Diff
Modified: trunk/Source/WebKit/mac/ChangeLog (199827 => 199828)
--- trunk/Source/WebKit/mac/ChangeLog 2016-04-21 19:36:36 UTC (rev 199827)
+++ trunk/Source/WebKit/mac/ChangeLog 2016-04-21 19:37:30 UTC (rev 199828)
@@ -1,3 +1,26 @@
+2016-04-21 Beth Dakin <bda...@apple.com>
+
+ showCandidates() should take a range and the string should be the whole
+ paragraph
+ https://bugs.webkit.org/show_bug.cgi?id=156813
+ -and corresponding-
+ rdar://problem/25760533
+
+ Reviewed by Tim Horton.
+
+ Cache the range and the paragraph since we compute them in
+ requestCandidatesForSelection, and then we can use them again in
+ handleRequestedCandidates.
+ * WebCoreSupport/WebEditorClient.h:
+ * WebCoreSupport/WebEditorClient.mm:
+ (WebEditorClient::requestCandidatesForSelection):
+ (WebEditorClient::handleRequestedCandidates):
+ * WebView/WebView.mm:
+ (-[WebView updateWebViewAdditions]):
+ (-[WebView showCandidates:forString:inRect:forSelectedRange:view:completionHandler:]):
+ (-[WebView showCandidates:forString:inRect:view:completionHandler:]): Deleted.
+ * WebView/WebViewInternal.h:
+
2016-04-21 Chris Dumez <cdu...@apple.com>
Drop [UsePointersEvenForNonNullableObjectArguments] from Range
Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.h (199827 => 199828)
--- trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.h 2016-04-21 19:36:36 UTC (rev 199827)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.h 2016-04-21 19:37:30 UTC (rev 199828)
@@ -187,6 +187,10 @@
#endif
WebCore::VisibleSelection m_lastSelectionForRequestedCandidates;
+#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
+ RetainPtr<NSString> m_paragraphContextForCandidateRequest;
+ NSRange m_rangeForCandidates;
+#endif
WeakPtrFactory<WebEditorClient> m_weakPtrFactory;
};
Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm (199827 => 199828)
--- trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm 2016-04-21 19:36:36 UTC (rev 199827)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm 2016-04-21 19:37:30 UTC (rev 199828)
@@ -1153,12 +1153,12 @@
int lengthToSelectionStart = TextIterator::rangeLength(makeRange(paragraphStart, selectionStart).get());
int lengthToSelectionEnd = TextIterator::rangeLength(makeRange(paragraphStart, selectionEnd).get());
- NSRange rangeForCandidates = NSMakeRange(lengthToSelectionStart, lengthToSelectionEnd - lengthToSelectionStart);
- String fullPlainTextStringOfParagraph = plainText(makeRange(paragraphStart, paragraphEnd).get());
+ NSRange m_rangeForCandidates = NSMakeRange(lengthToSelectionStart, lengthToSelectionEnd - lengthToSelectionStart);
+ m_paragraphContextForCandidateRequest = plainText(makeRange(paragraphStart, paragraphEnd).get());
NSTextCheckingTypes checkingTypes = NSTextCheckingTypeSpelling | NSTextCheckingTypeReplacement | NSTextCheckingTypeCorrection;
auto weakEditor = m_weakPtrFactory.createWeakPtr();
- [[NSSpellChecker sharedSpellChecker] requestCandidatesForSelectedRange:rangeForCandidates inString:fullPlainTextStringOfParagraph types:checkingTypes options:nil inSpellDocumentWithTag:spellCheckerDocumentTag() completionHandler:[weakEditor](NSInteger sequenceNumber, NSArray<NSTextCheckingResult *> *candidates) {
+ [[NSSpellChecker sharedSpellChecker] requestCandidatesForSelectedRange:m_rangeForCandidates inString:m_paragraphContextForCandidateRequest.get() types:checkingTypes options:nil inSpellDocumentWithTag:spellCheckerDocumentTag() completionHandler:[weakEditor](NSInteger sequenceNumber, NSArray<NSTextCheckingResult *> *candidates) {
dispatch_async(dispatch_get_main_queue(), ^{
if (!weakEditor)
return;
@@ -1189,7 +1189,7 @@
rectForSelectionCandidates = frame->view()->contentsToWindow(quads[0].enclosingBoundingBox());
auto weakEditor = m_weakPtrFactory.createWeakPtr();
- [m_webView showCandidates:candidates forString:frame->editor().stringForCandidateRequest() inRect:rectForSelectionCandidates view:m_webView completionHandler:[weakEditor](NSTextCheckingResult *acceptedCandidate) {
+ [m_webView showCandidates:candidates forString:m_paragraphContextForCandidateRequest.get() inRect:rectForSelectionCandidates forSelectedRange:m_rangeForCandidates view:m_webView completionHandler:[weakEditor](NSTextCheckingResult *acceptedCandidate) {
dispatch_async(dispatch_get_main_queue(), ^{
if (!weakEditor)
return;
Modified: trunk/Source/WebKit/mac/WebView/WebView.mm (199827 => 199828)
--- trunk/Source/WebKit/mac/WebView/WebView.mm 2016-04-21 19:36:36 UTC (rev 199827)
+++ trunk/Source/WebKit/mac/WebView/WebView.mm 2016-04-21 19:37:30 UTC (rev 199828)
@@ -6692,7 +6692,7 @@
{
}
-- (void)showCandidates:(NSArray *)candidates forString:(NSString *)string inRect:(NSRect)rectOfTypedString view:(NSView *)view completionHandler:(void (^)(NSTextCheckingResult *acceptedCandidate))completionBlock
+- (void)showCandidates:(NSArray *)candidates forString:(NSString *)string inRect:(NSRect)rectOfTypedString forSelectedRange:(NSRange)range view:(NSView *)view completionHandler:(void (^)(NSTextCheckingResult *acceptedCandidate))completionBlock
{
}
Modified: trunk/Source/WebKit/mac/WebView/WebViewInternal.h (199827 => 199828)
--- trunk/Source/WebKit/mac/WebView/WebViewInternal.h 2016-04-21 19:36:36 UTC (rev 199827)
+++ trunk/Source/WebKit/mac/WebView/WebViewInternal.h 2016-04-21 19:37:30 UTC (rev 199828)
@@ -291,5 +291,5 @@
@interface WebView (WebUpdateWebViewAdditions)
- (void)updateWebViewAdditions;
-- (void)showCandidates:(NSArray *)candidates forString:(NSString *)string inRect:(NSRect)rectOfTypedString view:(NSView *)view completionHandler:(void (^)(NSTextCheckingResult *acceptedCandidate))completionBlock;
+- (void)showCandidates:(NSArray *)candidates forString:(NSString *)string inRect:(NSRect)rectOfTypedString forSelectedRange:(NSRange)range view:(NSView *)view completionHandler:(void (^)(NSTextCheckingResult *acceptedCandidate))completionBlock;
@end
Modified: trunk/Source/WebKit2/ChangeLog (199827 => 199828)
--- trunk/Source/WebKit2/ChangeLog 2016-04-21 19:36:36 UTC (rev 199827)
+++ trunk/Source/WebKit2/ChangeLog 2016-04-21 19:37:30 UTC (rev 199828)
@@ -1,3 +1,20 @@
+2016-04-21 Beth Dakin <bda...@apple.com>
+
+ showCandidates() should take a range and the string should be the whole
+ paragraph
+ https://bugs.webkit.org/show_bug.cgi?id=156813
+ -and corresponding-
+ rdar://problem/25760533
+
+ Reviewed by Tim Horton.
+
+ * UIProcess/Cocoa/WebViewImpl.h:
+ * UIProcess/Cocoa/WebViewImpl.mm:
+ (WebKit::WebViewImpl::updateWebViewImplAdditions):
+ (WebKit::WebViewImpl::showCandidates):
+ (WebKit::WebViewImpl::requestCandidatesForSelectionIfNeeded):
+ (WebKit::WebViewImpl::handleRequestedCandidates):
+
2016-04-21 Chelsea Pugh <cp...@apple.com>
[iOS] Allow clients to hide the accessory view on a form input session
Modified: trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h (199827 => 199828)
--- trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h 2016-04-21 19:36:36 UTC (rev 199827)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h 2016-04-21 19:37:30 UTC (rev 199828)
@@ -472,7 +472,7 @@
void rightMouseUp(NSEvent *);
void updateWebViewImplAdditions();
- void showCandidates(NSArray *candidates, NSString *, NSRect rectOfTypedString, NSView *, void (^completionHandler)(NSTextCheckingResult *acceptedCandidate));
+ void showCandidates(NSArray *candidates, NSString *, NSRect rectOfTypedString, NSRange selectedRange, NSView *, void (^completionHandler)(NSTextCheckingResult *acceptedCandidate));
void webViewImplAdditionsWillDestroyView();
bool windowIsFrontWindowUnderMouse(NSEvent *);
Modified: trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm (199827 => 199828)
--- trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm 2016-04-21 19:36:36 UTC (rev 199827)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm 2016-04-21 19:37:30 UTC (rev 199828)
@@ -91,6 +91,10 @@
#import <WebKitSystemInterface.h>
#import <sys/stat.h>
+#if USE(APPLE_INTERNAL_SDK)
+#import <WebKitAdditions/WebViewImplIncludes.h>
+#endif
+
SOFT_LINK_CONSTANT_MAY_FAIL(Lookup, LUNotificationPopoverWillClose, NSString *)
@interface NSApplication ()
@@ -435,7 +439,7 @@
{
}
-void WebViewImpl::showCandidates(NSArray *candidates, NSString *string, NSRect rectOfTypedString, NSView *view, void (^completionHandler)(NSTextCheckingResult *acceptedCandidate))
+void WebViewImpl::showCandidates(NSArray *candidates, NSString *string, NSRect rectOfTypedString, NSRange selectedRange, NSView *view, void (^completionHandler)(NSTextCheckingResult *acceptedCandidate))
{
}
@@ -2154,10 +2158,10 @@
m_lastStringForCandidateRequest = postLayoutData.stringForCandidateRequest;
#if HAVE(ADVANCED_SPELL_CHECKING)
- NSRange rangeForCandidates = NSMakeRange(postLayoutData.candidateRequestStartPosition, postLayoutData.selectedTextLength);
+ NSRange selectedRange = NSMakeRange(postLayoutData.candidateRequestStartPosition, postLayoutData.selectedTextLength);
NSTextCheckingTypes checkingTypes = NSTextCheckingTypeSpelling | NSTextCheckingTypeReplacement | NSTextCheckingTypeCorrection;
auto weakThis = createWeakPtr();
- [[NSSpellChecker sharedSpellChecker] requestCandidatesForSelectedRange:rangeForCandidates inString:postLayoutData.paragraphContextForCandidateRequest types:checkingTypes options:nil inSpellDocumentWithTag:spellCheckerDocumentTag() completionHandler:[weakThis](NSInteger sequenceNumber, NSArray<NSTextCheckingResult *> *candidates) {
+ [[NSSpellChecker sharedSpellChecker] requestCandidatesForSelectedRange:selectedRange inString:postLayoutData.paragraphContextForCandidateRequest types:checkingTypes options:nil inSpellDocumentWithTag:spellCheckerDocumentTag() completionHandler:[weakThis](NSInteger sequenceNumber, NSArray<NSTextCheckingResult *> *candidates) {
dispatch_async(dispatch_get_main_queue(), ^{
if (!weakThis)
return;
@@ -2182,8 +2186,9 @@
if (m_lastStringForCandidateRequest != postLayoutData.stringForCandidateRequest)
return;
+ NSRange selectedRange = NSMakeRange(postLayoutData.candidateRequestStartPosition, postLayoutData.selectedTextLength);
auto weakThis = createWeakPtr();
- showCandidates(candidates, postLayoutData.stringForCandidateRequest, postLayoutData.selectionClipRect, m_view, [weakThis](NSTextCheckingResult *acceptedCandidate) {
+ showCandidates(candidates, postLayoutData.paragraphContextForCandidateRequest, postLayoutData.selectionClipRect, selectedRange, m_view, [weakThis](NSTextCheckingResult *acceptedCandidate) {
dispatch_async(dispatch_get_main_queue(), ^{
if (!weakThis)
return;