Title: [195552] trunk/Source/WebKit/mac
- Revision
- 195552
- Author
- [email protected]
- Date
- 2016-01-25 13:38:07 -0800 (Mon, 25 Jan 2016)
Log Message
WK1: Handle soft spaces after accepted candidates
https://bugs.webkit.org/show_bug.cgi?id=153442
-and corresponding-
rdar://problem/23958418
Reviewed by Tim Horton.
The space at the end of candidates is a soft space. If that space exists,
cache the range of the space in m_softSpaceRange.
* WebCoreSupport/WebEditorClient.mm:
(WebEditorClient::handleAcceptedCandidate):
New ivar in WebHTMLViewPrivate softSpaceRange keeps track to the NSRange of a
soft space if the last text that was inserted has a soft space at the end.
* WebView/WebHTMLView.mm:
(-[WebHTMLView initWithFrame:]):
(-[WebHTMLView _setSoftSpaceRange:]):
When new text is inserted, find out if it is being inserted right after a
soft space. If it is, then [NSSpellChecker deletesAutospaceBeforeString] will
tell us if the space needs to be removed. If that is the case, then set the
replacementString to the soft space.
(-[WebHTMLView insertText:]):
* WebView/WebHTMLViewInternal.h:
Modified Paths
Diff
Modified: trunk/Source/WebKit/mac/ChangeLog (195551 => 195552)
--- trunk/Source/WebKit/mac/ChangeLog 2016-01-25 21:12:22 UTC (rev 195551)
+++ trunk/Source/WebKit/mac/ChangeLog 2016-01-25 21:38:07 UTC (rev 195552)
@@ -1,3 +1,30 @@
+2016-01-25 Beth Dakin <[email protected]>
+
+ WK1: Handle soft spaces after accepted candidates
+ https://bugs.webkit.org/show_bug.cgi?id=153442
+ -and corresponding-
+ rdar://problem/23958418
+
+ Reviewed by Tim Horton.
+
+ The space at the end of candidates is a soft space. If that space exists,
+ cache the range of the space in m_softSpaceRange.
+ * WebCoreSupport/WebEditorClient.mm:
+ (WebEditorClient::handleAcceptedCandidate):
+
+ New ivar in WebHTMLViewPrivate softSpaceRange keeps track to the NSRange of a
+ soft space if the last text that was inserted has a soft space at the end.
+ * WebView/WebHTMLView.mm:
+ (-[WebHTMLView initWithFrame:]):
+ (-[WebHTMLView _setSoftSpaceRange:]):
+
+ When new text is inserted, find out if it is being inserted right after a
+ soft space. If it is, then [NSSpellChecker deletesAutospaceBeforeString] will
+ tell us if the space needs to be removed. If that is the case, then set the
+ replacementString to the soft space.
+ (-[WebHTMLView insertText:]):
+ * WebView/WebHTMLViewInternal.h:
+
2016-01-17 Ada Chan <[email protected]>
Add a mode parameter to MediaControllerInterface::supportsFullscreen() and ChromeClient::supportsVideoFullscreen().
Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm (195551 => 195552)
--- trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm 2016-01-25 21:12:22 UTC (rev 195551)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm 2016-01-25 21:38:07 UTC (rev 195552)
@@ -1215,6 +1215,17 @@
if (selection != m_lastSelectionForRequestedCandidates)
return;
+ NSView <WebDocumentView> *view = [[[m_webView selectedFrame] frameView] documentView];
+ if ([view isKindOfClass:[WebHTMLView class]]) {
+ NSRange range = [acceptedCandidate range];
+ if (acceptedCandidate.replacementString && [acceptedCandidate.replacementString length] > 0) {
+ NSRange replacedRange = NSMakeRange(range.location, [acceptedCandidate.replacementString length]);
+ NSRange softSpaceRange = NSMakeRange(NSMaxRange(replacedRange) - 1, 1);
+ if ([acceptedCandidate.replacementString hasSuffix:@" "])
+ [(WebHTMLView *)view _setSoftSpaceRange:softSpaceRange];
+ }
+ }
+
frame->editor().handleAcceptedCandidate(textCheckingResultFromNSTextCheckingResult(acceptedCandidate));
}
#endif // PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
Modified: trunk/Source/WebKit/mac/WebView/WebHTMLView.mm (195551 => 195552)
--- trunk/Source/WebKit/mac/WebView/WebHTMLView.mm 2016-01-25 21:12:22 UTC (rev 195551)
+++ trunk/Source/WebKit/mac/WebView/WebHTMLView.mm 2016-01-25 21:38:07 UTC (rev 195552)
@@ -109,6 +109,7 @@
#import <WebCore/LocalizedStrings.h>
#import <WebCore/MIMETypeRegistry.h>
#import <WebCore/MainFrame.h>
+#import <WebCore/NSSpellCheckerSPI.h>
#import <WebCore/NSURLFileTypeMappingsSPI.h>
#import <WebCore/NSViewSPI.h>
#import <WebCore/Page.h>
@@ -977,6 +978,7 @@
#if !PLATFORM(IOS)
BOOL installedTrackingArea;
id flagsChangedEventMonitor;
+ NSRange softSpaceRange;
#endif
#ifndef NDEBUG
@@ -2844,6 +2846,7 @@
_private = [[WebHTMLViewPrivate alloc] init];
_private->pluginController = [[WebPluginController alloc] initWithDocumentView:self];
+ _private->softSpaceRange = NSMakeRange(NSNotFound, 0);
#if PLATFORM(IOS)
[[NSNotificationCenter defaultCenter]
addObserver:self selector:@selector(markedTextUpdate:)
@@ -6126,8 +6129,13 @@
[fontManager setSelectedFont:font isMultiple:multipleFonts];
[fontManager setSelectedAttributes:(attributes ? attributes : @{ }) isMultiple:multipleFonts];
}
-#endif
+- (void)_setSoftSpaceRange:(NSRange)range
+{
+ _private->softSpaceRange = range;
+}
+#endif // !PLATFORM(IOS)
+
- (BOOL)_canSmartCopyOrDelete
{
if (![[self _webView] smartInsertDeleteEnabled])
@@ -7086,6 +7094,14 @@
if (!coreFrame || !coreFrame->editor().canEdit())
return;
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
+ if (_private->softSpaceRange.location != NSNotFound && (replacementRange.location == NSMaxRange(_private->softSpaceRange) || replacementRange.location == NSNotFound) && replacementRange.length == 0 && [[NSSpellChecker sharedSpellChecker] deletesAutospaceBeforeString:text language:nil])
+ replacementRange = _private->softSpaceRange;
+#endif
+#if !PLATFORM(IOS)
+ _private->softSpaceRange = NSMakeRange(NSNotFound, 0);
+#endif
+
if (replacementRange.location != NSNotFound)
[[self _frame] _selectNSRange:replacementRange];
Modified: trunk/Source/WebKit/mac/WebView/WebHTMLViewInternal.h (195551 => 195552)
--- trunk/Source/WebKit/mac/WebView/WebHTMLViewInternal.h 2016-01-25 21:12:22 UTC (rev 195551)
+++ trunk/Source/WebKit/mac/WebView/WebHTMLViewInternal.h 2016-01-25 21:38:07 UTC (rev 195552)
@@ -42,6 +42,7 @@
- (void)_selectionChanged;
#if !PLATFORM(IOS)
- (void)_updateFontPanel;
+- (void)_setSoftSpaceRange:(NSRange)range;
#endif
- (BOOL)_canSmartCopyOrDelete;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes