[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-10851-g50815da

darin at apple.com darin at apple.com
Wed Dec 22 17:53:11 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit a5f05c0a6d24f491379fb74dc20684c62e728acc
Author: darin at apple.com <darin at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Dec 2 01:19:05 2010 +0000

    2010-12-01  Jia Pu  <jpu at 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 at 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 at 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 at 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 at 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 at 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 at 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 at 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 at 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 at 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 at 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 at 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

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 5dd92a3..2f56543 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,18 @@
+2010-12-01  Jia Pu  <jpu at 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 at apple.com>
 
         Land Windows specific results for /vertical-scrollbar-in-rtl.html
diff --git a/LayoutTests/platform/mac-leopard/Skipped b/LayoutTests/platform/mac-leopard/Skipped
index 6a05892..f1160c6 100644
--- a/LayoutTests/platform/mac-leopard/Skipped
+++ b/LayoutTests/platform/mac-leopard/Skipped
@@ -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
diff --git a/LayoutTests/platform/mac-snowleopard/Skipped b/LayoutTests/platform/mac-snowleopard/Skipped
index 46d5082..4c50160 100644
--- a/LayoutTests/platform/mac-snowleopard/Skipped
+++ b/LayoutTests/platform/mac-snowleopard/Skipped
@@ -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
diff --git a/LayoutTests/platform/mac-tiger/Skipped b/LayoutTests/platform/mac-tiger/Skipped
index 719b65d..a496878 100644
--- a/LayoutTests/platform/mac-tiger/Skipped
+++ b/LayoutTests/platform/mac-tiger/Skipped
@@ -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
diff --git a/LayoutTests/platform/mac-wk2/Skipped b/LayoutTests/platform/mac-wk2/Skipped
index b427adb..ad82150 100644
--- a/LayoutTests/platform/mac-wk2/Skipped
+++ b/LayoutTests/platform/mac-wk2/Skipped
@@ -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
diff --git a/LayoutTests/platform/mac/editing/spelling/delete-autocorrected-word-1-expected.txt b/LayoutTests/platform/mac/editing/spelling/delete-autocorrected-word-1-expected.txt
new file mode 100644
index 0000000..b87a909
--- /dev/null
+++ b/LayoutTests/platform/mac/editing/spelling/delete-autocorrected-word-1-expected.txt
@@ -0,0 +1,97 @@
+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
diff --git a/LayoutTests/platform/mac/editing/spelling/delete-autocorrected-word-1.html b/LayoutTests/platform/mac/editing/spelling/delete-autocorrected-word-1.html
new file mode 100644
index 0000000..5a6dcb8
--- /dev/null
+++ b/LayoutTests/platform/mac/editing/spelling/delete-autocorrected-word-1.html
@@ -0,0 +1,56 @@
+<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>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 5d42cdb..e2b7c8f 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,63 @@
+2010-12-01  Jia Pu  <jpu at 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 at apple.com>
 
         Reviewed by James Robinson.
diff --git a/WebCore/WebCore.exp.in b/WebCore/WebCore.exp.in
index 30aa525..95811a5 100644
--- a/WebCore/WebCore.exp.in
+++ b/WebCore/WebCore.exp.in
@@ -680,10 +680,10 @@ __ZN7WebCore6Editor21isSelectionMisspelledEv
 __ZN7WebCore6Editor23setBaseWritingDirectionENS_16WritingDirectionE
 __ZN7WebCore6Editor24advanceToNextMisspellingEb
 __ZN7WebCore6Editor24computeAndSetTypingStyleEPNS_19CSSStyleDeclarationENS_10EditActionE
-__ZN7WebCore6Editor24handleRejectedCorrectionEv
 __ZN7WebCore6Editor24isSelectionUngrammaticalEv
 __ZN7WebCore6Editor26decreaseSelectionListLevelEv
 __ZN7WebCore6Editor26increaseSelectionListLevelEv
+__ZN7WebCore6Editor27handleCorrectionPanelResultERKN3WTF6StringE
 __ZN7WebCore6Editor29canDecreaseSelectionListLevelEv
 __ZN7WebCore6Editor29canIncreaseSelectionListLevelEv
 __ZN7WebCore6Editor30applyParagraphStyleToSelectionEPNS_19CSSStyleDeclarationENS_10EditActionE
diff --git a/WebCore/editing/CorrectionPanelInfo.h b/WebCore/editing/CorrectionPanelInfo.h
index 2caac17..edc2bf7 100644
--- a/WebCore/editing/CorrectionPanelInfo.h
+++ b/WebCore/editing/CorrectionPanelInfo.h
@@ -44,7 +44,8 @@ namespace WebCore {
 struct CorrectionPanelInfo {
     enum PanelType {
         PanelTypeCorrection = 0,
-        PanelTypeReversion
+        PanelTypeReversion,
+        PanelTypeSpellingSuggestions
     };
 
     RefPtr<Range> m_rangeToBeReplaced;
diff --git a/WebCore/editing/Editor.cpp b/WebCore/editing/Editor.cpp
index 3a43f33..8c85363 100644
--- a/WebCore/editing/Editor.cpp
+++ b/WebCore/editing/Editor.cpp
@@ -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);
     }
 }
