Skip to content

Commit

Permalink
Rename MAC_CATALYST_GRAMMAR_CHECKING to ENABLE_POST_EDITING_GRAMMAR_C…
Browse files Browse the repository at this point in the history
…HECKING for clarity.

https://bugs.webkit.org/show_bug.cgi?id=241434

Reviewed by Tim Horton.

After upstreaming, change the name of this flag, and also have it in open source for clarity.

* Source/WTF/wtf/PlatformEnableCocoa.h:
* Source/WebCore/editing/Editor.cpp:
(WebCore::Editor::markMisspellingsAfterTypingToWord):
(WebCore::Editor::markAndReplaceFor):
* Source/WebCore/platform/graphics/cocoa/GraphicsContextCocoa.mm:
(WebCore::grammarColor):
* Source/WebKit/Platform/spi/ios/UIKitSPI.h:
* Source/WebKit/UIProcess/ios/TextCheckerIOS.mm:
(WebKit::mutableState):
(WebKit::TextChecker::setGrammarCheckingEnabled):
(WebKit::TextChecker::checkTextOfParagraph):

Canonical link: https://commits.webkit.org/251414@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@295408 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
megangardner committed Jun 9, 2022
1 parent df8b96d commit 82a311d
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
5 changes: 5 additions & 0 deletions Source/WTF/wtf/PlatformEnableCocoa.h
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions Source/WebCore/editing/Editor.cpp
Expand Up @@ -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);
Expand Down Expand Up @@ -2879,7 +2879,7 @@ void Editor::markAndReplaceFor(const SpellCheckRequest& request, const Vector<Te

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 ENABLE(POST_EDITING_GRAMMAR_CHECKING)
if (!resultRangeIsAcceptableForReplacement && shouldCheckForCorrection && resultType == TextCheckingType::Correction)
resultRangeIsAcceptableForReplacement = results[i].details.size() > 0;
if (!resultRangeIsAcceptableForReplacement && shouldMarkGrammar && shouldCheckForCorrection && resultType == TextCheckingType::Correction) {
Expand Down Expand Up @@ -2934,7 +2934,7 @@ void Editor::markAndReplaceFor(const SpellCheckRequest& request, const Vector<Te

String replacedString = plainText(rangeToReplace);
bool existingMarkersPermitReplacement = m_alternativeTextController->processMarkersOnTextToBeReplacedByResult(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
Expand Down
Expand Up @@ -63,7 +63,7 @@

static RetainPtr<CGColorRef> 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, [] {
Expand Down
2 changes: 1 addition & 1 deletion Source/WebKit/Platform/spi/ios/UIKitSPI.h
Expand Up @@ -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<NSTextCheckingResult *> *)checkString:(NSString *)stringToCheck range:(NSRange)range types:(NSTextCheckingTypes)checkingTypes languages:(NSArray<NSString *> *)languagesArray options:(NSDictionary<NSString *, id> *)options;
Expand Down
6 changes: 3 additions & 3 deletions Source/WebKit/UIProcess/ios/TextCheckerIOS.mm
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit 82a311d

Please sign in to comment.