Commit a5f05c0a authored by darin@apple.com's avatar darin@apple.com
Browse files

2010-12-01 Jia Pu <jpu@apple.com>

        Reviewed by Darin Adler.

        Support multiple correction candidates panel for misspelled word on Mac OS X.
        https://bugs.webkit.org/show_bug.cgi?id=50137
        <rdar://problem/8568059>

        Adopted new function signature defined in base class.

        * src/EditorClientImpl.cpp:
        (WebKit::EditorClientImpl::getGuessesForWord):
        * src/EditorClientImpl.h:
2010-12-01  Jia Pu  <jpu@apple.com>

        Reviewed by Darin Adler.

        Support multiple correction candidates panel for misspelled word on Mac OS X.
        https://bugs.webkit.org/show_bug.cgi?id=50137
        <rdar://problem/8568059>

        Adopted new function signature defined in base class.

        * WebCoreSupport/EditorClientQt.cpp:
        (WebCore::EditorClientQt::getGuessesForWord):
        * WebCoreSupport/EditorClientQt.h:
2010-12-01  Jia Pu  <jpu@apple.com>

        Reviewed by Darin Adler.

        Support multiple correction candidates panel for misspelled word on Mac OS X.
        https://bugs.webkit.org/show_bug.cgi?id=50137
        <rdar://problem/8568059>

        Adopted new function signature defined in base class.

        * WebCoreSupport/EditorClientGtk.cpp:
        (WebKit::EditorClient::getGuessesForWord):
        * WebCoreSupport/EditorClientGtk.h:
2010-12-01  Jia Pu  <jpu@apple.com>

        Reviewed by Darin Adler.

        Support multiple correction candidates panel for misspelled word on Mac OS X.
        https://bugs.webkit.org/show_bug.cgi?id=50137
        <rdar://problem/8568059>

        Adopted new function signature defined in base class.

        * WebCoreSupport/WebEditorClient.cpp:
        (WebEditorClient::getGuessesForWord):
        * WebCoreSupport/WebEditorClient.h:
2010-12-01  Jia Pu  <jpu@apple.com>

        Reviewed by Darin Adler.

        Support multiple correction candidates panel for misspelled word on Mac OS X.
        https://bugs.webkit.org/show_bug.cgi?id=50137
        <rdar://problem/8568059>

        Adopted new function signature defined in base class.

        * WebKitSupport/EditorClientWx.cpp:
        (WebCore::EditorClientWx::getGuessesForWord):
        * WebKitSupport/EditorClientWx.h:
2010-12-01  Jia Pu  <jpu@apple.com>

        Reviewed by Darin Adler.

        Support multiple correction candidates panel for misspelled word on Mac OS X.
        https://bugs.webkit.org/show_bug.cgi?id=50137
        <rdar://problem/8568059>

        This patch is for supporting multiple correction suggestion panel on Mac OS X.
        The behavior and implementation is similar to that of reversion candiate panel.

        * WebCoreSupport/WebEditorClient.h: Adopted new signatures defined in base class.

        * WebCoreSupport/WebEditorClient.mm:  Adopted new signatures defined in base class.
          Added code to handle new multiple suggestion canidate panel type.
        (WebEditorClient::showCorrectionPanel):
        (WebEditorClient::getGuessesForWord):
2010-12-01  Jia Pu  <jpu@apple.com>

        Reviewed by Darin Adler.

        Support multiple correction candidates panel for misspelled word on Mac OS X.
        https://bugs.webkit.org/show_bug.cgi?id=50137
        <rdar://problem/8568059>

        Adopted new function signature defined in base class.

        * WebCoreSupport/EditorClientHaiku.cpp:
        (WebCore::EditorClientHaiku::getGuessesForWord):
        * WebCoreSupport/EditorClientHaiku.h:
2010-12-01  Jia Pu  <jpu@apple.com>

        Reviewed by Darin Adler.

        Support multiple correction candidates panel for misspelled word on Mac OS X.
        https://bugs.webkit.org/show_bug.cgi?id=50137
        <rdar://problem/8568059>

        Adopted new function signature defined in base class.

        * WebCoreSupport/EditorClientWinCE.cpp:
        (WebKit::EditorClientWinCE::getGuessesForWord):
        * WebCoreSupport/EditorClientWinCE.h:
2010-12-01  Jia Pu  <jpu@apple.com>

        Reviewed by Darin Adler.

        Support multiple correction candidates panel for misspelled word on Mac OS X.
        https://bugs.webkit.org/show_bug.cgi?id=50137
        <rdar://problem/8568059>

        Adopted new function signature defined in base class.

        * WebCoreSupport/EditorClientEfl.cpp:
        (WebCore::EditorClientEfl::getGuessesForWord):
        * WebCoreSupport/EditorClientEfl.h:
