Diff
Modified: trunk/Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj (295120 => 295121)
--- trunk/Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj 2022-06-02 05:05:28 UTC (rev 295120)
+++ trunk/Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj 2022-06-02 07:42:37 UTC (rev 295121)
@@ -71,6 +71,7 @@
416E995323DAE6BE00E871CB /* AudioToolboxSoftLink.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 416E995123DAE6BD00E871CB /* AudioToolboxSoftLink.cpp */; };
41E1F344248A6A000022D5DE /* VideoToolboxSoftLink.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 416E995523DAEFF700E871CB /* VideoToolboxSoftLink.cpp */; };
4450FC9F21F5F602004DFA56 /* QuickLookSoftLink.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4450FC9D21F5F602004DFA56 /* QuickLookSoftLink.mm */; };
+ 4469328B28483EF700614F16 /* FoundationSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 4469328A2848321C00614F16 /* FoundationSPI.h */; settings = {ATTRIBUTES = (Private, ); }; };
44E1A8B021FA54EB00C3048E /* LookupSoftLink.mm in Sources */ = {isa = PBXBuildFile; fileRef = 44E1A8AE21FA54DA00C3048E /* LookupSoftLink.mm */; };
57F1C90A25DCF0CF00E8F6EA /* CryptoKitPrivateSoftLink.mm in Sources */ = {isa = PBXBuildFile; fileRef = 57F1C90825DCF0CF00E8F6EA /* CryptoKitPrivateSoftLink.mm */; };
57FD318A22B3593E008D0E8B /* AppSSOSoftLink.mm in Sources */ = {isa = PBXBuildFile; fileRef = 57FD318922B3593E008D0E8B /* AppSSOSoftLink.mm */; };
@@ -863,6 +864,7 @@
445097BB26EBF66D003EF771 /* CFNotificationCenterSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFNotificationCenterSPI.h; sourceTree = "<group>"; };
4450FC9D21F5F602004DFA56 /* QuickLookSoftLink.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = QuickLookSoftLink.mm; sourceTree = "<group>"; };
4450FC9E21F5F602004DFA56 /* QuickLookSoftLink.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QuickLookSoftLink.h; sourceTree = "<group>"; };
+ 4469328A2848321C00614F16 /* FoundationSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FoundationSPI.h; sourceTree = "<group>"; };
44E1A8AD21FA54DA00C3048E /* LookupSoftLink.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LookupSoftLink.h; sourceTree = "<group>"; };
44E1A8AE21FA54DA00C3048E /* LookupSoftLink.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = LookupSoftLink.mm; sourceTree = "<group>"; };
44EEA0FE2747438900594A83 /* NSServicesRolloverButtonCellSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSServicesRolloverButtonCellSPI.h; sourceTree = "<group>"; };
@@ -1049,6 +1051,7 @@
0C2DA1251F3BEB4900DBC317 /* DataDetectorsCoreSPI.h */,
1D12CC4A2411BCAE00FDA0A3 /* FeatureFlagsSPI.h */,
93468E662714A7CD009983E3 /* FilePortSPI.h */,
+ 4469328A2848321C00614F16 /* FoundationSPI.h */,
CE5673862151A7B9002F92D7 /* IOKitSPI.h */,
0C2DA1261F3BEB4900DBC317 /* IOPMLibSPI.h */,
0C2DA1271F3BEB4900DBC317 /* IOPSLibSPI.h */,
@@ -1690,6 +1693,7 @@
DD20DDE527BC90D70093D175 /* FeatureFlagsSPI.h in Headers */,
DD20DDE627BC90D70093D175 /* FilePortSPI.h in Headers */,
DD20DE5F27BC90D80093D175 /* FileSizeFormatter.h in Headers */,
+ 4469328B28483EF700614F16 /* FoundationSPI.h in Headers */,
DD20DE1227BC90D80093D175 /* GraphicsServicesSPI.h in Headers */,
DD20DE6027BC90D80093D175 /* Gunzip.h in Headers */,
DD20DE1E27BC90D80093D175 /* HIServicesSPI.h in Headers */,
Added: trunk/Source/WebCore/PAL/pal/spi/cocoa/FoundationSPI.h (0 => 295121)
--- trunk/Source/WebCore/PAL/pal/spi/cocoa/FoundationSPI.h (rev 0)
+++ trunk/Source/WebCore/PAL/pal/spi/cocoa/FoundationSPI.h 2022-06-02 07:42:37 UTC (rev 295121)
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2022 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#import <Foundation/Foundation.h>
+
+@interface NSTextCheckingResult ()
+- (NSDictionary *)detail;
+@end
+
Modified: trunk/Source/WebCore/editing/Editor.cpp (295120 => 295121)
--- trunk/Source/WebCore/editing/Editor.cpp 2022-06-02 05:05:28 UTC (rev 295120)
+++ trunk/Source/WebCore/editing/Editor.cpp 2022-06-02 07:42:37 UTC (rev 295121)
@@ -2880,6 +2880,8 @@
bool resultRangeIsAcceptableForReplacement = automaticReplacementStartLocation <= resultEndLocation && resultEndLocation <= automaticReplacementEndLocation;
// In this case the result range just has to touch the automatic replacement range, so we can handle replacing non-word text such as punctuation.
#if ENABLE(MAC_CATALYST_GRAMMAR_CHECKING)
+ if (!resultRangeIsAcceptableForReplacement && shouldCheckForCorrection && resultType == TextCheckingType::Correction)
+ resultRangeIsAcceptableForReplacement = results[i].details.size() > 0;
if (!resultRangeIsAcceptableForReplacement && shouldMarkGrammar && shouldCheckForCorrection && resultType == TextCheckingType::Correction) {
resultRangeIsAcceptableForReplacement = previousGrammarRanges.containsIf([&](auto& range) {
return range.location == resultLocation && range.length == resultLength;
@@ -2932,6 +2934,10 @@
String replacedString = plainText(rangeToReplace);
bool existingMarkersPermitReplacement = m_alternativeTextController->processMarkersOnTextToBeReplacedByResult(results[i], rangeToReplace, replacedString);
+#if ENABLE(MAC_CATALYST_GRAMMAR_CHECKING)
+ if (!existingMarkersPermitReplacement && shouldCheckForCorrection && resultType == TextCheckingType::Correction)
+ existingMarkersPermitReplacement = results[i].details.size() > 0;
+#endif
if (!existingMarkersPermitReplacement)
continue;
Modified: trunk/Source/WebKit/UIProcess/ios/TextCheckerIOS.mm (295120 => 295121)
--- trunk/Source/WebKit/UIProcess/ios/TextCheckerIOS.mm 2022-06-02 05:05:28 UTC (rev 295120)
+++ trunk/Source/WebKit/UIProcess/ios/TextCheckerIOS.mm 2022-06-02 07:42:37 UTC (rev 295121)
@@ -31,6 +31,7 @@
#import "TextCheckerState.h"
#import "UIKitSPI.h"
#import <WebCore/NotImplemented.h>
+#import <pal/spi/cocoa/FoundationSPI.h>
#import <wtf/HashMap.h>
#import <wtf/NeverDestroyed.h>
#import <wtf/RetainPtr.h>
@@ -272,6 +273,25 @@
result.type = TextCheckingType::Correction;
result.range = resultRange;
result.replacement = [incomingResult replacementString];
+ if ([incomingResult respondsToSelector:@selector(detail)]) {
+ NSDictionary *incomingDetail = [incomingResult detail];
+ if (incomingDetail) {
+ result.details.reserveInitialCapacity(1);
+ GrammarDetail detail;
+
+ NSValue *detailRangeAsNSValue = [incomingDetail objectForKey:@"NSGrammarRange"];
+ ASSERT(detailRangeAsNSValue);
+
+ NSRange detailNSRange = [detailRangeAsNSValue rangeValue];
+ ASSERT(detailNSRange.location != NSNotFound);
+ ASSERT(detailNSRange.length > 0);
+
+ detail.range = detailNSRange;
+ detail.userDescription = [incomingDetail objectForKey:@"NSGrammarUserDescription"];
+ detail.guesses = makeVector<String>([incomingDetail objectForKey:@"NSGrammarCorrections"]);
+ result.details.uncheckedAppend(WTFMove(detail));
+ }
+ }
results.append(WTFMove(result));
}
}
Modified: trunk/Source/WebKit/UIProcess/mac/TextCheckerMac.mm (295120 => 295121)
--- trunk/Source/WebKit/UIProcess/mac/TextCheckerMac.mm 2022-06-02 05:05:28 UTC (rev 295120)
+++ trunk/Source/WebKit/UIProcess/mac/TextCheckerMac.mm 2022-06-02 07:42:37 UTC (rev 295121)
@@ -30,6 +30,7 @@
#import "TextCheckerState.h"
#import <WebCore/NotImplemented.h>
+#import <pal/spi/cocoa/FoundationSPI.h>
#import <pal/spi/mac/NSSpellCheckerSPI.h>
#import <wtf/CheckedArithmetic.h>
#import <wtf/NeverDestroyed.h>
@@ -41,6 +42,7 @@
- (NSString *)languageForWordRange:(NSRange)range inString:(NSString *)string orthography:(NSOrthography *)orthography;
@end
+
static NSString* const WebAutomaticSpellingCorrectionEnabled = @"WebAutomaticSpellingCorrectionEnabled";
static NSString* const WebContinuousSpellCheckingEnabled = @"WebContinuousSpellCheckingEnabled";
static NSString* const WebGrammarCheckingEnabled = @"WebGrammarCheckingEnabled";
@@ -395,6 +397,26 @@
result.type = TextCheckingType::Correction;
result.range = resultRange;
result.replacement = [incomingResult replacementString];
+ if ([incomingResult respondsToSelector:@selector(detail)]) {
+ NSDictionary *incomingDetail = [incomingResult detail];
+ if (incomingDetail) {
+ result.details.reserveInitialCapacity(1);
+ GrammarDetail detail;
+
+ NSValue *detailRangeAsNSValue = [incomingDetail objectForKey:NSGrammarRange];
+ ASSERT(detailRangeAsNSValue);
+
+ NSRange detailNSRange = [detailRangeAsNSValue rangeValue];
+ ASSERT(detailNSRange.location != NSNotFound);
+ ASSERT(detailNSRange.length > 0);
+
+ detail.range = detailNSRange;
+ detail.userDescription = [incomingDetail objectForKey:NSGrammarUserDescription];
+ NSArray *guesses = [incomingDetail objectForKey:NSGrammarCorrections];
+ detail.guesses = makeVector<String>(guesses);
+ result.details.uncheckedAppend(WTFMove(detail));
+ }
+ }
results.append(WTFMove(result));
}
}