Commit a2f77992 authored by jpu@apple.com's avatar jpu@apple.com

2011-05-12 Jia Pu <jpu@apple.com>

        Reviewed by Darin Adler.

        Regression caused by changeset 86281
        https://bugs.webkit.org/show_bug.cgi?id=60712

        Changed wording in some tests to reflect AppKit UI change.

        * manual-tests/autocorrection/delete-to-end-of-word-to-show-reversion.html:
        * manual-tests/autocorrection/move-to-end-of-word-to-show-reversion.html:
2011-05-12  Jia Pu  <jpu@apple.com>

        Reviewed by Darin Adler.

        Regression caused by changeset 86281
        https://bugs.webkit.org/show_bug.cgi?id=60712
        <rdar://problem/9427970>

        Removed the condition variable. [NSSpellChecker dismissCorrectionIndicatorForView:] is blocking.
        So handleAcceptedReplacement() triggered by dismissInternal() will return before dismissInternal()
        returns. So we don't need to use the condition to coordinate between these two function. In fact,
        all callbacks are delivered on main thread. We don't really need any locking here.

        Since now we don't have distinction between dismiss() and dismissSoon(). dismissSoon() has
        been removed.

        * WebCoreSupport/CorrectionPanel.h:
        * WebCoreSupport/CorrectionPanel.mm:
        (CorrectionPanel::CorrectionPanel):
        (CorrectionPanel::show):
        (CorrectionPanel::dismiss):
        (CorrectionPanel::dismissInternal):
        (CorrectionPanel::handleAcceptedReplacement):
        * WebCoreSupport/WebEditorClient.mm:
        (WebEditorClient::dismissCorrectionPanelSoon):
2011-05-12  Jia Pu  <jpu@apple.com>

        Reviewed by Darin Adler.

        Regression caused by changeset 86281
        https://bugs.webkit.org/show_bug.cgi?id=60712
        <rdar://problem/9427970>

        Removed the condition variable. [NSSpellChecker dismissCorrectionIndicatorForView:] is blocking.
        So handleAcceptedReplacement() triggered by dismissInternal() will return before dismissInternal()
        returns. So we don't need to use the condition to coordinate between these two function. In fact,
        all callbacks are delivered on main thread. We don't really need any locking here.

        Since now we don't have distinction between dismiss() and dismissSoon(). dismissSoon() has
        been removed.

        * UIProcess/API/mac/PageClientImpl.mm:
        (WebKit::PageClientImpl::dismissCorrectionPanelSoon):
        * UIProcess/mac/CorrectionPanel.h:
        * UIProcess/mac/CorrectionPanel.mm:
        (WebKit::CorrectionPanel::CorrectionPanel):
        (WebKit::CorrectionPanel::show):
        (WebKit::CorrectionPanel::dismiss):
        (WebKit::CorrectionPanel::dismissInternal):
        (WebKit::CorrectionPanel::handleAcceptedReplacement):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@86406 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 6245322a