diff --git a/WebCore/editing/Editor.h b/WebCore/editing/Editor.h
index 99c1c58..abba4f4 100644
--- a/WebCore/editing/Editor.h
+++ b/WebCore/editing/Editor.h
@@ -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)
diff --git a/WebCore/editing/TextCheckingHelper.cpp b/WebCore/editing/TextCheckingHelper.cpp
index d524cf3..2241b85 100644
--- a/WebCore/editing/TextCheckingHelper.cpp
+++ b/WebCore/editing/TextCheckingHelper.cpp
@@ -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;
diff --git a/WebCore/editing/TextCheckingHelper.h b/WebCore/editing/TextCheckingHelper.h
index 4dced05..227530f 100644
--- a/WebCore/editing/TextCheckingHelper.h
+++ b/WebCore/editing/TextCheckingHelper.h
@@ -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;
 
diff --git a/WebCore/loader/EmptyClients.h b/WebCore/loader/EmptyClients.h
index a15cee5..a29379d 100644
--- a/WebCore/loader/EmptyClients.h
+++ b/WebCore/loader/EmptyClients.h
@@ -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) { }
 
diff --git a/WebCore/manual-tests/autocorrection/dismiss-multiple-guesses.html b/WebCore/manual-tests/autocorrection/dismiss-multiple-guesses.html
new file mode 100644
index 0000000..56724f1
--- /dev/null
+++ b/WebCore/manual-tests/autocorrection/dismiss-multiple-guesses.html
@@ -0,0 +1,49 @@
+<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');
+    typeCharacterCommand('h');
+    typeCharacterCommand('e');
+    typeCharacterCommand(' ');
+    typeCharacterCommand('m');
+    typeCharacterCommand('e');
+    typeCharacterCommand('s');
+    typeCharacterCommand('a');
+    typeCharacterCommand('e');
+    typeCharacterCommand('g');
+    typeCharacterCommand('e');
+    typeCharacterCommand('e');
+    typeCharacterCommand(' ');
+    execMoveSelectionBackwardByCharacterCommand();
+}
+
+</script>
+
+<title>Dismiss Multiple Guesses Test</title>
+</head>
+<body>
+<div><p>This test verifies that pressing ESC key diusmisses multiple guesses panel correctly</p>
+<p>After seeing the panel with multiple candidates, pressing ESC key to dismiss the panel.</p>
+<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, then kill AppleSpell.service process.</p>
+<div contenteditable id="root" class="editing">
+<span id="test"></span>
+</div>
+
+
+<script>
+runEditingTest();
+</script>
+
+</body>
+</html>
diff --git a/WebCore/manual-tests/autocorrection/select-from-multiple-guesses.html b/WebCore/manual-tests/autocorrection/select-from-multiple-guesses.html
new file mode 100644
index 0000000..dc8881f
--- /dev/null
+++ b/WebCore/manual-tests/autocorrection/select-from-multiple-guesses.html
@@ -0,0 +1,49 @@
+<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');
+    typeCharacterCommand('h');
+    typeCharacterCommand('e');
+    typeCharacterCommand(' ');
+    typeCharacterCommand('m');
+    typeCharacterCommand('e');
+    typeCharacterCommand('s');
+    typeCharacterCommand('a');
+    typeCharacterCommand('e');
+    typeCharacterCommand('g');
+    typeCharacterCommand('e');
+    typeCharacterCommand('e');
+    typeCharacterCommand(' ');
+    execMoveSelectionBackwardByCharacterCommand();
+}
+
+</script>
+
+<title>Select From Multiple Guesses Test</title>
+</head>
+<body>
+<div><p>This test verifies that multiple guesses on mispelled word is working correctly</p>
+<p>After seeing the panel with multiple candidates, use left and/or right arrow key to select the desired candidate, and then use return key to confirm. You can also use this test to test that pressing ESC key will dismiss the panel.</p>
+<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, then kill AppleSpell.service process.</p>
+<div contenteditable id="root" class="editing">
+<span id="test"></span>
+</div>
+
+
+<script>
+runEditingTest();
+</script>
+
+</body>
+</html>
diff --git a/WebCore/page/EditorClient.h b/WebCore/page/EditorClient.h
index 61bdd41..ba9ceee 100644
--- a/WebCore/page/EditorClient.h
+++ b/WebCore/page/EditorClient.h
@@ -190,7 +190,7 @@ public:
 #endif
 
 #if SUPPORT_AUTOCORRECTION_PANEL
-    virtual void showCorrectionPanel(CorrectionPanelInfo::PanelType, const FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacmentString, Editor*) = 0;
+    virtual void showCorrectionPanel(CorrectionPanelInfo::PanelType, const FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacmentString, const Vector<String>& alternativeReplacementStrings, Editor*) = 0;
     virtual void dismissCorrectionPanel(CorrectionWasRejectedOrNot) = 0;
     virtual bool isShowingCorrectionPanel() = 0;
 #endif