2010-12-01  Jia Pu  <jpu@apple.com>

        Reviewed by Darin Adler.

        Support multiple correction candidates panel for misspelled word on Mac OS X.
        https://bugs.webkit.org/show_bug.cgi?id=50137
        <rdar://problem/8568059>

        Test: platform/mac/editing/spelling/delete-autocorrected-word-1.html
        Manual test: WebCore/manual-tests/autocorrection/dismiss-multiple-guesses.html
                     WebCore/manual-tests/autocorrection/select-from-multiple-guesses.html

        This patch is for supporting multiple correction suggestion panel on Mac OS X.
        The behavior and implementation is similar to that of reversion candiate panel.

        * WebCore.exp.in: Added and removed symbols.

        * editing/CorrectionPanelInfo.h: Added new correction panel type, PanelTypeSpellingSuggestions.

        * editing/Editor.cpp:
        (WebCore::markerTypesForAutocorrection): Convenient function for getting marker types to
          be added to autocorrected word.
        (WebCore::boundingBoxForRange): Convenient function for calculating the bounding box of a range.
        (WebCore::markerTypesForReplacement): Convenient function for getting marker types to
          be added to word that has been replaced by various correction panel.
        (WebCore::Editor::respondToChangedSelection): Added code to trigger timer for multiple
          suggestion panel.
        (WebCore::Editor::guessesForMisspelledSelection): Adopted new signature of EditorClient::getGuessesForWord().
        (WebCore::Editor::markMisspellingsAfterTypingToWord): Adopted new signature of applyCorrectionPanelInfo().
        (WebCore::Editor::markAllMisspellingsAndBadGrammarInRanges): Ditto.
        (WebCore::Editor::correctionPanelTimerFired): Added code to handle new multiple suggestion panel.
        (WebCore::Editor::handleCorrectionPanelResult): Replaced handleRejectedCorrection(), since
          with new AppKit correction panel API, not only rejection, but also confirmation can be
          handled in callback.
        (WebCore::Editor::stopCorrectionPanelTimer): Moved the code that clears correction panel info
          from dismissCorrectionPanel() to this function to fix a bug that would occur when deleting
          autocorrected word.
        (WebCore::Editor::dismissCorrectionPanel): Ditto.
        (WebCore::Editor::applyCorrectionPanelInfo): Added code to handle new multiple suggestion panel.

        * editing/Editor.h: Replaced handleRejectedCorrection() with handleCorrectionPanelResult().
          Changed the signature of applyCorrectionPanelInfo() to hanlde new correction panel type.

        * editing/TextCheckingHelper.cpp:
        (WebCore::TextCheckingHelper::guessesForMisspelledOrUngrammaticalRange): Adopted new EditorClient::getGuessesForWord().

        * editing/TextCheckingHelper.h: Made paragraphRange() public.

        * loader/EmptyClients.h:
        (WebCore::EmptyEditorClient::showCorrectionPanel): Adopted new signature defined in base class.
        (WebCore::EmptyEditorClient::getGuessesForWord): Ditto.

        * manual-tests/autocorrection/dismiss-multiple-guesses.html: Added.

        * manual-tests/autocorrection/select-from-multiple-guesses.html: Added.

        * page/EditorClient.h:  Changed showCorrectionPanel() to allow passing multiple correction
          candidates. Changed getGuessesForWord() to allow passing in contextual text for better
          correction suggestions (for those spellcheckers that utilizes such contextual information).
2010-12-01  Jia Pu  <jpu@apple.com>

        Reviewed by Darin Adler.

        Support multiple correction candidates panel for misspelled word on Mac OS X.
        https://bugs.webkit.org/show_bug.cgi?id=50137
        <rdar://problem/8568059>

        * platform/mac-leopard/Skipped:
        * platform/mac-snowleopard/Skipped:
        * platform/mac-tiger/Skipped:
        * platform/mac-wk2/Skipped:
        * platform/mac/editing/spelling/delete-autocorrected-word-1-expected.txt: Added.
        * platform/mac/editing/spelling/delete-autocorrected-word-1.html: Added.
2010-12-01  Jia Pu  <jpu@apple.com>

        Reviewed by Darin Adler.

        Support multiple correction candidates panel for misspelled word on Mac OS X.
        https://bugs.webkit.org/show_bug.cgi?id=50137
        <rdar://problem/8568059>

        Adopted new function signatures defined in base class.

        * WebProcess/WebCoreSupport/WebEditorClient.cpp:
        (WebKit::WebEditorClient::getGuessesForWord):
        * WebProcess/WebCoreSupport/WebEditorClient.h:
        * WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm:
        (WebKit::WebEditorClient::showCorrectionPanel):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@73088 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent d3c399f3
2010-12-01 Jia Pu <jpu@apple.com>
Reviewed by Darin Adler.
Support multiple correction candidates panel for misspelled word on Mac OS X.
https://bugs.webkit.org/show_bug.cgi?id=50137
<rdar://problem/8568059>
* platform/mac-leopard/Skipped:
* platform/mac-snowleopard/Skipped:
* platform/mac-tiger/Skipped:
* platform/mac-wk2/Skipped:
* platform/mac/editing/spelling/delete-autocorrected-word-1-expected.txt: Added.
* platform/mac/editing/spelling/delete-autocorrected-word-1.html: Added.
2010-12-01 Brian Weinstein <bweinstein@apple.com>
 