2011-05-12 Jia Pu <jpu@apple.com>
Reviewed by Darin Adler.
Regression caused by changeset 86281
https://bugs.webkit.org/show_bug.cgi?id=60712
Changed wording in some tests to reflect AppKit UI change.
* manual-tests/autocorrection/delete-to-end-of-word-to-show-reversion.html:
* manual-tests/autocorrection/move-to-end-of-word-to-show-reversion.html:
2011-05-12 Daniel Bates <dbates@rim.com>
Attempt to fix the build after changeset 86391 <http://trac.webkit.org/changeset/86391>
......@@ -32,7 +32,7 @@ function editingTest() {
</head>
<body>
<div><p>This test verifies that reversion panel is shown when user moves carret to previously corrected word using delete key.</p>
<p>After seeing the reversion panel, press ESC key, then space key. You should see the phrase "the mesage". </p>
<p>After seeing the reversion panel, press down key followed by return key. You should see the phrase "the mesage". </p>
<p style="color:green">Note, this test can fail due to user specific spell checking data. If the user has previously frequently revert 'message' to 'mesage'. 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>
......
......@@ -32,7 +32,7 @@ function editingTest() {
</head>
<body>
<div><p>This test verifies that reversion panel is shown when user moves carret to previously corrected word</p>
<p>After seeing the reversion panel, press ESC key, then space key. You should see the phrase "the mesage". </p>
<p>After seeing the reversion panel, press down key followed by return key. You should see the phrase "the mesage". </p>
<p style="color:green">Note, this test can fail due to user specific spell checking data. If the user has previously frequently revert 'message' to 'mesage'. 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>
......
2011-05-12 Jia Pu <jpu@apple.com>
Reviewed by Darin Adler.
Regression caused by changeset 86281
https://bugs.webkit.org/show_bug.cgi?id=60712
<rdar://problem/9427970>
Removed the condition variable. [NSSpellChecker dismissCorrectionIndicatorForView:] is blocking.
So handleAcceptedReplacement() triggered by dismissInternal() will return before dismissInternal()
returns. So we don't need to use the condition to coordinate between these two function. In fact,
all callbacks are delivered on main thread. We don't really need any locking here.
Since now we don't have distinction between dismiss() and dismissSoon(). dismissSoon() has
been removed.
* WebCoreSupport/CorrectionPanel.h:
* WebCoreSupport/CorrectionPanel.mm:
(CorrectionPanel::CorrectionPanel):
(CorrectionPanel::show):
(CorrectionPanel::dismiss):
(CorrectionPanel::dismissInternal):
(CorrectionPanel::handleAcceptedReplacement):
* WebCoreSupport/WebEditorClient.mm:
(WebEditorClient::dismissCorrectionPanelSoon):
2011-05-12 Patrick Gansterer <paroga@webkit.org>
Reviewed by Adam Barth.
......
......@@ -39,21 +39,18 @@ public:
CorrectionPanel();
~CorrectionPanel();
void show(WebView*, WebCore::CorrectionPanelInfo::PanelType, const WebCore::FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacementString, const Vector<String>& alternativeReplacementStrings);
void dismiss(WebCore::ReasonForDismissingCorrectionPanel);
String dismissSoon(WebCore::ReasonForDismissingCorrectionPanel);
String dismiss(WebCore::ReasonForDismissingCorrectionPanel);
static void recordAutocorrectionResponse(WebView*, NSCorrectionResponse, const String& replacedString, const String& replacementString);
private:
bool isShowing() const { return m_view; }
void dismissInternal(WebCore::ReasonForDismissingCorrectionPanel, bool dismissingExternally);
String dismissInternal(WebCore::ReasonForDismissingCorrectionPanel, bool dismissingExternally);
void handleAcceptedReplacement(NSString* acceptedReplacement, NSString* replaced, NSString* proposedReplacement, NSCorrectionIndicatorType);
bool m_wasDismissedExternally;
WebCore::ReasonForDismissingCorrectionPanel m_reasonForDismissing;
RetainPtr<WebView> m_view;
RetainPtr<NSString> m_resultForSynchronousDismissal;
RetainPtr<NSCondition> m_resultCondition;
bool m_isDismissing;
RetainPtr<NSString> m_resultForDismissal;
};
#endif // !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
......
......@@ -46,8 +46,6 @@ static inline NSCorrectionIndicatorType correctionIndicatorType(CorrectionPanelI
CorrectionPanel::CorrectionPanel()
: m_wasDismissedExternally(false)
, m_reasonForDismissing(ReasonForDismissingCorrectionPanelIgnored)
, m_resultCondition(AdoptNS, [[NSCondition alloc] init])
, m_isDismissing(false)
{
}
......@@ -79,35 +77,23 @@ void CorrectionPanel::show(WebView* view, CorrectionPanelInfo::PanelType type, c
[[NSSpellChecker sharedSpellChecker] showCorrectionIndicatorOfType:indicatorType primaryString:replacementStringAsNSString alternativeStrings:alternativeStrings forStringInRect:[view convertRect:boundingBoxOfReplacedString fromView:nil] view:m_view.get() completionHandler:^(NSString* acceptedString) {
handleAcceptedReplacement(acceptedString, replacedStringAsNSString, replacementStringAsNSString, indicatorType);
}];
m_isDismissing = false;
}
void CorrectionPanel::dismiss(ReasonForDismissingCorrectionPanel reason)
String CorrectionPanel::dismiss(ReasonForDismissingCorrectionPanel reason)
{
dismissInternal(reason, true);
return dismissInternal(reason, true);
}
String CorrectionPanel::dismissSoon(ReasonForDismissingCorrectionPanel reason)
{
dismissInternal(reason, true);
[m_resultCondition.get() lock];
while (m_isDismissing)
[m_resultCondition.get() wait];
[m_resultCondition.get() unlock];
return m_resultForSynchronousDismissal.get();
}
void CorrectionPanel::dismissInternal(ReasonForDismissingCorrectionPanel reason, bool dismissingExternally)
String CorrectionPanel::dismissInternal(ReasonForDismissingCorrectionPanel reason, bool dismissingExternally)
{
if (!isShowing())
return;
m_isDismissing = true;
return String();
m_wasDismissedExternally = dismissingExternally;
m_reasonForDismissing = reason;
m_resultForSynchronousDismissal.clear();
m_resultForDismissal.clear();
[[NSSpellChecker sharedSpellChecker] dismissCorrectionIndicatorForView:m_view.get()];
m_view.clear();
return m_resultForDismissal.get();
}
void CorrectionPanel::recordAutocorrectionResponse(WebView* view, NSCorrectionResponse response, const String& replacedString, const String& replacementString)
......@@ -116,7 +102,10 @@ void CorrectionPanel::recordAutocorrectionResponse(WebView* view, NSCorrectionRe
}
void CorrectionPanel::handleAcceptedReplacement(NSString* acceptedReplacement, NSString* replaced, NSString* proposedReplacement, NSCorrectionIndicatorType correctionIndicatorType)
{
{
if (!m_view)
return;
NSSpellChecker* spellChecker = [NSSpellChecker sharedSpellChecker];
NSInteger documentTag = [m_view.get() spellCheckerDocumentTag];
......@@ -141,15 +130,10 @@ void CorrectionPanel::handleAcceptedReplacement(NSString* acceptedReplacement, N
break;
}
if (!m_wasDismissedExternally)
[m_view.get() handleCorrectionPanelResult:acceptedReplacement];
[m_view.get() handleCorrectionPanelResult:acceptedReplacement];
m_view.clear();
if (acceptedReplacement)
m_resultForSynchronousDismissal.adoptNS([acceptedReplacement copy]);
[m_resultCondition.get() lock];
m_isDismissing = false;
[m_resultCondition.get() signal];
[m_resultCondition.get() unlock];
m_resultForDismissal.adoptNS([acceptedReplacement copy]);
}
#endif // !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
......
......@@ -875,7 +875,7 @@ void WebEditorClient::dismissCorrectionPanel(ReasonForDismissingCorrectionPanel
String WebEditorClient::dismissCorrectionPanelSoon(ReasonForDismissingCorrectionPanel reasonForDismissing)
{
return m_correctionPanel.dismissSoon(reasonForDismissing);
return m_correctionPanel.dismiss(reasonForDismissing);
}
void WebEditorClient::recordAutocorrectionResponse(EditorClient::AutocorrectionResponseType responseType, const String& replacedString, const String& replacementString)
......
2011-05-12 Jia Pu <jpu@apple.com>
Reviewed by Darin Adler.
Regression caused by changeset 86281
https://bugs.webkit.org/show_bug.cgi?id=60712
<rdar://problem/9427970>
Removed the condition variable. [NSSpellChecker dismissCorrectionIndicatorForView:] is blocking.
So handleAcceptedReplacement() triggered by dismissInternal() will return before dismissInternal()
returns. So we don't need to use the condition to coordinate between these two function. In fact,
all callbacks are delivered on main thread. We don't really need any locking here.
Since now we don't have distinction between dismiss() and dismissSoon(). dismissSoon() has
been removed.
* UIProcess/API/mac/PageClientImpl.mm:
(WebKit::PageClientImpl::dismissCorrectionPanelSoon):
* UIProcess/mac/CorrectionPanel.h:
* UIProcess/mac/CorrectionPanel.mm:
(WebKit::CorrectionPanel::CorrectionPanel):
(WebKit::CorrectionPanel::show):
(WebKit::CorrectionPanel::dismiss):
(WebKit::CorrectionPanel::dismissInternal):
(WebKit::CorrectionPanel::handleAcceptedReplacement):
2011-05-12 Brian Weinstein <bweinstein@apple.com>
Reviewed by Adam Roben.
......
......@@ -432,7 +432,7 @@ void PageClientImpl::dismissCorrectionPanel(ReasonForDismissingCorrectionPanel r
String PageClientImpl::dismissCorrectionPanelSoon(WebCore::ReasonForDismissingCorrectionPanel reason)
{
#if !defined(BUILDING_ON_SNOW_LEOPARD)
return m_correctionPanel.dismissSoon(reason);
return m_correctionPanel.dismiss(reason);
#else
return String();
#endif
......
......@@ -40,21 +40,18 @@ public:
CorrectionPanel();
~CorrectionPanel();
void show(WKView*, WebCore::CorrectionPanelInfo::PanelType, const WebCore::FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacementString, const Vector<String>& alternativeReplacementStrings);
void dismiss(WebCore::ReasonForDismissingCorrectionPanel);
String dismissSoon(WebCore::ReasonForDismissingCorrectionPanel);
String dismiss(WebCore::ReasonForDismissingCorrectionPanel);
static void recordAutocorrectionResponse(WKView*, NSCorrectionResponse, const String& replacedString, const String& replacementString);
private:
bool isShowing() const { return m_view; }
void dismissInternal(WebCore::ReasonForDismissingCorrectionPanel, bool dismissingExternally);
String dismissInternal(WebCore::ReasonForDismissingCorrectionPanel, bool dismissingExternally);
void handleAcceptedReplacement(NSString* acceptedReplacement, NSString* replaced, NSString* proposedReplacement, NSCorrectionIndicatorType);
bool m_wasDismissedExternally;
WebCore::ReasonForDismissingCorrectionPanel m_reasonForDismissing;
RetainPtr<WKView> m_view;
RetainPtr<NSString> m_resultForSynchronousDismissal;
RetainPtr<NSCondition> m_resultCondition;
bool m_isDismissing;
RetainPtr<NSString> m_resultForDismissal;
};
} // namespace WebKit
......
......@@ -52,8 +52,6 @@ namespace WebKit {
CorrectionPanel::CorrectionPanel()
: m_wasDismissedExternally(false)
, m_reasonForDismissing(ReasonForDismissingCorrectionPanelIgnored)
, m_resultCondition(AdoptNS, [[NSCondition alloc] init])
, m_isDismissing(false)
{
}
......@@ -86,35 +84,23 @@ void CorrectionPanel::show(WKView* view, CorrectionPanelInfo::PanelType type, co
[spellChecker showCorrectionIndicatorOfType:indicatorType primaryString:replacementStringAsNSString alternativeStrings:alternativeStrings forStringInRect:boundingBoxOfReplacedString view:m_view.get() completionHandler:^(NSString* acceptedString) {
handleAcceptedReplacement(acceptedString, replacedStringAsNSString, replacementStringAsNSString, indicatorType);
}];
m_isDismissing = false;
}
void CorrectionPanel::dismiss(ReasonForDismissingCorrectionPanel reason)
String CorrectionPanel::dismiss(ReasonForDismissingCorrectionPanel reason)
{
dismissInternal(reason, true);
return dismissInternal(reason, true);
}
String CorrectionPanel::dismissSoon(ReasonForDismissingCorrectionPanel reason)
{
dismissInternal(reason, true);
[m_resultCondition.get() lock];
while (m_isDismissing)
[m_resultCondition.get() wait];
[m_resultCondition.get() unlock];
return m_resultForSynchronousDismissal.get();
}
void CorrectionPanel::dismissInternal(ReasonForDismissingCorrectionPanel reason, bool dismissingExternally)
String CorrectionPanel::dismissInternal(ReasonForDismissingCorrectionPanel reason, bool dismissingExternally)
{
if (!isShowing())
return;
return String();
m_isDismissing = true;
m_wasDismissedExternally = dismissingExternally;
m_reasonForDismissing = reason;
m_resultForSynchronousDismissal.clear();
m_resultForDismissal.clear();
[[NSSpellChecker sharedSpellChecker] dismissCorrectionIndicatorForView:m_view.get()];
m_view.clear();
return m_resultForDismissal.get();
}
void CorrectionPanel::recordAutocorrectionResponse(WKView* view, NSCorrectionResponse response, const String& replacedString, const String& replacementString)
......@@ -124,6 +110,9 @@ void CorrectionPanel::recordAutocorrectionResponse(WKView* view, NSCorrectionRes
void CorrectionPanel::handleAcceptedReplacement(NSString* acceptedReplacement, NSString* replaced, NSString* proposedReplacement, NSCorrectionIndicatorType correctionIndicatorType)
{
if (!m_view)
return;
NSSpellChecker* spellChecker = [NSSpellChecker sharedSpellChecker];
NSInteger documentTag = [m_view.get() spellCheckerDocumentTag];
......@@ -147,16 +136,11 @@ void CorrectionPanel::handleAcceptedReplacement(NSString* acceptedReplacement, N
[spellChecker recordResponse:NSCorrectionResponseAccepted toCorrection:acceptedReplacement forWord:replaced language:nil inSpellDocumentWithTag:documentTag];
break;
}
if (!m_wasDismissedExternally)
[m_view.get() handleCorrectionPanelResult:acceptedReplacement];
[m_view.get() handleCorrectionPanelResult:acceptedReplacement];
m_view.clear();
if (acceptedReplacement)
m_resultForSynchronousDismissal.adoptNS([acceptedReplacement copy]);
[m_resultCondition.get() lock];
m_isDismissing = false;
[m_resultCondition.get() signal];
[m_resultCondition.get() unlock];
m_resultForDismissal.adoptNS([acceptedReplacement copy]);
}
} // namespace WebKit
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment