Commit ca72090a authored by jpu@apple.com's avatar jpu@apple.com
Browse files

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

        Reviewed by Darin Adler.

        CorrectionPanel sometimes hangs in dismissSoon().
        https://bugs.webkit.org/show_bug.cgi?id=60599
        <rdar://problem/9313628>

        Make sure dismissSoon() won't wait indefinitely if handleAcceptedReplacement() sets m_resultForSynchronousDismissal
        to nil. Added a designated variable m_isDismissing, instead of piggy-backing m_resultForSynchronousDismissal,
        for condition checking.

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

        Reviewed by Darin Adler.

        CorrectionPanel sometimes hangs in dismissSoon().
        https://bugs.webkit.org/show_bug.cgi?id=60599
        <rdar://problem/9313628>

        Make sure dismissSoon() won't wait indefinitely if handleAcceptedReplacement() sets m_resultForSynchronousDismissal
        to nil. Added a designated variable m_isDismissing, instead of piggy-backing m_resultForSynchronousDismissal,
        for condition checking.

        * UIProcess/mac/CorrectionPanel.h:
        * UIProcess/mac/CorrectionPanel.mm:
        (WebKit::CorrectionPanel::CorrectionPanel):
        (WebKit::CorrectionPanel::show):
        (WebKit::CorrectionPanel::dismissSoon):
        (WebKit::CorrectionPanel::dismissInternal):
        (WebKit::CorrectionPanel::handleAcceptedReplacement):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@86281 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 9e852f43