@@ -199,7 +199,8 @@ public:
     virtual void updateSpellingUIWithMisspelledWord(const String&) = 0;
     virtual void showSpellingUI(bool show) = 0;
     virtual bool spellingUIIsShowing() = 0;
-    virtual void getGuessesForWord(const String&, Vector<String>& guesses) = 0;
+    // For spellcheckers that support multiple languages, it's often important to be able to identify the language in order to provide more accurate correction suggestions. Caller can pass in more text in "context" to aid such spellcheckers on language identification. Noramlly it's the text surrounding the "word" for which we are getting correction suggestions.
+    virtual void getGuessesForWord(const String& word, const String& context, Vector<String>& guesses) = 0;
     virtual void willSetInputMethodState() = 0;
     virtual void setInputMethodState(bool enabled) = 0;
 };
diff --git a/WebKit/chromium/ChangeLog b/WebKit/chromium/ChangeLog
index fc4a2aa..bbcdcbd 100644
--- a/WebKit/chromium/ChangeLog
+++ b/WebKit/chromium/ChangeLog
@@ -1,3 +1,17 @@
+2010-12-01  Jia Pu  <jpu at 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  Alexey Marinichev  <amarinichev at chromium.org>
 
         Reviewed by James Robinson.
diff --git a/WebKit/chromium/src/EditorClientImpl.cpp b/WebKit/chromium/src/EditorClientImpl.cpp
index bc1d206..6f1739f 100644
--- a/WebKit/chromium/src/EditorClientImpl.cpp
+++ b/WebKit/chromium/src/EditorClientImpl.cpp
@@ -929,7 +929,8 @@ bool EditorClientImpl::spellingUIIsShowing()
     return false;
 }
 
-void EditorClientImpl::getGuessesForWord(const String&,
+void EditorClientImpl::getGuessesForWord(const String& word,
+                                         const String& context,
                                          WTF::Vector<String>& guesses)
 {
     notImplemented();
diff --git a/WebKit/chromium/src/EditorClientImpl.h b/WebKit/chromium/src/EditorClientImpl.h
index b05a592..a194399 100644
--- a/WebKit/chromium/src/EditorClientImpl.h
+++ b/WebKit/chromium/src/EditorClientImpl.h
@@ -107,6 +107,7 @@ public:
     virtual void showSpellingUI(bool show);
     virtual bool spellingUIIsShowing();
     virtual void getGuessesForWord(const WTF::String& word,
+                                   const WTF::String& context,
                                    WTF::Vector<WTF::String>& guesses);
     virtual void willSetInputMethodState();
     virtual void setInputMethodState(bool enabled);
diff --git a/WebKit/efl/ChangeLog b/WebKit/efl/ChangeLog
index 7a12fd7..8b21f5e 100644
--- a/WebKit/efl/ChangeLog
+++ b/WebKit/efl/ChangeLog
@@ -1,3 +1,17 @@
+2010-12-01  Jia Pu  <jpu at 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-11-22  Alex Grilo  <abgrilo at profusion.mobi>
 
         Reviewed by Kenneth Rohde Christiansen.
diff --git a/WebKit/efl/WebCoreSupport/EditorClientEfl.cpp b/WebKit/efl/WebCoreSupport/EditorClientEfl.cpp
index 9184812..6bb961b 100644
--- a/WebKit/efl/WebCoreSupport/EditorClientEfl.cpp
+++ b/WebKit/efl/WebCoreSupport/EditorClientEfl.cpp
@@ -488,7 +488,7 @@ bool EditorClientEfl::spellingUIIsShowing()
     return false;
 }
 
-void EditorClientEfl::getGuessesForWord(const String&, Vector<String>&)
+void EditorClientEfl::getGuessesForWord(const String& word, const String& context, Vector<String>& guesses)
 {
     notImplemented();
 }
diff --git a/WebKit/efl/WebCoreSupport/EditorClientEfl.h b/WebKit/efl/WebCoreSupport/EditorClientEfl.h
index 9f60cfb..b108ab6 100644
--- a/WebKit/efl/WebCoreSupport/EditorClientEfl.h
+++ b/WebKit/efl/WebCoreSupport/EditorClientEfl.h
@@ -110,7 +110,7 @@ public:
     virtual void updateSpellingUIWithMisspelledWord(const String&);
     virtual void showSpellingUI(bool show);
     virtual bool spellingUIIsShowing();
-    virtual void getGuessesForWord(const String&, WTF::Vector<String>& guesses);
+    virtual void getGuessesForWord(const String& word, const String& context, WTF::Vector<String>& guesses);
     virtual void willSetInputMethodState();
     virtual void setInputMethodState(bool enabled);
 
diff --git a/WebKit/gtk/ChangeLog b/WebKit/gtk/ChangeLog
index ade99ea..d455df9 100644
--- a/WebKit/gtk/ChangeLog
+++ b/WebKit/gtk/ChangeLog
@@ -1,3 +1,17 @@
+2010-12-01  Jia Pu  <jpu at 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-11-30  Nicolas Dufresne  <nicolas.dufresne at collabora.co.uk>
 
         Reviewed by Martin Robinson.
diff --git a/WebKit/gtk/WebCoreSupport/EditorClientGtk.cpp b/WebKit/gtk/WebCoreSupport/EditorClientGtk.cpp
index bd88480..da07e56 100644
--- a/WebKit/gtk/WebCoreSupport/EditorClientGtk.cpp
+++ b/WebKit/gtk/WebCoreSupport/EditorClientGtk.cpp
@@ -1008,7 +1008,7 @@ bool EditorClient::spellingUIIsShowing()
     return false;
 }
 
