diff --git a/Source/WTF/wtf/PlatformEnableCocoa.h b/Source/WTF/wtf/PlatformEnableCocoa.h index 3936b9291446..a69e19f17edb 100644 --- a/Source/WTF/wtf/PlatformEnableCocoa.h +++ b/Source/WTF/wtf/PlatformEnableCocoa.h @@ -481,6 +481,11 @@ #define ENABLE_POINTER_LOCK 0 #endif + +#if !defined(ENABLE_POST_EDITING_GRAMMAR_CHECKING) && ((PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 130000) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 160000)) +#define ENABLE_POST_EDITING_GRAMMAR_CHECKING 1 +#endif + #if !defined(ENABLE_PREVIEW_CONVERTER) && PLATFORM(IOS) #define ENABLE_PREVIEW_CONVERTER 1 #endif diff --git a/Source/WebCore/editing/Editor.cpp b/Source/WebCore/editing/Editor.cpp index 8a9287257741..c612448ae89a 100644 --- a/Source/WebCore/editing/Editor.cpp +++ b/Source/WebCore/editing/Editor.cpp @@ -2546,7 +2546,7 @@ void Editor::markMisspellingsAfterTypingToWord(const VisiblePosition& wordStart, auto adjacentWords = VisibleSelection(startOfWord(wordStart, LeftWordIfOnBoundary), endOfWord(wordStart, RightWordIfOnBoundary)); auto adjacentWordRange = adjacentWords.toNormalizedRange(); -#if ENABLE(MAC_CATALYST_GRAMMAR_CHECKING) +#if ENABLE(POST_EDITING_GRAMMAR_CHECKING) if (isGrammarCheckingEnabled()) { textCheckingOptions.add(TextCheckingType::Grammar); textCheckingOptions.add(TextCheckingType::Correction); @@ -2879,7 +2879,7 @@ void Editor::markAndReplaceFor(const SpellCheckRequest& request, const Vector 0; if (!resultRangeIsAcceptableForReplacement && shouldMarkGrammar && shouldCheckForCorrection && resultType == TextCheckingType::Correction) { @@ -2934,7 +2934,7 @@ void Editor::markAndReplaceFor(const SpellCheckRequest& request, const VectorprocessMarkersOnTextToBeReplacedByResult(results[i], rangeToReplace, replacedString); -#if ENABLE(MAC_CATALYST_GRAMMAR_CHECKING) +#if ENABLE(POST_EDITING_GRAMMAR_CHECKING) if (!existingMarkersPermitReplacement && shouldCheckForCorrection && resultType == TextCheckingType::Correction) existingMarkersPermitReplacement = results[i].details.size() > 0; #endif diff --git a/Source/WebCore/platform/graphics/cocoa/GraphicsContextCocoa.mm b/Source/WebCore/platform/graphics/cocoa/GraphicsContextCocoa.mm index e3ac16b3b48a..b80c223e9420 100644 --- a/Source/WebCore/platform/graphics/cocoa/GraphicsContextCocoa.mm +++ b/Source/WebCore/platform/graphics/cocoa/GraphicsContextCocoa.mm @@ -63,7 +63,7 @@ static RetainPtr grammarColor(bool useDarkMode) { -#if ENABLE(MAC_CATALYST_GRAMMAR_CHECKING) +#if ENABLE(POST_EDITING_GRAMMAR_CHECKING) static bool useBlueForGrammar = false; static std::once_flag flag; std::call_once(flag, [] { diff --git a/Source/WebKit/Platform/spi/ios/UIKitSPI.h b/Source/WebKit/Platform/spi/ios/UIKitSPI.h index aebd53894ec6..0602b36a26f6 100644 --- a/Source/WebKit/Platform/spi/ios/UIKitSPI.h +++ b/Source/WebKit/Platform/spi/ios/UIKitSPI.h @@ -1545,7 +1545,7 @@ typedef NS_ENUM(NSUInteger, _UIContextMenuLayout) { @end #endif -#if ENABLE(MAC_CATALYST_GRAMMAR_CHECKING) +#if ENABLE(POST_EDITING_GRAMMAR_CHECKING) @interface UITextChecker () + (BOOL)grammarCheckingEnabled; - (NSArray *)checkString:(NSString *)stringToCheck range:(NSRange)range types:(NSTextCheckingTypes)checkingTypes languages:(NSArray *)languagesArray options:(NSDictionary *)options; diff --git a/Source/WebKit/UIProcess/ios/TextCheckerIOS.mm b/Source/WebKit/UIProcess/ios/TextCheckerIOS.mm index 2ab40e06b8a9..be28327f8e06 100644 --- a/Source/WebKit/UIProcess/ios/TextCheckerIOS.mm +++ b/Source/WebKit/UIProcess/ios/TextCheckerIOS.mm @@ -46,7 +46,7 @@ static NeverDestroyed state = [] { TextCheckerState initialState; initialState.isContinuousSpellCheckingEnabled = TextChecker::isContinuousSpellCheckingAllowed(); -#if ENABLE(MAC_CATALYST_GRAMMAR_CHECKING) +#if ENABLE(POST_EDITING_GRAMMAR_CHECKING) initialState.isGrammarCheckingEnabled = [UITextChecker respondsToSelector:@selector(grammarCheckingEnabled)] && [UITextChecker grammarCheckingEnabled]; #else initialState.isGrammarCheckingEnabled = false; @@ -81,7 +81,7 @@ void TextChecker::setGrammarCheckingEnabled(bool isGrammarCheckingEnabled) { -#if ENABLE(MAC_CATALYST_GRAMMAR_CHECKING) +#if ENABLE(POST_EDITING_GRAMMAR_CHECKING) if (state().isGrammarCheckingEnabled == isGrammarCheckingEnabled) return; @@ -222,7 +222,7 @@ auto stringToCheck = text.createNSStringWithoutCopying(); auto range = NSMakeRange(0, [stringToCheck length]); -#if ENABLE(MAC_CATALYST_GRAMMAR_CHECKING) +#if ENABLE(POST_EDITING_GRAMMAR_CHECKING) if ([textChecker respondsToSelector:@selector(checkString:range:types:languages:options:)]) { NSTextCheckingTypes types = 0; if (checkingTypes.contains(TextCheckingType::Spelling))