2011-05-11 Jia Pu <jpu@apple.com>
Reviewed by Darin Adler.
CorrectionPanel sometimes hangs in dismissSoon().
https://bugs.webkit.org/show_bug.cgi?id=60599
<rdar://problem/9313628>
Make sure dismissSoon() won't wait indefinitely if handleAcceptedReplacement() sets m_resultForSynchronousDismissal
to nil. Added a designated variable m_isDismissing, instead of piggy-backing m_resultForSynchronousDismissal,
for condition checking.
* WebCoreSupport/CorrectionPanel.h:
* WebCoreSupport/CorrectionPanel.mm:
(CorrectionPanel::CorrectionPanel):
(CorrectionPanel::show):
(CorrectionPanel::dismissSoon):
(CorrectionPanel::dismissInternal):
(CorrectionPanel::handleAcceptedReplacement):
2011-05-10 Anton D'Auria <adauria@apple.com>
Reviewed by David Levin.
......
......@@ -53,6 +53,7 @@ private:
RetainPtr<WebView> m_view;
RetainPtr<NSString> m_resultForSynchronousDismissal;
RetainPtr<NSCondition> m_resultCondition;
bool m_isDismissing;
};
#endif // !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
......
......@@ -47,6 +47,7 @@ CorrectionPanel::CorrectionPanel()
: m_wasDismissedExternally(false)
, m_reasonForDismissing(ReasonForDismissingCorrectionPanelIgnored)
, m_resultCondition(AdoptNS, [[NSCondition alloc] init])
, m_isDismissing(false)
{
}
......@@ -78,6 +79,7 @@ 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)
......@@ -87,12 +89,9 @@ void CorrectionPanel::dismiss(ReasonForDismissingCorrectionPanel reason)
String CorrectionPanel::dismissSoon(ReasonForDismissingCorrectionPanel reason)
{
if (!isShowing())
return String();
dismissInternal(reason, true);
[m_resultCondition.get() lock];
while (!m_resultForSynchronousDismissal)
while (m_isDismissing)
[m_resultCondition.get() wait];
[m_resultCondition.get() unlock];
return m_resultForSynchronousDismissal.get();
......@@ -100,10 +99,11 @@ String CorrectionPanel::dismissSoon(ReasonForDismissingCorrectionPanel reason)
void CorrectionPanel::dismissInternal(ReasonForDismissingCorrectionPanel reason, bool dismissingExternally)
{
m_wasDismissedExternally = dismissingExternally;
if (!isShowing())
return;
m_isDismissing = true;
m_wasDismissedExternally = dismissingExternally;
m_reasonForDismissing = reason;
m_resultForSynchronousDismissal.clear();
[[NSSpellChecker sharedSpellChecker] dismissCorrectionIndicatorForView:m_view.get()];
......@@ -141,14 +141,13 @@ void CorrectionPanel::handleAcceptedReplacement(NSString* acceptedReplacement, N
break;
}
if (!m_wasDismissedExternally) {
if (!m_wasDismissedExternally)
[m_view.get() handleCorrectionPanelResult:acceptedReplacement];
return;
}
[m_resultCondition.get() lock];
if (acceptedReplacement)
m_resultForSynchronousDismissal.adoptNS([acceptedReplacement copy]);
[m_resultCondition.get() lock];
m_isDismissing = false;
[m_resultCondition.get() signal];
[m_resultCondition.get() unlock];
}
......
2011-05-11 Jia Pu <jpu@apple.com>
Reviewed by Darin Adler.
CorrectionPanel sometimes hangs in dismissSoon().
https://bugs.webkit.org/show_bug.cgi?id=60599
<rdar://problem/9313628>
Make sure dismissSoon() won't wait indefinitely if handleAcceptedReplacement() sets m_resultForSynchronousDismissal
to nil. Added a designated variable m_isDismissing, instead of piggy-backing m_resultForSynchronousDismissal,
for condition checking.
* UIProcess/mac/CorrectionPanel.h:
* UIProcess/mac/CorrectionPanel.mm:
(WebKit::CorrectionPanel::CorrectionPanel):
(WebKit::CorrectionPanel::show):
(WebKit::CorrectionPanel::dismissSoon):
(WebKit::CorrectionPanel::dismissInternal):
(WebKit::CorrectionPanel::handleAcceptedReplacement):
2011-05-11 Sheriff Bot <webkit.review.bot@gmail.com>
 
Unreviewed, rolling out r86255.
......
......@@ -54,6 +54,7 @@ private:
RetainPtr<WKView> m_view;
RetainPtr<NSString> m_resultForSynchronousDismissal;
RetainPtr<NSCondition> m_resultCondition;
bool m_isDismissing;
};
} // namespace WebKit
......
......@@ -53,6 +53,7 @@ CorrectionPanel::CorrectionPanel()
: m_wasDismissedExternally(false)
, m_reasonForDismissing(ReasonForDismissingCorrectionPanelIgnored)
, m_resultCondition(AdoptNS, [[NSCondition alloc] init])
, m_isDismissing(false)
{
}
......@@ -85,6 +86,7 @@ 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)
......@@ -94,12 +96,9 @@ void CorrectionPanel::dismiss(ReasonForDismissingCorrectionPanel reason)
String CorrectionPanel::dismissSoon(ReasonForDismissingCorrectionPanel reason)
{
if (!isShowing())
return String();
dismissInternal(reason, true);
[m_resultCondition.get() lock];
while (!m_resultForSynchronousDismissal)
while (m_isDismissing)
[m_resultCondition.get() wait];
[m_resultCondition.get() unlock];
return m_resultForSynchronousDismissal.get();
......@@ -107,10 +106,11 @@ String CorrectionPanel::dismissSoon(ReasonForDismissingCorrectionPanel reason)
void CorrectionPanel::dismissInternal(ReasonForDismissingCorrectionPanel reason, bool dismissingExternally)
{
m_wasDismissedExternally = dismissingExternally;
if (!isShowing())
return;
m_isDismissing = true;
m_wasDismissedExternally = dismissingExternally;
m_reasonForDismissing = reason;
m_resultForSynchronousDismissal.clear();
[[NSSpellChecker sharedSpellChecker] dismissCorrectionIndicatorForView:m_view.get()];
......@@ -148,14 +148,13 @@ void CorrectionPanel::handleAcceptedReplacement(NSString* acceptedReplacement, N
break;
}
if (!m_wasDismissedExternally) {
if (!m_wasDismissedExternally)
[m_view.get() handleCorrectionPanelResult:acceptedReplacement];
return;
}
[m_resultCondition.get() lock];
if (acceptedReplacement)
m_resultForSynchronousDismissal.adoptNS([acceptedReplacement copy]);
[m_resultCondition.get() lock];
m_isDismissing = false;
[m_resultCondition.get() signal];
[m_resultCondition.get() unlock];
}
......
Supports Markdown
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