-void EditorClient::getGuessesForWord(const String& word, WTF::Vector<String>& guesses)
+void EditorClient::getGuessesForWord(const String& word, const String& context, WTF::Vector<String>& guesses)
 {
     GSList* dicts = webkit_web_settings_get_enchant_dicts(m_webView);
     guesses.clear();
diff --git a/WebKit/gtk/WebCoreSupport/EditorClientGtk.h b/WebKit/gtk/WebCoreSupport/EditorClientGtk.h
index f9ff82e..22543c6 100644
--- a/WebKit/gtk/WebCoreSupport/EditorClientGtk.h
+++ b/WebKit/gtk/WebCoreSupport/EditorClientGtk.h
@@ -129,7 +129,7 @@ namespace WebKit {
         virtual void updateSpellingUIWithMisspelledWord(const WTF::String&);
         virtual void showSpellingUI(bool show);
         virtual bool spellingUIIsShowing();
-        virtual void getGuessesForWord(const WTF::String&, WTF::Vector<WTF::String>& guesses);
+        virtual void getGuessesForWord(const WTF::String& word, const WTF::String& context, WTF::Vector<WTF::String>& guesses);
         virtual void willSetInputMethodState();
         virtual void setInputMethodState(bool enabled);
 
diff --git a/WebKit/haiku/ChangeLog b/WebKit/haiku/ChangeLog
index 723c957..65a83f9 100644
--- a/WebKit/haiku/ChangeLog
+++ b/WebKit/haiku/ChangeLog
@@ -1,3 +1,17 @@
+2010-12-01  Jia Pu  <jpu at 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-11-08  Alexey Proskuryakov  <ap at apple.com>
 
         Reviewed by Darin Adler.
diff --git a/WebKit/haiku/WebCoreSupport/EditorClientHaiku.cpp b/WebKit/haiku/WebCoreSupport/EditorClientHaiku.cpp
index bdd7eb8..deca47a 100644
--- a/WebKit/haiku/WebCoreSupport/EditorClientHaiku.cpp
+++ b/WebKit/haiku/WebCoreSupport/EditorClientHaiku.cpp
@@ -461,7 +461,7 @@ bool EditorClientHaiku::spellingUIIsShowing()
     return false;
 }
 
-void EditorClientHaiku::getGuessesForWord(const String&, Vector<String>&)
+void EditorClientHaiku::getGuessesForWord(const String& word, const String& context, Vector<String>& guesses)
 {
     notImplemented();
 }
diff --git a/WebKit/haiku/WebCoreSupport/EditorClientHaiku.h b/WebKit/haiku/WebCoreSupport/EditorClientHaiku.h
index 5cbec27..cfde51c 100644
--- a/WebKit/haiku/WebCoreSupport/EditorClientHaiku.h
+++ b/WebKit/haiku/WebCoreSupport/EditorClientHaiku.h
@@ -107,7 +107,7 @@ namespace WebCore {
         virtual void updateSpellingUIWithMisspelledWord(const String&);
         virtual void showSpellingUI(bool show);
         virtual bool spellingUIIsShowing();
-        virtual void getGuessesForWord(const String&, Vector<String>& guesses);
+        virtual void getGuessesForWord(const String& word, const String& context, Vector<String>& guesses);
         virtual void willSetInputMethodState();
         virtual void setInputMethodState(bool enabled);
 
diff --git a/WebKit/mac/ChangeLog b/WebKit/mac/ChangeLog
index 87a814a..76428a4 100644
--- a/WebKit/mac/ChangeLog
+++ b/WebKit/mac/ChangeLog
@@ -1,3 +1,21 @@
+2010-12-01  Jia Pu  <jpu at 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  David Hyatt  <hyatt at apple.com>
 
         Reviewed by Darin Adler.
diff --git a/WebKit/mac/WebCoreSupport/WebEditorClient.h b/WebKit/mac/WebCoreSupport/WebEditorClient.h
index 23cf312..a7ffe3a 100644
--- a/WebKit/mac/WebCoreSupport/WebEditorClient.h
+++ b/WebKit/mac/WebCoreSupport/WebEditorClient.h
@@ -129,11 +129,11 @@ public:
     virtual void updateSpellingUIWithMisspelledWord(const WTF::String&);
     virtual void showSpellingUI(bool show);
     virtual bool spellingUIIsShowing();
-    virtual void getGuessesForWord(const WTF::String&, WTF::Vector<WTF::String>& guesses);
+    virtual void getGuessesForWord(const WTF::String& word, const WTF::String& context, WTF::Vector<WTF::String>& guesses);
     virtual void willSetInputMethodState();
     virtual void setInputMethodState(bool enabled);
 #if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
-    virtual void showCorrectionPanel(WebCore::CorrectionPanelInfo::PanelType, const WebCore::FloatRect& boundingBoxOfReplacedString, const WTF::String& replacedString, const WTF::String& replacementString, WebCore::Editor*);
+    virtual void showCorrectionPanel(WebCore::CorrectionPanelInfo::PanelType, const WebCore::FloatRect& boundingBoxOfReplacedString, const WTF::String& replacedString, const WTF::String& replacementString, const WTF::Vector<WTF::String>& alternativeReplacementStrings, WebCore::Editor*);
     virtual void dismissCorrectionPanel(WebCore::CorrectionWasRejectedOrNot);
     virtual bool isShowingCorrectionPanel();
 #endif
diff --git a/WebKit/mac/WebCoreSupport/WebEditorClient.mm b/WebKit/mac/WebCoreSupport/WebEditorClient.mm
index 9efa766..0376122 100644
--- a/WebKit/mac/WebCoreSupport/WebEditorClient.mm
+++ b/WebKit/mac/WebCoreSupport/WebEditorClient.mm
@@ -77,6 +77,22 @@ using namespace WTF;
 
 using namespace HTMLNames;
 
+#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
+static inline NSCorrectionBubbleType correctionBubbleType(CorrectionPanelInfo::PanelType panelType)
+{
+    switch (panelType) {
+    case CorrectionPanelInfo::PanelTypeCorrection:
+        return NSCorrectionBubbleTypeCorrection;
+    case CorrectionPanelInfo::PanelTypeReversion:
+        return NSCorrectionBubbleTypeReversion;
+    case CorrectionPanelInfo::PanelTypeSpellingSuggestions:
+        return NSCorrectionBubbleTypeGuesses;
+    }
+    ASSERT_NOT_REACHED();
+    return NSCorrectionBubbleTypeCorrection;
+}
+#endif
+
 @interface NSAttributedString (WebNSAttributedStringDetails)
 - (id)_initWithDOMRange:(DOMRange*)range;
 - (DOMDocumentFragment*)_documentFromRange:(NSRange)range document:(DOMDocument*)document documentAttributes:(NSDictionary *)dict subresources:(NSArray **)subresources;
@@ -856,7 +872,7 @@ void WebEditorClient::updateSpellingUIWithGrammarString(const String& badGrammar
 }
 
 #if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
-void WebEditorClient::showCorrectionPanel(WebCore::CorrectionPanelInfo::PanelType panelType, const FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacementString, Editor* editor) {
+void WebEditorClient::showCorrectionPanel(WebCore::CorrectionPanelInfo::PanelType panelType, const FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacementString, const Vector<String>& alternativeReplacementStrings, Editor* editor) {
     dismissCorrectionPanel(WebCore::CorrectionWasNotRejected);
 
     NSRect boundingBoxAsNSRect = boundingBoxOfReplacedString;
@@ -868,14 +884,34 @@ void WebEditorClient::showCorrectionPanel(WebCore::CorrectionPanelInfo::PanelTyp
     NSString *replacementStringAsNSString = replacementString;
 
     m_correctionPanelIsShown = YES;
-    NSCorrectionBubbleType bubbleType = panelType == WebCore::CorrectionPanelInfo::PanelTypeCorrection ? NSCorrectionBubbleTypeCorrection : NSCorrectionBubbleTypeReversion;
-    [[NSSpellChecker sharedSpellChecker] showCorrectionBubbleOfType:bubbleType primaryString:replacementStringAsNSString alternativeStrings:nil forStringInRect:boundingBoxAsNSRect view:m_webView completionHandler:^(NSString *acceptedString) {
-        if (!acceptedString && bubbleType == NSCorrectionBubbleTypeCorrection) {
-            [[NSSpellChecker sharedSpellChecker] recordResponse:NSCorrectionResponseRejected toCorrection:replacementStringAsNSString forWord:replacedStringAsNSString language:nil inSpellDocumentWithTag:[m_webView spellCheckerDocumentTag]];
-            editor->handleRejectedCorrection();
-        } else if (acceptedString && bubbleType == NSCorrectionBubbleTypeReversion) {
-            [[NSSpellChecker sharedSpellChecker] recordResponse:NSCorrectionResponseReverted toCorrection:replacedStringAsNSString forWord:replacementStringAsNSString language:nil inSpellDocumentWithTag:[m_webView spellCheckerDocumentTag]];
-            editor->handleRejectedCorrection();
+    NSCorrectionBubbleType bubbleType = correctionBubbleType(panelType);
+    NSMutableArray *alternativeStrings = nil;
+    if (!alternativeReplacementStrings.isEmpty()) {
+        size_t size = alternativeReplacementStrings.size();
+        alternativeStrings = [NSMutableArray arrayWithCapacity:size];
+        for (size_t i = 0; i < size; ++i)
+            [alternativeStrings addObject:(NSString*)alternativeReplacementStrings[i]];
+    }
+
+    [[NSSpellChecker sharedSpellChecker] showCorrectionBubbleOfType:bubbleType primaryString:replacementStringAsNSString alternativeStrings:alternativeStrings forStringInRect:boundingBoxAsNSRect view:m_webView completionHandler:^(NSString *acceptedString) {
+        switch (bubbleType) {
+        case NSCorrectionBubbleTypeCorrection:
+            if (!acceptedString) {
+                [[NSSpellChecker sharedSpellChecker] recordResponse:NSCorrectionResponseRejected toCorrection:replacementStringAsNSString forWord:replacedStringAsNSString language:nil inSpellDocumentWithTag:[m_webView spellCheckerDocumentTag]];
+                editor->handleCorrectionPanelResult(String());
+            }
+            break;
+        case NSCorrectionBubbleTypeReversion:
+            if (acceptedString) {
+                [[NSSpellChecker sharedSpellChecker] recordResponse:NSCorrectionResponseReverted toCorrection:replacedStringAsNSString forWord:replacementStringAsNSString language:nil inSpellDocumentWithTag:[m_webView spellCheckerDocumentTag]];
+                editor->handleCorrectionPanelResult(String());
+            }
+            break;
+        case NSCorrectionBubbleTypeGuesses:
+            if (acceptedString)
+                [[NSSpellChecker sharedSpellChecker] recordResponse:NSCorrectionResponseAccepted toCorrection:acceptedString forWord:replacedStringAsNSString language:nil inSpellDocumentWithTag:[m_webView spellCheckerDocumentTag]];
+            editor->handleCorrectionPanelResult(String(acceptedString));
+            break;
         }
     }];
 }
@@ -916,11 +952,22 @@ bool WebEditorClient::spellingUIIsShowing()
     return [[[NSSpellChecker sharedSpellChecker] spellingPanel] isVisible];
 }
 
-void WebEditorClient::getGuessesForWord(const String& word, WTF::Vector<String>& guesses)
-{
+void WebEditorClient::getGuessesForWord(const String& word, const String& context, Vector<String>& guesses) {
+    guesses.clear();
+#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
+    NSString* language = nil;
+    NSOrthography* orthography = nil;
+    NSSpellChecker *checker = [NSSpellChecker sharedSpellChecker];
+    if (context.length()) {
+        [checker checkString:context range:NSMakeRange(0, context.length()) types:NSTextCheckingTypeOrthography options:0 inSpellDocumentWithTag:spellCheckerDocumentTag() orthography:&orthography wordCount:0];
+        language = [checker languageForWordRange:NSMakeRange(0, context.length()) inString:context orthography:orthography];
+    }
+    NSArray* stringsArray = [checker guessesForWordRange:NSMakeRange(0, word.length()) inString:word language:language inSpellDocumentWithTag:spellCheckerDocumentTag()];
+#else
     NSArray* stringsArray = [[NSSpellChecker sharedSpellChecker] guessesForWord:word];
+#endif
     unsigned count = [stringsArray count];
-    guesses.clear();
+
     if (count > 0) {
         NSEnumerator* enumerator = [stringsArray objectEnumerator];
         NSString* string;
diff --git a/WebKit/qt/ChangeLog b/WebKit/qt/ChangeLog
index 892dd16..d361624 100644
--- a/WebKit/qt/ChangeLog
+++ b/WebKit/qt/ChangeLog
@@ -1,3 +1,17 @@
+2010-12-01  Jia Pu  <jpu at 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-11-30  Benjamin Poulain  <benjamin.poulain at nokia.com>
 
         Reviewed by Kenneth Rohde Christiansen.
diff --git a/WebKit/qt/WebCoreSupport/EditorClientQt.cpp b/WebKit/qt/WebCoreSupport/EditorClientQt.cpp
index 91a0cc6..46eeeb0 100644
--- a/WebKit/qt/WebCoreSupport/EditorClientQt.cpp
+++ b/WebKit/qt/WebCoreSupport/EditorClientQt.cpp
@@ -558,7 +558,7 @@ bool EditorClientQt::spellingUIIsShowing()
     return false;
 }
 
-void EditorClientQt::getGuessesForWord(const String&, Vector<String>&)
+void EditorClientQt::getGuessesForWord(const String& word, const String& context, Vector<String>& guesses)
 {
     notImplemented();
 }
diff --git a/WebKit/qt/WebCoreSupport/EditorClientQt.h b/WebKit/qt/WebCoreSupport/EditorClientQt.h
index 7d99d22..defa8bb 100644
--- a/WebKit/qt/WebCoreSupport/EditorClientQt.h
+++ b/WebKit/qt/WebCoreSupport/EditorClientQt.h
@@ -104,7 +104,7 @@ public:
     virtual void updateSpellingUIWithMisspelledWord(const String&);
     virtual void showSpellingUI(bool show);
     virtual bool spellingUIIsShowing();
-    virtual void getGuessesForWord(const String&, Vector<String>& guesses);
+    virtual void getGuessesForWord(const String& word, const String& context, Vector<String>& guesses);
     virtual void willSetInputMethodState();
     virtual void setInputMethodState(bool enabled);
 
diff --git a/WebKit/win/ChangeLog b/WebKit/win/ChangeLog
index 1d1de36..ed946c8 100644
--- a/WebKit/win/ChangeLog
+++ b/WebKit/win/ChangeLog
@@ -1,3 +1,17 @@
+2010-12-01  Jia Pu  <jpu at 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  Steve Falkenburg  <sfalken at apple.com>
 
         Reviewed by Adam Roben.
diff --git a/WebKit/win/WebCoreSupport/WebEditorClient.cpp b/WebKit/win/WebCoreSupport/WebEditorClient.cpp
index f03ffd6..539259b 100644
--- a/WebKit/win/WebCoreSupport/WebEditorClient.cpp
+++ b/WebKit/win/WebCoreSupport/WebEditorClient.cpp
@@ -758,7 +758,7 @@ bool WebEditorClient::spellingUIIsShowing()
     return !!showing;
 }
 
-void WebEditorClient::getGuessesForWord(const String& word, Vector<String>& guesses)
+void WebEditorClient::getGuessesForWord(const String& word, const String& context, Vector<String>& guesses)
 {
     guesses.clear();
 
diff --git a/WebKit/win/WebCoreSupport/WebEditorClient.h b/WebKit/win/WebCoreSupport/WebEditorClient.h
index 8be6de9..f0b78ba 100644
--- a/WebKit/win/WebCoreSupport/WebEditorClient.h
+++ b/WebKit/win/WebCoreSupport/WebEditorClient.h
@@ -107,7 +107,7 @@ public:
     virtual void updateSpellingUIWithMisspelledWord(const WTF::String&);
     virtual void showSpellingUI(bool show);
     virtual bool spellingUIIsShowing();
-    virtual void getGuessesForWord(const WTF::String&, Vector<WTF::String>& guesses);
+    virtual void getGuessesForWord(const WTF::String& word, const WTF::String& context, WTF::Vector<WTF::String>& guesses);
 
     virtual void willSetInputMethodState();
     virtual void setInputMethodState(bool);
diff --git a/WebKit/wince/ChangeLog b/WebKit/wince/ChangeLog
index 5ef55fa..d32059d 100644
--- a/WebKit/wince/ChangeLog
+++ b/WebKit/wince/ChangeLog
@@ -1,3 +1,17 @@
+2010-12-01  Jia Pu  <jpu at 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-11-30  Patrick Gansterer  <paroga at webkit.org>
 
         Reviewed by Adam Roben.
diff --git a/WebKit/wince/WebCoreSupport/EditorClientWinCE.cpp b/WebKit/wince/WebCoreSupport/EditorClientWinCE.cpp
index 7dee562..c4555ed 100644
--- a/WebKit/wince/WebCoreSupport/EditorClientWinCE.cpp
+++ b/WebKit/wince/WebCoreSupport/EditorClientWinCE.cpp
@@ -487,7 +487,7 @@ bool EditorClientWinCE::spellingUIIsShowing()
     return false;
 }
 
-void EditorClientWinCE::getGuessesForWord(const String& word, WTF::Vector<String>& guesses)
+void EditorClientWinCE::getGuessesForWord(const String& word, const String& context, WTF::Vector<String>& guesses)
 {
     notImplemented();
 }
diff --git a/WebKit/wince/WebCoreSupport/EditorClientWinCE.h b/WebKit/wince/WebCoreSupport/EditorClientWinCE.h
index be85b3f..fd3dd10 100644
--- a/WebKit/wince/WebCoreSupport/EditorClientWinCE.h
+++ b/WebKit/wince/WebCoreSupport/EditorClientWinCE.h
@@ -97,7 +97,7 @@ public:
     virtual void updateSpellingUIWithMisspelledWord(const WTF::String&);
     virtual void showSpellingUI(bool);
     virtual bool spellingUIIsShowing();
-    virtual void getGuessesForWord(const WTF::String&, WTF::Vector<WTF::String>&);
+    virtual void getGuessesForWord(const WTF::String& word, const WTF::String& context, WTF::Vector<WTF::String>& guesses);
     virtual void willSetInputMethodState();
     virtual void setInputMethodState(bool);
 
diff --git a/WebKit/wx/ChangeLog b/WebKit/wx/ChangeLog
index 2b55577..ee07fbd 100644
--- a/WebKit/wx/ChangeLog
+++ b/WebKit/wx/ChangeLog
@@ -1,3 +1,17 @@
+2010-12-01  Jia Pu  <jpu at 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-11-24  Patrick Gansterer  <paroga at webkit.org>
 
         Reviewed by Csaba Osztrogonác.
diff --git a/WebKit/wx/WebKitSupport/EditorClientWx.cpp b/WebKit/wx/WebKitSupport/EditorClientWx.cpp
index 59e2fd4..5601364 100644
--- a/WebKit/wx/WebKitSupport/EditorClientWx.cpp
+++ b/WebKit/wx/WebKitSupport/EditorClientWx.cpp
@@ -542,9 +542,9 @@ bool EditorClientWx::spellingUIIsShowing()
     return false;
 }
 
-void EditorClientWx::getGuessesForWord(const String&, Vector<String>& guesses) 
-{ 
-    notImplemented(); 
+void EditorClientWx::getGuessesForWord(const String& word, const String& context, Vector<String>& guesses)
+{
+    notImplemented();
 }
 
 String EditorClientWx::getAutoCorrectSuggestionForMisspelledWord(const WTF::String&)
diff --git a/WebKit/wx/WebKitSupport/EditorClientWx.h b/WebKit/wx/WebKitSupport/EditorClientWx.h
index be5c98a..35a95ab 100644
--- a/WebKit/wx/WebKitSupport/EditorClientWx.h
+++ b/WebKit/wx/WebKitSupport/EditorClientWx.h
@@ -107,9 +107,9 @@ public:
     virtual void updateSpellingUIWithMisspelledWord(const String&);
     virtual void showSpellingUI(bool show);
     virtual bool spellingUIIsShowing();
-    virtual void getGuessesForWord(const String&, Vector<String>& guesses);
+    virtual void getGuessesForWord(const String& word, const String& context, Vector<String>& guesses);
     virtual String getAutoCorrectSuggestionForMisspelledWord(const WTF::String&);
-    
+
     virtual void willSetInputMethodState();
     virtual void setInputMethodState(bool enabled);
 
diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index 960ea9f..ad60ab3 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -1,3 +1,19 @@
+2010-12-01  Jia Pu  <jpu at 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):
+
 2010-12-01  Simon Fraser  <simon.fraser at apple.com>
 
         Reviewed by John Sullivan.
diff --git a/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp b/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp
index 13595b0..f83fc90 100644
--- a/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp
+++ b/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp
@@ -393,7 +393,7 @@ bool WebEditorClient::spellingUIIsShowing()
     return false;
 }
 
-void WebEditorClient::getGuessesForWord(const String&, Vector<String>&)
+void WebEditorClient::getGuessesForWord(const String&, const String&, Vector<String>&)
 {
     notImplemented();
 }
diff --git a/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h b/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h
index 62a5ed2..9ff2a62 100644
--- a/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h
+++ b/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h
@@ -130,11 +130,11 @@ private:
     virtual void updateSpellingUIWithMisspelledWord(const String&);
     virtual void showSpellingUI(bool show);
     virtual bool spellingUIIsShowing();
-    virtual void getGuessesForWord(const String&, Vector<String>& guesses);
+    virtual void getGuessesForWord(const String& word, const String& context, Vector<String>& guesses);
     virtual void willSetInputMethodState();
     virtual void setInputMethodState(bool enabled);
 #if PLATFORM(MAC) && !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
-    virtual void showCorrectionPanel(WebCore::CorrectionPanelInfo::PanelType, const WebCore::FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacementString, WebCore::Editor*);
+    virtual void showCorrectionPanel(WebCore::CorrectionPanelInfo::PanelType, const WebCore::FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacementString, const Vector<String>& alternativeReplacementStrings, WebCore::Editor*);
     virtual void dismissCorrectionPanel(WebCore::CorrectionWasRejectedOrNot);
     virtual bool isShowingCorrectionPanel();
 #endif
diff --git a/WebKit2/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm b/WebKit2/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm
index badc301..c94f4d7 100644
--- a/WebKit2/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm
+++ b/WebKit2/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm
@@ -223,7 +223,7 @@ void WebEditorClient::checkTextOfParagraph(const UChar *, int length, uint64_t,
 #endif
 
 #if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
-void WebEditorClient::showCorrectionPanel(WebCore::CorrectionPanelInfo::PanelType type, const WebCore::FloatRect& boundingBoxOfReplacedString, const WTF::String& replacedString, const WTF::String& replacementString, WebCore::Editor*)
+void WebEditorClient::showCorrectionPanel(WebCore::CorrectionPanelInfo::PanelType type, const WebCore::FloatRect& boundingBoxOfReplacedString, const WTF::String& replacedString, const WTF::String& replacementString, const Vector<String>& alternativeReplacementStrings, WebCore::Editor*)
 {
     notImplemented();
 }

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list