Land Windows specific results for /vertical-scrollbar-in-rtl.html
......@@ -106,6 +106,7 @@ platform/mac/editing/spelling/autocorrection-removing-underline-after-paste.html
platform/mac/editing/spelling/autocorrection-removing-underline.html
platform/mac/editing/spelling/autocorrection-simple.html
platform/mac/editing/spelling/click-autocorrected-word.html
platform/mac/editing/spelling/delete-autocorrected-word-1.html
platform/mac/editing/spelling/delete-into-autocorrected-word.html
platform/mac/editing/spelling/delete-into-misspelled-word.html
platform/mac/editing/spelling/editing-multiple-words-with-markers.html
......
......@@ -131,6 +131,7 @@ platform/mac/editing/spelling/autocorrection-removing-underline-after-paste.html
platform/mac/editing/spelling/autocorrection-removing-underline.html
platform/mac/editing/spelling/autocorrection-simple.html
platform/mac/editing/spelling/click-autocorrected-word.html
platform/mac/editing/spelling/delete-autocorrected-word-1.html
platform/mac/editing/spelling/delete-into-autocorrected-word.html
platform/mac/editing/spelling/delete-into-misspelled-word.html
platform/mac/editing/spelling/editing-multiple-words-with-markers.html
......
......@@ -211,6 +211,7 @@ platform/mac/editing/spelling/autocorrection-removing-underline-after-paste.html
platform/mac/editing/spelling/autocorrection-removing-underline.html
platform/mac/editing/spelling/autocorrection-simple.html
platform/mac/editing/spelling/click-autocorrected-word.html
platform/mac/editing/spelling/delete-autocorrected-word-1.html
platform/mac/editing/spelling/delete-into-autocorrected-word.html
platform/mac/editing/spelling/delete-into-misspelled-word.html
platform/mac/editing/spelling/editing-multiple-words-with-markers.html
......
......@@ -498,6 +498,7 @@ platform/mac/editing/spelling/autocorrection-removing-underline-after-paste.html
platform/mac/editing/spelling/autocorrection-removing-underline.html
platform/mac/editing/spelling/autocorrection-simple.html
platform/mac/editing/spelling/click-autocorrected-word.html
platform/mac/editing/spelling/delete-autocorrected-word-1.html
platform/mac/editing/spelling/delete-into-autocorrected-word.html
platform/mac/editing/spelling/delete-into-misspelled-word.html
platform/mac/editing/spelling/editing-multiple-words-with-markers.html
......
EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 3 of DIV > BODY > HTML > #document
EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document toDOMRange:range from 1 of #text > DIV > BODY > HTML > #document to 1 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 1 of #text > DIV > BODY > HTML > #document to 1 of #text > DIV > BODY > HTML > #document toDOMRange:range from 2 of #text > DIV > BODY > HTML > #document to 2 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 2 of #text > DIV > BODY > HTML > #document to 2 of #text > DIV > BODY > HTML > #document toDOMRange:range from 3 of #text > DIV > BODY > HTML > #document to 3 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 3 of #text > DIV > BODY > HTML > #document to 3 of #text > DIV > BODY > HTML > #document toDOMRange:range from 4 of #text > DIV > BODY > HTML > #document to 4 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 4 of #text > DIV > BODY > HTML > #document to 4 of #text > DIV > BODY > HTML > #document toDOMRange:range from 5 of #text > DIV > BODY > HTML > #document to 5 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 5 of #text > DIV > BODY > HTML > #document to 5 of #text > DIV > BODY > HTML > #document toDOMRange:range from 6 of #text > DIV > BODY > HTML > #document to 6 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 6 of #text > DIV > BODY > HTML > #document to 6 of #text > DIV > BODY > HTML > #document toDOMRange:range from 7 of #text > DIV > BODY > HTML > #document to 7 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 7 of #text > DIV > BODY > HTML > #document to 7 of #text > DIV > BODY > HTML > #document toDOMRange:range from 8 of #text > DIV > BODY > HTML > #document to 8 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 8 of #text > DIV > BODY > HTML > #document to 8 of #text > DIV > BODY > HTML > #document toDOMRange:range from 9 of #text > DIV > BODY > HTML > #document to 9 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 9 of #text > DIV > BODY > HTML > #document to 9 of #text > DIV > BODY > HTML > #document toDOMRange:range from 10 of #text > DIV > BODY > HTML > #document to 10 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 10 of #text > DIV > BODY > HTML > #document to 10 of #text > DIV > BODY > HTML > #document toDOMRange:range from 11 of #text > DIV > BODY > HTML > #document to 11 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 11 of #text > DIV > BODY > HTML > #document to 11 of #text > DIV > BODY > HTML > #document toDOMRange:range from 12 of #text > DIV > BODY > HTML > #document to 12 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 12 of #text > DIV > BODY > HTML > #document to 12 of #text > DIV > BODY > HTML > #document toDOMRange:range from 13 of #text > DIV > BODY > HTML > #document to 13 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 13 of #text > DIV > BODY > HTML > #document to 13 of #text > DIV > BODY > HTML > #document toDOMRange:range from 4 of #text > DIV > BODY > HTML > #document to 12 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: shouldInsertText:message replacingDOMRange:range from 4 of #text > DIV > BODY > HTML > #document to 12 of #text > DIV > BODY > HTML > #document givenAction:WebViewInsertActionTyped
EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 4 of #text > DIV > BODY > HTML > #document to 12 of #text > DIV > BODY > HTML > #document toDOMRange:range from 11 of #text > DIV > BODY > HTML > #document to 11 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: shouldDeleteDOMRange:range from 11 of #text > DIV > BODY > HTML > #document to 12 of #text > DIV > BODY > HTML > #document
EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 11 of #text > DIV > BODY > HTML > #document to 11 of #text > DIV > BODY > HTML > #document toDOMRange:range from 11 of #text > DIV > BODY > HTML > #document to 11 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
EDITING DELEGATE: shouldDeleteDOMRange:range from 10 of #text > DIV > BODY > HTML > #document to 11 of #text > DIV > BODY > HTML > #document
EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 10 of #text > DIV > BODY > HTML > #document to 10 of #text > DIV > BODY > HTML > #document toDOMRange:range from 10 of #text > DIV > BODY > HTML > #document to 10 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
EDITING DELEGATE: shouldDeleteDOMRange:range from 9 of #text > DIV > BODY > HTML > #document to 10 of #text > DIV > BODY > HTML > #document
EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 9 of #text > DIV > BODY > HTML > #document to 9 of #text > DIV > BODY > HTML > #document toDOMRange:range from 9 of #text > DIV > BODY > HTML > #document to 9 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
EDITING DELEGATE: shouldDeleteDOMRange:range from 8 of #text > DIV > BODY > HTML > #document to 9 of #text > DIV > BODY > HTML > #document
EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 8 of #text > DIV > BODY > HTML > #document to 8 of #text > DIV > BODY > HTML > #document toDOMRange:range from 8 of #text > DIV > BODY > HTML > #document to 8 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
EDITING DELEGATE: shouldDeleteDOMRange:range from 7 of #text > DIV > BODY > HTML > #document to 8 of #text > DIV > BODY > HTML > #document
EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 7 of #text > DIV > BODY > HTML > #document to 7 of #text > DIV > BODY > HTML > #document toDOMRange:range from 7 of #text > DIV > BODY > HTML > #document to 7 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
EDITING DELEGATE: shouldDeleteDOMRange:range from 6 of #text > DIV > BODY > HTML > #document to 7 of #text > DIV > BODY > HTML > #document
EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 6 of #text > DIV > BODY > HTML > #document to 6 of #text > DIV > BODY > HTML > #document toDOMRange:range from 6 of #text > DIV > BODY > HTML > #document to 6 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
EDITING DELEGATE: shouldDeleteDOMRange:range from 5 of #text > DIV > BODY > HTML > #document to 6 of #text > DIV > BODY > HTML > #document
EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 5 of #text > DIV > BODY > HTML > #document to 5 of #text > DIV > BODY > HTML > #document toDOMRange:range from 5 of #text > DIV > BODY > HTML > #document to 5 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
EDITING DELEGATE: shouldDeleteDOMRange:range from 4 of #text > DIV > BODY > HTML > #document to 5 of #text > DIV > BODY > HTML > #document
EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 4 of #text > DIV > BODY > HTML > #document to 4 of #text > DIV > BODY > HTML > #document toDOMRange:range from 4 of #text > DIV > BODY > HTML > #document to 4 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
layer at (0,0) size 800x600
RenderView at (0,0) size 800x600
layer at (0,0) size 800x600
RenderBlock {HTML} at (0,0) size 800x600
RenderBody {BODY} at (8,8) size 784x584
RenderBlock {DIV} at (0,0) size 784x18
RenderText {#text} at (0,0) size 397x18
text run at (0,0) width 397: "Upon success, you should only see the word \"the\" in text field."
RenderBlock {P} at (0,34) size 784x18 [color=#008000]
RenderText {#text} at (0,0) size 702x18
text run at (0,0) width 702: "Note, this test can fail due to user specific spell checking data. To fix this, remove all files in ~/Library/Spelling."
RenderBlock {DIV} at (0,68) size 784x56 [border: (2px solid #FF0000)]
RenderText {#text} at (14,14) size 36x28
text run at (14,14) width 36: "the "
RenderInline {SPAN} at (0,0) size 0x28
caret: position 4 of child 0 {#text} of child 5 {DIV} of body
<html>
<head>
<style>
.editing {
border: 2px solid red;
padding: 12px;
font-size: 24px;
}
</style>
<script src=../../../../editing/editing.js language="JavaScript" type="text/JavaScript" ></script>
<script>
function editingTest() {
typeCharacterCommand('t');
typeCharacterCommand('h');
typeCharacterCommand('e');
typeCharacterCommand(' ');
typeCharacterCommand('m');
typeCharacterCommand('e');
typeCharacterCommand('s');
typeCharacterCommand('s');
typeCharacterCommand('a');
typeCharacterCommand('g');
typeCharacterCommand('e');
typeCharacterCommand('e');
typeCharacterCommand(' ');
execDeleteCommand();
execDeleteCommand();
execDeleteCommand();
execDeleteCommand();
execDeleteCommand();
execDeleteCommand();
execDeleteCommand();
execDeleteCommand();
}
</script>
<title>Delete Autocorrected Word Test 1</title>
</head>
<body>
<div>Upon success, you should only see the word "the" in text field.</div>
<p style="color:green">Note, this test can fail due to user specific spell checking data. To fix this, remove all files in ~/Library/Spelling.</p>
<div contenteditable id="root" class="editing">
<span id="test"></span>
</div>
<script>
runEditingTest();
</script>
</body>
</html>
2010-12-01 Jia Pu <jpu@apple.com>
Reviewed by Darin Adler.
Support multiple correction candidates panel for misspelled word on Mac OS X.
https://bugs.webkit.org/show_bug.cgi?id=50137
<rdar://problem/8568059>
Test: platform/mac/editing/spelling/delete-autocorrected-word-1.html
Manual test: WebCore/manual-tests/autocorrection/dismiss-multiple-guesses.html
WebCore/manual-tests/autocorrection/select-from-multiple-guesses.html
This patch is for supporting multiple correction suggestion panel on Mac OS X.
The behavior and implementation is similar to that of reversion candiate panel.
* WebCore.exp.in: Added and removed symbols.
* editing/CorrectionPanelInfo.h: Added new correction panel type, PanelTypeSpellingSuggestions.
* editing/Editor.cpp:
(WebCore::markerTypesForAutocorrection): Convenient function for getting marker types to
be added to autocorrected word.
(WebCore::boundingBoxForRange): Convenient function for calculating the bounding box of a range.
(WebCore::markerTypesForReplacement): Convenient function for getting marker types to
be added to word that has been replaced by various correction panel.
(WebCore::Editor::respondToChangedSelection): Added code to trigger timer for multiple
suggestion panel.
(WebCore::Editor::guessesForMisspelledSelection): Adopted new signature of EditorClient::getGuessesForWord().
(WebCore::Editor::markMisspellingsAfterTypingToWord): Adopted new signature of applyCorrectionPanelInfo().
(WebCore::Editor::markAllMisspellingsAndBadGrammarInRanges): Ditto.
(WebCore::Editor::correctionPanelTimerFired): Added code to handle new multiple suggestion panel.
(WebCore::Editor::handleCorrectionPanelResult): Replaced handleRejectedCorrection(), since
with new AppKit correction panel API, not only rejection, but also confirmation can be
handled in callback.
(WebCore::Editor::stopCorrectionPanelTimer): Moved the code that clears correction panel info
from dismissCorrectionPanel() to this function to fix a bug that would occur when deleting
autocorrected word.
(WebCore::Editor::dismissCorrectionPanel): Ditto.
(WebCore::Editor::applyCorrectionPanelInfo): Added code to handle new multiple suggestion panel.
* editing/Editor.h: Replaced handleRejectedCorrection() with handleCorrectionPanelResult().
Changed the signature of applyCorrectionPanelInfo() to hanlde new correction panel type.
* editing/TextCheckingHelper.cpp:
(WebCore::TextCheckingHelper::guessesForMisspelledOrUngrammaticalRange): Adopted new EditorClient::getGuessesForWord().
* editing/TextCheckingHelper.h: Made paragraphRange() public.
* loader/EmptyClients.h:
(WebCore::EmptyEditorClient::showCorrectionPanel): Adopted new signature defined in base class.
(WebCore::EmptyEditorClient::getGuessesForWord): Ditto.
* manual-tests/autocorrection/dismiss-multiple-guesses.html: Added.
* manual-tests/autocorrection/select-from-multiple-guesses.html: Added.
* page/EditorClient.h: Changed showCorrectionPanel() to allow passing multiple correction
candidates. Changed getGuessesForWord() to allow passing in contextual text for better
correction suggestions (for those spellcheckers that utilizes such contextual information).
2010-12-01 David Hyatt <hyatt@apple.com>
 
Reviewed by James Robinson.
......@@ -680,10 +680,10 @@ __ZN7WebCore6Editor21isSelectionMisspelledEv
__ZN7WebCore6Editor23setBaseWritingDirectionENS_16WritingDirectionE
__ZN7WebCore6Editor24advanceToNextMisspellingEb
__ZN7WebCore6Editor24computeAndSetTypingStyleEPNS_19CSSStyleDeclarationENS_10EditActionE
__ZN7WebCore6Editor24handleRejectedCorrectionEv
__ZN7WebCore6Editor24isSelectionUngrammaticalEv
__ZN7WebCore6Editor26decreaseSelectionListLevelEv
__ZN7WebCore6Editor26increaseSelectionListLevelEv
__ZN7WebCore6Editor27handleCorrectionPanelResultERKN3WTF6StringE
__ZN7WebCore6Editor29canDecreaseSelectionListLevelEv
__ZN7WebCore6Editor29canIncreaseSelectionListLevelEv
__ZN7WebCore6Editor30applyParagraphStyleToSelectionEPNS_19CSSStyleDeclarationENS_10EditActionE
......
......@@ -44,7 +44,8 @@ namespace WebCore {
struct CorrectionPanelInfo {
enum PanelType {
PanelTypeCorrection = 0,
PanelTypeReversion
PanelTypeReversion,
PanelTypeSpellingSuggestions
};
RefPtr<Range> m_rangeToBeReplaced;
......
......@@ -92,6 +92,37 @@ static inline bool isAmbiguousBoundaryCharacter(UChar character)
return character == '\'' || character == rightSingleQuotationMark || character == hebrewPunctuationGershayim;
}
#if SUPPORT_AUTOCORRECTION_PANEL
static const Vector<DocumentMarker::MarkerType>& markerTypesForAutocorrection()
{
DEFINE_STATIC_LOCAL(Vector<DocumentMarker::MarkerType>, markerTypesForAutoCorrection, ());
if (markerTypesForAutoCorrection.isEmpty()) {
markerTypesForAutoCorrection.append(DocumentMarker::Replacement);
markerTypesForAutoCorrection.append(DocumentMarker::CorrectionIndicator);
}
return markerTypesForAutoCorrection;
}
static FloatRect boundingBoxForRange(Range* range)
{
Vector<FloatQuad> textQuads;
range->getBorderAndTextQuads(textQuads);
FloatRect totalBoundingBox;
size_t size = textQuads.size();
for (size_t i = 0; i< size; ++i)
totalBoundingBox.unite(textQuads[i].boundingBox());
return totalBoundingBox;
}
#endif // SUPPORT_AUTOCORRECTION_PANEL
static const Vector<DocumentMarker::MarkerType>& markerTypesForReplacement()
{
DEFINE_STATIC_LOCAL(Vector<DocumentMarker::MarkerType>, markerTypesForReplacement, ());
if (markerTypesForReplacement.isEmpty())
markerTypesForReplacement.append(DocumentMarker::Replacement);
return markerTypesForReplacement;
}
// When an event handler has moved the selection outside of a text control
// we should use the target control's selection for this editing operation.
VisibleSelection Editor::selectionForCommand(Event* event)
......@@ -500,13 +531,18 @@ void Editor::respondToChangedSelection(const VisibleSelection& oldSelection)
size_t markerCount = markers.size();
for (size_t i = 0; i < markerCount; ++i) {
const DocumentMarker& marker = markers[i];
if (marker.type == DocumentMarker::CorrectionIndicator && static_cast<int>(marker.endOffset) == endOffset) {
if (((marker.type == DocumentMarker::CorrectionIndicator && marker.description.length()) || marker.type == DocumentMarker::Spelling) && static_cast<int>(marker.endOffset) == endOffset) {
RefPtr<Range> wordRange = Range::create(frame()->document(), node, marker.startOffset, node, marker.endOffset);
String currentWord = plainText(wordRange.get());
if (currentWord.length() > 0 && marker.description.length() > 0) {
if (currentWord.length()) {
m_correctionPanelInfo.m_rangeToBeReplaced = wordRange;
m_correctionPanelInfo.m_replacementString = marker.description;
startCorrectionPanelTimer(CorrectionPanelInfo::PanelTypeReversion);
m_correctionPanelInfo.m_replacedString = currentWord;
if (marker.type == DocumentMarker::Spelling)
startCorrectionPanelTimer(CorrectionPanelInfo::PanelTypeSpellingSuggestions);
else {
m_correctionPanelInfo.m_replacementString = marker.description;
startCorrectionPanelTimer(CorrectionPanelInfo::PanelTypeReversion);
}
}
break;
}
......@@ -1932,7 +1968,7 @@ Vector<String> Editor::guessesForMisspelledSelection()
Vector<String> guesses;
if (client())
client()->getGuessesForWord(selectedString, guesses);
client()->getGuessesForWord(selectedString, String(), guesses);
return guesses;
}
......@@ -2019,7 +2055,7 @@ void Editor::markMisspellingsAfterTypingToWord(const VisiblePosition &wordStart,
doApplyCorrection = false;
}
if (doApplyCorrection)
applyCorrectionPanelInfo(true);
applyCorrectionPanelInfo(markerTypesForAutocorrection());
m_correctionPanelInfo.m_rangeToBeReplaced.clear();
#else
UNUSED_PARAM(selectionAfterTyping);
......@@ -2341,7 +2377,7 @@ void Editor::markAllMisspellingsAndBadGrammarInRanges(TextCheckingOptions textCh
m_correctionPanelInfo.m_replacedString = replacedString;
m_correctionPanelInfo.m_replacementString = result->replacement;
m_correctionPanelInfo.m_isActive = true;
client()->showCorrectionPanel(m_correctionPanelInfo.m_panelType, totalBoundingBox, m_correctionPanelInfo.m_replacedString, result->replacement, this);
client()->showCorrectionPanel(m_correctionPanelInfo.m_panelType, totalBoundingBox, m_correctionPanelInfo.m_replacedString, result->replacement, Vector<String>(), this);
doReplacement = false;
}
#endif
......@@ -2419,39 +2455,66 @@ void Editor::markMisspellingsAndBadGrammar(const VisibleSelection& spellingSelec
void Editor::correctionPanelTimerFired(Timer<Editor>*)
{
#if SUPPORT_AUTOCORRECTION_PANEL
if (m_correctionPanelInfo.m_panelType == CorrectionPanelInfo::PanelTypeCorrection) {
switch (m_correctionPanelInfo.m_panelType) {
case CorrectionPanelInfo::PanelTypeCorrection: {
VisibleSelection selection(frame()->selection()->selection());
VisiblePosition start(selection.start(), selection.affinity());
VisiblePosition p = startOfWord(start, LeftWordIfOnBoundary);
VisibleSelection adjacentWords = VisibleSelection(p, start);
markAllMisspellingsAndBadGrammarInRanges(MarkSpelling | ShowCorrectionPanel, adjacentWords.toNormalizedRange().get(), 0);
} else {
String currentWord = plainText(m_correctionPanelInfo.m_rangeToBeReplaced.get());
Vector<FloatQuad> textQuads;
m_correctionPanelInfo.m_rangeToBeReplaced->getBorderAndTextQuads(textQuads);
Vector<FloatQuad>::const_iterator end = textQuads.end();
FloatRect totalBoundingBox;
for (Vector<FloatQuad>::const_iterator it = textQuads.begin(); it < end; ++it)
totalBoundingBox.unite(it->boundingBox());
}
break;
case CorrectionPanelInfo::PanelTypeReversion: {
m_correctionPanelInfo.m_isActive = true;
m_correctionPanelInfo.m_replacedString = plainText(m_correctionPanelInfo.m_rangeToBeReplaced.get());
client()->showCorrectionPanel(m_correctionPanelInfo.m_panelType, boundingBoxForRange(m_correctionPanelInfo.m_rangeToBeReplaced.get()), m_correctionPanelInfo.m_replacedString, m_correctionPanelInfo.m_replacementString, Vector<String>(), this);
}
break;
case CorrectionPanelInfo::PanelTypeSpellingSuggestions: {
if (plainText(m_correctionPanelInfo.m_rangeToBeReplaced.get()) != m_correctionPanelInfo.m_replacedString)
break;
String paragraphText = plainText(TextCheckingParagraph(m_correctionPanelInfo.m_rangeToBeReplaced).paragraphRange().get());
Vector<String> suggestions;
client()->getGuessesForWord(m_correctionPanelInfo.m_replacedString, paragraphText, suggestions);
if (suggestions.isEmpty())
break;
String topSuggestion = suggestions.first();
suggestions.remove(0);
m_correctionPanelInfo.m_isActive = true;
m_correctionPanelInfo.m_replacedString = currentWord;
client()->showCorrectionPanel(m_correctionPanelInfo.m_panelType, totalBoundingBox, m_correctionPanelInfo.m_replacedString, m_correctionPanelInfo.m_replacementString, this);
client()->showCorrectionPanel(m_correctionPanelInfo.m_panelType, boundingBoxForRange(m_correctionPanelInfo.m_rangeToBeReplaced.get()), m_correctionPanelInfo.m_replacedString, topSuggestion, suggestions, this);
}
break;
}
#endif
}
void Editor::handleRejectedCorrection()
void Editor::handleCorrectionPanelResult(const String& correction)
{
Range* replacedRange = m_correctionPanelInfo.m_rangeToBeReplaced.get();
if (!replacedRange || m_frame->document() != replacedRange->ownerDocument())
return;
if (m_correctionPanelInfo.m_panelType == CorrectionPanelInfo::PanelTypeCorrection)
String currentWord = plainText(m_correctionPanelInfo.m_rangeToBeReplaced.get());
// Check to see if the word we are about to correct has been changed between timer firing and callback being triggered.
if (currentWord != m_correctionPanelInfo.m_replacedString)
return;
m_correctionPanelInfo.m_isActive = false;
switch (m_correctionPanelInfo.m_panelType) {
case CorrectionPanelInfo::PanelTypeCorrection:
replacedRange->startContainer()->document()->markers()->addMarker(replacedRange, DocumentMarker::RejectedCorrection, m_correctionPanelInfo.m_replacedString);
else {
m_correctionPanelInfo.m_isActive = false;
applyCorrectionPanelInfo(false);
break;
case CorrectionPanelInfo::PanelTypeReversion:
applyCorrectionPanelInfo(markerTypesForReplacement());
case CorrectionPanelInfo::PanelTypeSpellingSuggestions:
if (correction.length()) {
m_correctionPanelInfo.m_replacementString = correction;
applyCorrectionPanelInfo(markerTypesForReplacement());
}
break;
}
m_correctionPanelInfo.m_rangeToBeReplaced.clear();
}
......@@ -2475,6 +2538,7 @@ void Editor::stopCorrectionPanelTimer()
{
#if SUPPORT_AUTOCORRECTION_PANEL
m_correctionPanelTimer.stop();
m_correctionPanelInfo.m_rangeToBeReplaced.clear();
#endif
}
......@@ -2504,7 +2568,6 @@ void Editor::dismissCorrectionPanel(CorrectionWasRejectedOrNot correctionWasReje
if (!m_correctionPanelInfo.m_isActive)
return;
m_correctionPanelInfo.m_isActive = false;
m_correctionPanelInfo.m_rangeToBeReplaced.clear();
if (client())
client()->dismissCorrectionPanel(correctionWasRejectedOrNot);
#else
......@@ -2608,7 +2671,7 @@ void Editor::removeSpellAndCorrectionMarkersFromWordsToBeEdited(bool doNotRemove
document->markers()->removeMarkers(pairIterator->first.get(), pairIterator->second);
}
void Editor::applyCorrectionPanelInfo(bool addCorrectionIndicatorMarker)
void Editor::applyCorrectionPanelInfo(const Vector<DocumentMarker::MarkerType>& markerTypesToAdd)
{
if (!m_correctionPanelInfo.m_rangeToBeReplaced)
return;
......@@ -2649,9 +2712,10 @@ void Editor::applyCorrectionPanelInfo(bool addCorrectionIndicatorMarker)
caretPosition.moveToOffset(caretPosition.offsetInContainerNode() + m_correctionPanelInfo.m_replacementString.length() - m_correctionPanelInfo.m_replacedString.length());
setEnd(paragraphRangeContainingCorrection.get(), endOfParagraph(caretPosition));
RefPtr<Range> replacementRange = TextIterator::subrange(paragraphRangeContainingCorrection.get(), correctionStartOffsetInParagraph, m_correctionPanelInfo.m_replacementString.length());
replacementRange->startContainer()->document()->markers()->addMarker(replacementRange.get(), DocumentMarker::Replacement, m_correctionPanelInfo.m_replacementString);
if (addCorrectionIndicatorMarker)
replacementRange->startContainer()->document()->markers()->addMarker(replacementRange.get(), DocumentMarker::CorrectionIndicator, m_correctionPanelInfo.m_replacedString);
DocumentMarkerController* markers = replacementRange->startContainer()->document()->markers();
size_t size = markerTypesToAdd.size();
for (size_t i = 0; i < size; ++i)
markers->addMarker(replacementRange.get(), markerTypesToAdd[i], m_correctionPanelInfo.m_replacementString);
m_frame->selection()->moveTo(caretPosition, false);
}
}
......
......@@ -313,7 +313,8 @@ public:
void handleCancelOperation();
void startCorrectionPanelTimer(CorrectionPanelInfo::PanelType);
void handleRejectedCorrection();
// If user confirmed a correction in the correction panel, correction has non-zero length, otherwise it means that user has dismissed the panel.
void handleCorrectionPanelResult(const String& correction);
bool isShowingCorrectionPanel();
void pasteAsFragment(PassRefPtr<DocumentFragment>, bool smartReplace, bool matchStyle);
......@@ -409,7 +410,7 @@ private:
Node* findEventTargetFromSelection() const;
void stopCorrectionPanelTimer();
void dismissCorrectionPanel(CorrectionWasRejectedOrNot);
void applyCorrectionPanelInfo(bool addCorrectionIndicatorMarker);
void applyCorrectionPanelInfo(const Vector<DocumentMarker::MarkerType>& markerTypesToAdd);
};
inline void Editor::setStartNewKillRingSequence(bool flag)
......
......@@ -541,7 +541,7 @@ Vector<String> TextCheckingHelper::guessesForMisspelledOrUngrammaticalRange(bool
if (result->type == TextCheckingTypeSpelling && paragraph.checkingRangeMatches(result->location, result->length)) {
String misspelledWord = paragraph.checkingSubstring();
ASSERT(misspelledWord.length());
m_client->getGuessesForWord(misspelledWord, guesses);
m_client->getGuessesForWord(misspelledWord, String(), guesses);
m_client->updateSpellingUIWithMisspelledWord(misspelledWord);
misspelled = true;
return guesses;
......
......@@ -55,11 +55,11 @@ public:
bool checkingRangeMatches(int location, int length) const { return location == checkingStart() && length == checkingLength(); }
bool isCheckingRangeCoveredBy(int location, int length) const { return location <= checkingStart() && location + length >= checkingStart() + checkingLength(); }
bool checkingRangeCovers(int location, int length) const { return location < checkingEnd() && location + length > checkingStart(); }
PassRefPtr<Range> paragraphRange() const;
private:
void invalidateParagraphRangeValues();
PassRefPtr<Range> checkingRange() const { return m_checkingRange; }
PassRefPtr<Range> paragraphRange() const;
PassRefPtr<Range> offsetAsRange() const;
const String& text() const;
......
......@@ -480,7 +480,7 @@ public:
virtual void checkTextOfParagraph(const UChar*, int, uint64_t, Vector<TextCheckingResult>&) { };
#endif
#if SUPPORT_AUTOCORRECTION_PANEL
virtual void showCorrectionPanel(CorrectionPanelInfo::PanelType, const FloatRect&, const String&, const String&, Editor*) { }
virtual void showCorrectionPanel(CorrectionPanelInfo::PanelType, const FloatRect&, const String&, const String&, const Vector<String>&, Editor*) { }
virtual void dismissCorrectionPanel(CorrectionWasRejectedOrNot) { }
virtual bool isShowingCorrectionPanel() { return false; }
#endif
......@@ -488,7 +488,7 @@ public:
virtual void updateSpellingUIWithMisspelledWord(const String&) { }
virtual void showSpellingUI(bool) { }
virtual bool spellingUIIsShowing() { return false; }
virtual void getGuessesForWord(const String&, Vector<String>&) { }
virtual void getGuessesForWord(const String&, const String&, Vector<String>&) { }
virtual void willSetInputMethodState() { }
virtual void setInputMethodState(bool) { }
......
<html>
<head>
<style>
.editing {
border: 2px solid red;
padding: 12px;
font-size: 24px;
}
</style>
<script src=../../../LayoutTests/editing/editing.js language="JavaScript" type="text/JavaScript" ></script>
<script>
function editingTest() {
typeCharacterCommand('t');