Title: [235299] releases/WebKitGTK/webkit-2.22/Source
Revision
235299
Author
carlo...@webkit.org
Date
2018-08-24 01:09:35 -0700 (Fri, 24 Aug 2018)

Log Message

Merge r235120 - Replace TextCheckingTypeMask with OptionSet
https://bugs.webkit.org/show_bug.cgi?id=188678

Reviewed by Antti Koivisto.

Source/WebCore:

Replaces TextCheckingTypeMask with an OptionSet to improve type safety and code clarity. Additionally
change the values of TextCheckingType such that all the enumerators fit within an uint8_t.

* PlatformMac.cmake:
* SourcesCocoa.txt:
* WebCore.xcodeproj/project.pbxproj:
* accessibility/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::hasMisspelling const):
* accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
(AXAttributeStringSetSpelling):
* editing/AlternativeTextController.cpp:
(WebCore::AlternativeTextController::timerFired):
(WebCore::AlternativeTextController::processMarkersOnTextToBeReplacedByResult):
* editing/Editor.cpp:
(WebCore::Editor::replaceSelectionWithFragment):
(WebCore::Editor::markMisspellingsAfterTypingToWord):
(WebCore::Editor::markAllMisspellingsAndBadGrammarInRanges):
(WebCore::isAutomaticTextReplacementType):
(WebCore::Editor::markAndReplaceFor): For now, change a local variable from const to non-const to work
around the following MSVC compiler bug: <https://developercommunity.visualstudio.com/content/problem/316713/msvc-cant-compile-webkits-optionsetcontainsany.html>.
(WebCore::Editor::markMisspellingsAndBadGrammar):
(WebCore::Editor::updateMarkersForWordsAffectedByEditing):
(WebCore::Editor::editorUIUpdateTimerFired):
(WebCore::Editor::resolveTextCheckingTypeMask):
* editing/Editor.h:
* editing/SpellChecker.cpp:
(WebCore::SpellCheckRequest::SpellCheckRequest):
(WebCore::SpellCheckRequest::create):
(WebCore::SpellChecker::didCheckSucceed):
* editing/SpellChecker.h:
* editing/TextCheckingHelper.cpp:
(WebCore::findGrammaticalErrors):
(WebCore::findMisspellings):
(WebCore::TextCheckingHelper::findFirstMisspellingOrBadGrammar):
(WebCore::TextCheckingHelper::guessesForMisspelledOrUngrammaticalRange const):
(WebCore::checkTextOfParagraph):
* editing/TextCheckingHelper.h:
* loader/EmptyClients.cpp:
* platform/text/TextCheckerClient.h:
* platform/text/TextChecking.h: Remove TextCheckingTypeMask. Reorganized the fields of TextCheckingRequestData
to coallesce padding and move it to the end of class. Also used default initializer syntax and defaulted (= default)
the default constructor of TextCheckingRequestData, removing the need for a user-defined default constructor.
(WebCore::TextCheckingRequestData::TextCheckingRequestData):
(WebCore::TextCheckingRequestData::text const): Changed return type from String to const String&
to avoid unnecessary ref-count churn for callers that do not need to take a shared ownership in
this string.
(WebCore::TextCheckingRequestData::checkingTypes const): Renamed; formerly named mask.
(WebCore::TextCheckingRequestData::mask const): Deleted.
* platform/text/mac/TextCheckingMac.mm: Added.
(WebCore::nsTextCheckingTypes):
* testing/Internals.cpp:
(WebCore::Internals::handleAcceptedCandidate):

Source/WebKit:

* Scripts/webkit/messages.py: Add WebCore::TextCheckingType to the special case map so that
the generator knows what header has the definition for this type.
* Shared/WebCoreArgumentCoders.cpp:
(IPC::ArgumentCoder<TextCheckingRequestData>::encode):
(IPC::ArgumentCoder<TextCheckingRequestData>::decode):
* UIProcess/Cocoa/WebViewImpl.mm:
(WebKit::coreTextCheckingType):
(WebKit::textCheckingResultFromNSTextCheckingResult):
* UIProcess/TextChecker.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::checkTextOfParagraph):
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* UIProcess/gtk/TextCheckerGtk.cpp:
(WebKit::TextChecker::requestCheckingOfString):
(WebKit::TextChecker::checkTextOfParagraph): Also simplified return expressions.
* UIProcess/ios/TextCheckerIOS.mm:
(WebKit::TextChecker::checkTextOfParagraph):
* UIProcess/mac/TextCheckerMac.mm:
(WebKit::TextChecker::checkTextOfParagraph):
* UIProcess/win/TextCheckerWin.cpp:
(WebKit::TextChecker::checkTextOfParagraph):
* WebProcess/WebCoreSupport/WebEditorClient.cpp:
(WebKit::WebEditorClient::shouldEraseMarkersAfterChangeSelection const):
(WebKit::WebEditorClient::checkTextOfParagraph):
* WebProcess/WebCoreSupport/WebEditorClient.h:

Source/WebKitLegacy/mac:

Currently we have code in WebEditorClient::checkTextOfParagraph() that incorrectly assumes
that the enumerators of TextCheckingType have a one-to-one correspondence with NSTextCheckingType.
(This is not the case because there is not corresponding NSTextCheckingType for TextCheckingTypeShowCorrectionPanel).
We now explicitly convert from OptionSet<TextCheckingType> to NSTextCheckingTypes.

* WebCoreSupport/WebEditorClient.h:
* WebCoreSupport/WebEditorClient.mm:
(WebEditorClient::checkTextOfParagraph):
(WebEditorClient::shouldEraseMarkersAfterChangeSelection const):
(core): Fix up code style nits; compare resultType on the right-hand side instead of the
left as this is more readable and unncessary now that modern compilers like Clang have
diagnostics to catch accidental assignments when equality was intended.
(WebEditorClient::didCheckSucceed):
* WebView/WebView.mm:
(coreTextCheckingType):
(textCheckingResultFromNSTextCheckingResult):

Modified Paths

Added Paths

Diff

Modified: releases/WebKitGTK/webkit-2.22/Source/WebCore/ChangeLog (235298 => 235299)


--- releases/WebKitGTK/webkit-2.22/Source/WebCore/ChangeLog	2018-08-24 08:09:07 UTC (rev 235298)
+++ releases/WebKitGTK/webkit-2.22/Source/WebCore/ChangeLog	2018-08-24 08:09:35 UTC (rev 235299)
@@ -1,3 +1,63 @@
+2018-08-21  Daniel Bates  <daba...@apple.com>
+
+        Replace TextCheckingTypeMask with OptionSet
+        https://bugs.webkit.org/show_bug.cgi?id=188678
+
+        Reviewed by Antti Koivisto.
+
+        Replaces TextCheckingTypeMask with an OptionSet to improve type safety and code clarity. Additionally
+        change the values of TextCheckingType such that all the enumerators fit within an uint8_t.
+
+        * PlatformMac.cmake:
+        * SourcesCocoa.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * accessibility/AccessibilityObject.cpp:
+        (WebCore::AccessibilityObject::hasMisspelling const):
+        * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
+        (AXAttributeStringSetSpelling):
+        * editing/AlternativeTextController.cpp:
+        (WebCore::AlternativeTextController::timerFired):
+        (WebCore::AlternativeTextController::processMarkersOnTextToBeReplacedByResult):
+        * editing/Editor.cpp:
+        (WebCore::Editor::replaceSelectionWithFragment):
+        (WebCore::Editor::markMisspellingsAfterTypingToWord):
+        (WebCore::Editor::markAllMisspellingsAndBadGrammarInRanges):
+        (WebCore::isAutomaticTextReplacementType):
+        (WebCore::Editor::markAndReplaceFor): For now, change a local variable from const to non-const to work
+        around the following MSVC compiler bug: <https://developercommunity.visualstudio.com/content/problem/316713/msvc-cant-compile-webkits-optionsetcontainsany.html>.
+        (WebCore::Editor::markMisspellingsAndBadGrammar):
+        (WebCore::Editor::updateMarkersForWordsAffectedByEditing):
+        (WebCore::Editor::editorUIUpdateTimerFired):
+        (WebCore::Editor::resolveTextCheckingTypeMask):
+        * editing/Editor.h:
+        * editing/SpellChecker.cpp:
+        (WebCore::SpellCheckRequest::SpellCheckRequest):
+        (WebCore::SpellCheckRequest::create):
+        (WebCore::SpellChecker::didCheckSucceed):
+        * editing/SpellChecker.h:
+        * editing/TextCheckingHelper.cpp:
+        (WebCore::findGrammaticalErrors):
+        (WebCore::findMisspellings):
+        (WebCore::TextCheckingHelper::findFirstMisspellingOrBadGrammar):
+        (WebCore::TextCheckingHelper::guessesForMisspelledOrUngrammaticalRange const):
+        (WebCore::checkTextOfParagraph):
+        * editing/TextCheckingHelper.h:
+        * loader/EmptyClients.cpp:
+        * platform/text/TextCheckerClient.h:
+        * platform/text/TextChecking.h: Remove TextCheckingTypeMask. Reorganized the fields of TextCheckingRequestData
+        to coallesce padding and move it to the end of class. Also used default initializer syntax and defaulted (= default)
+        the default constructor of TextCheckingRequestData, removing the need for a user-defined default constructor.
+        (WebCore::TextCheckingRequestData::TextCheckingRequestData):
+        (WebCore::TextCheckingRequestData::text const): Changed return type from String to const String&
+        to avoid unnecessary ref-count churn for callers that do not need to take a shared ownership in
+        this string.
+        (WebCore::TextCheckingRequestData::checkingTypes const): Renamed; formerly named mask.
+        (WebCore::TextCheckingRequestData::mask const): Deleted.
+        * platform/text/mac/TextCheckingMac.mm: Added.
+        (WebCore::nsTextCheckingTypes):
+        * testing/Internals.cpp:
+        (WebCore::Internals::handleAcceptedCandidate):
+
 2018-08-21  Fujii Hironori  <hironori.fu...@sony.com>
 
         Don't place "using namespace XXX;" in global space for unified source builds

Modified: releases/WebKitGTK/webkit-2.22/Source/WebCore/PlatformMac.cmake (235298 => 235299)


--- releases/WebKitGTK/webkit-2.22/Source/WebCore/PlatformMac.cmake	2018-08-24 08:09:07 UTC (rev 235298)
+++ releases/WebKitGTK/webkit-2.22/Source/WebCore/PlatformMac.cmake	2018-08-24 08:09:35 UTC (rev 235299)
@@ -452,6 +452,7 @@
 
     platform/text/mac/LocaleMac.mm
     platform/text/mac/TextBoundaries.mm
+    platform/text/mac/TextCheckingMac.mm
     platform/text/mac/TextEncodingRegistryMac.mm
 
     rendering/RenderThemeCocoa.mm

Modified: releases/WebKitGTK/webkit-2.22/Source/WebCore/SourcesCocoa.txt (235298 => 235299)


--- releases/WebKitGTK/webkit-2.22/Source/WebCore/SourcesCocoa.txt	2018-08-24 08:09:07 UTC (rev 235298)
+++ releases/WebKitGTK/webkit-2.22/Source/WebCore/SourcesCocoa.txt	2018-08-24 08:09:35 UTC (rev 235299)
@@ -527,6 +527,7 @@
 
 platform/text/mac/LocaleMac.mm
 platform/text/mac/TextBoundaries.mm
+platform/text/mac/TextCheckingMac.mm
 platform/text/mac/TextEncodingRegistryMac.mm
 
 rendering/RenderThemeCocoa.mm

Modified: releases/WebKitGTK/webkit-2.22/Source/WebCore/WebCore.xcodeproj/project.pbxproj (235298 => 235299)


--- releases/WebKitGTK/webkit-2.22/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2018-08-24 08:09:07 UTC (rev 235298)
+++ releases/WebKitGTK/webkit-2.22/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2018-08-24 08:09:35 UTC (rev 235299)
@@ -13534,6 +13534,7 @@
 		CE7B2DB11586ABAD0098B3FA /* TextAlternativeWithRange.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextAlternativeWithRange.h; sourceTree = "<group>"; };
 		CE7B2DB21586ABAD0098B3FA /* TextAlternativeWithRange.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TextAlternativeWithRange.mm; sourceTree = "<group>"; };
 		CE7E17821C83A49100AD06AF /* ContentSecurityPolicyHash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ContentSecurityPolicyHash.h; path = csp/ContentSecurityPolicyHash.h; sourceTree = "<group>"; };
+		CEA84720212622AD00940809 /* TextCheckingMac.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = TextCheckingMac.mm; sourceTree = "<group>"; };
 		CEBB8C3120786DCB00039547 /* FetchIdioms.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FetchIdioms.h; sourceTree = "<group>"; };
 		CEBB8C3220786DCB00039547 /* FetchIdioms.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FetchIdioms.cpp; sourceTree = "<group>"; };
 		CECADFC2153778FF00E37068 /* DictationAlternative.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DictationAlternative.cpp; sourceTree = "<group>"; };
@@ -23915,6 +23916,7 @@
 				F5973DDE15CFB2030027F804 /* LocaleMac.h */,
 				F5973DDF15CFB2030027F804 /* LocaleMac.mm */,
 				B2AFFC8C0D00A5DF0030074D /* TextBoundaries.mm */,
+				CEA84720212622AD00940809 /* TextCheckingMac.mm */,
 				A1F55DC41F54D3F000EDB75F /* TextEncodingRegistryMac.mm */,
 			);
 			path = mac;

Modified: releases/WebKitGTK/webkit-2.22/Source/WebCore/accessibility/AccessibilityObject.cpp (235298 => 235299)


--- releases/WebKitGTK/webkit-2.22/Source/WebCore/accessibility/AccessibilityObject.cpp	2018-08-24 08:09:07 UTC (rev 235298)
+++ releases/WebKitGTK/webkit-2.22/Source/WebCore/accessibility/AccessibilityObject.cpp	2018-08-24 08:09:35 UTC (rev 235299)
@@ -437,7 +437,7 @@
 
     if (unifiedTextCheckerEnabled(frame)) {
         Vector<TextCheckingResult> results;
-        checkTextOfParagraph(*textChecker, stringValue(), TextCheckingTypeSpelling, results, frame->selection().selection());
+        checkTextOfParagraph(*textChecker, stringValue(), TextCheckingType::Spelling, results, frame->selection().selection());
         if (!results.isEmpty())
             isMisspelled = true;
         return isMisspelled;

Modified: releases/WebKitGTK/webkit-2.22/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm (235298 => 235299)


--- releases/WebKitGTK/webkit-2.22/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm	2018-08-24 08:09:07 UTC (rev 235298)
+++ releases/WebKitGTK/webkit-2.22/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm	2018-08-24 08:09:35 UTC (rev 235299)
@@ -909,7 +909,7 @@
         
         // checkTextOfParagraph is the only spelling/grammar checker implemented in WK1 and WK2
         Vector<TextCheckingResult> results;
-        checkTextOfParagraph(*checker, text, TextCheckingTypeSpelling, results, node->document().frame()->selection().selection());
+        checkTextOfParagraph(*checker, text, TextCheckingType::Spelling, results, node->document().frame()->selection().selection());
         
         size_t size = results.size();
         for (unsigned i = 0; i < size; i++) {

Modified: releases/WebKitGTK/webkit-2.22/Source/WebCore/editing/AlternativeTextController.cpp (235298 => 235299)


--- releases/WebKitGTK/webkit-2.22/Source/WebCore/editing/AlternativeTextController.cpp	2018-08-24 08:09:07 UTC (rev 235298)
+++ releases/WebKitGTK/webkit-2.22/Source/WebCore/editing/AlternativeTextController.cpp	2018-08-24 08:09:35 UTC (rev 235299)
@@ -284,7 +284,7 @@
         VisiblePosition p = startOfWord(start, LeftWordIfOnBoundary);
         VisibleSelection adjacentWords = VisibleSelection(p, start);
         auto adjacentWordRange = adjacentWords.toNormalizedRange();
-        m_frame.editor().markAllMisspellingsAndBadGrammarInRanges(TextCheckingTypeSpelling | TextCheckingTypeReplacement | TextCheckingTypeShowCorrectionPanel, adjacentWordRange.copyRef(), adjacentWordRange.copyRef(), nullptr);
+        m_frame.editor().markAllMisspellingsAndBadGrammarInRanges({ TextCheckingType::Spelling, TextCheckingType::Replacement, TextCheckingType::ShowCorrectionPanel }, adjacentWordRange.copyRef(), adjacentWordRange.copyRef(), nullptr);
     }
         break;
     case AlternativeTextTypeReversion: {
@@ -540,7 +540,7 @@
 {
     DocumentMarkerController& markerController = m_frame.document()->markers();
     if (markerController.hasMarkers(rangeWithAlternative, DocumentMarker::Replacement)) {
-        if (result.type == TextCheckingTypeCorrection)
+        if (result.type == TextCheckingType::Correction)
             recordSpellcheckerResponseForModifiedCorrection(rangeWithAlternative, stringToBeReplaced, result.replacement);
         return false;
     }

Modified: releases/WebKitGTK/webkit-2.22/Source/WebCore/editing/Editor.cpp (235298 => 235299)


--- releases/WebKitGTK/webkit-2.22/Source/WebCore/editing/Editor.cpp	2018-08-24 08:09:07 UTC (rev 235298)
+++ releases/WebKitGTK/webkit-2.22/Source/WebCore/editing/Editor.cpp	2018-08-24 08:09:35 UTC (rev 235299)
@@ -668,7 +668,7 @@
         return;
 
     auto rangeToCheck = Range::create(document(), firstPositionInNode(nodeToCheck), lastPositionInNode(nodeToCheck));
-    if (auto request = SpellCheckRequest::create(resolveTextCheckingTypeMask(*nodeToCheck, TextCheckingTypeSpelling | TextCheckingTypeGrammar), TextCheckingProcessBatch, rangeToCheck.copyRef(), rangeToCheck.copyRef(), rangeToCheck.copyRef()))
+    if (auto request = SpellCheckRequest::create(resolveTextCheckingTypeMask(*nodeToCheck, { TextCheckingType::Spelling, TextCheckingType::Grammar }), TextCheckingProcessBatch, rangeToCheck.copyRef(), rangeToCheck.copyRef(), rangeToCheck.copyRef()))
         m_spellChecker->requestCheckingFor(request.releaseNonNull());
 }
 
@@ -2341,10 +2341,10 @@
 #if PLATFORM(IOS)
     UNUSED_PARAM(selectionAfterTyping);
     UNUSED_PARAM(doReplacement);
-    TextCheckingTypeMask textCheckingOptions = 0;
+    OptionSet<TextCheckingType> textCheckingOptions;
     if (isContinuousSpellCheckingEnabled())
-        textCheckingOptions |= TextCheckingTypeSpelling;
-    if (!(textCheckingOptions & TextCheckingTypeSpelling))
+        textCheckingOptions |= TextCheckingType::Spelling;
+    if (!textCheckingOptions.contains(TextCheckingType::Spelling))
         return;
 
     VisibleSelection adjacentWords = VisibleSelection(startOfWord(wordStart, LeftWordIfOnBoundary), endOfWord(wordStart, RightWordIfOnBoundary));
@@ -2358,10 +2358,10 @@
     if (unifiedTextCheckerEnabled()) {
         m_alternativeTextController->applyPendingCorrection(selectionAfterTyping);
 
-        TextCheckingTypeMask textCheckingOptions = 0;
+        OptionSet<TextCheckingType> textCheckingOptions;
 
         if (isContinuousSpellCheckingEnabled())
-            textCheckingOptions |= TextCheckingTypeSpelling;
+            textCheckingOptions |= TextCheckingType::Spelling;
 
 #if USE(AUTOMATIC_TEXT_REPLACEMENT)
         if (doReplacement
@@ -2369,14 +2369,14 @@
                 || isAutomaticLinkDetectionEnabled()
                 || isAutomaticDashSubstitutionEnabled()
                 || isAutomaticTextReplacementEnabled()
-                || ((textCheckingOptions & TextCheckingTypeSpelling) && isAutomaticSpellingCorrectionEnabled())))
-            textCheckingOptions |= TextCheckingTypeReplacement;
+                || (textCheckingOptions.contains(TextCheckingType::Spelling) && isAutomaticSpellingCorrectionEnabled())))
+            textCheckingOptions |= TextCheckingType::Replacement;
 #endif
-        if (!(textCheckingOptions & (TextCheckingTypeSpelling | TextCheckingTypeReplacement)))
+        if (!textCheckingOptions.contains(TextCheckingType::Spelling) && !textCheckingOptions.contains(TextCheckingType::Replacement))
             return;
 
         if (isGrammarCheckingEnabled())
-            textCheckingOptions |= TextCheckingTypeGrammar;
+            textCheckingOptions |= TextCheckingType::Grammar;
 
         auto sentenceStart = startOfSentence(wordStart);
         auto sentenceEnd = endOfSentence(wordStart);
@@ -2558,7 +2558,7 @@
 #endif
 }
 
-void Editor::markAllMisspellingsAndBadGrammarInRanges(TextCheckingTypeMask textCheckingOptions, RefPtr<Range>&& spellingRange, RefPtr<Range>&& automaticReplacementRange, RefPtr<Range>&& grammarRange)
+void Editor::markAllMisspellingsAndBadGrammarInRanges(OptionSet<TextCheckingType> textCheckingOptions, RefPtr<Range>&& spellingRange, RefPtr<Range>&& automaticReplacementRange, RefPtr<Range>&& grammarRange)
 {
     ASSERT(unifiedTextCheckerEnabled());
 
@@ -2565,8 +2565,8 @@
     // There shouldn't be pending autocorrection at this moment.
     ASSERT(!m_alternativeTextController->hasPendingCorrection());
 
-    bool shouldMarkGrammar = textCheckingOptions & TextCheckingTypeGrammar;
-    bool shouldShowCorrectionPanel = textCheckingOptions & TextCheckingTypeShowCorrectionPanel;
+    bool shouldMarkGrammar = textCheckingOptions.contains(TextCheckingType::Grammar);
+    bool shouldShowCorrectionPanel = textCheckingOptions.contains(TextCheckingType::ShowCorrectionPanel);
 
     // This function is called with selections already expanded to word boundaries.
     if (!client() || !spellingRange || (shouldMarkGrammar && !grammarRange))
@@ -2607,16 +2607,16 @@
 static bool isAutomaticTextReplacementType(TextCheckingType type)
 {
     switch (type) {
-    case TextCheckingTypeNone:
-    case TextCheckingTypeSpelling:
-    case TextCheckingTypeGrammar:
+    case TextCheckingType::None:
+    case TextCheckingType::Spelling:
+    case TextCheckingType::Grammar:
         return false;
-    case TextCheckingTypeLink:
-    case TextCheckingTypeQuote:
-    case TextCheckingTypeDash:
-    case TextCheckingTypeReplacement:
-    case TextCheckingTypeCorrection:
-    case TextCheckingTypeShowCorrectionPanel:
+    case TextCheckingType::Link:
+    case TextCheckingType::Quote:
+    case TextCheckingType::Dash:
+    case TextCheckingType::Replacement:
+    case TextCheckingType::Correction:
+    case TextCheckingType::ShowCorrectionPanel:
         return true;
     }
     ASSERT_NOT_REACHED();
@@ -2646,15 +2646,16 @@
 {
     Ref<Frame> protection(m_frame);
 
-    TextCheckingTypeMask textCheckingOptions = request.data().mask();
+    auto textCheckingOptions = request.data().checkingTypes();
     TextCheckingParagraph paragraph(request.checkingRange(), request.automaticReplacementRange(), &request.paragraphRange());
 
-    const bool shouldMarkSpelling = textCheckingOptions & TextCheckingTypeSpelling;
-    const bool shouldMarkGrammar = textCheckingOptions & TextCheckingTypeGrammar;
-    const bool shouldMarkLink = textCheckingOptions & TextCheckingTypeLink;
-    const bool shouldPerformReplacement = textCheckingOptions & (TextCheckingTypeQuote | TextCheckingTypeDash | TextCheckingTypeReplacement);
-    const bool shouldShowCorrectionPanel = textCheckingOptions & TextCheckingTypeShowCorrectionPanel;
-    const bool shouldCheckForCorrection = shouldShowCorrectionPanel || (textCheckingOptions & TextCheckingTypeCorrection);
+    // FIXME: Mark this const once MSVC bug is fixed: <https://developercommunity.visualstudio.com/content/problem/316713/msvc-cant-compile-webkits-optionsetcontainsany.html>.
+    bool shouldPerformReplacement = textCheckingOptions.containsAny({ TextCheckingType::Quote, TextCheckingType::Dash, TextCheckingType::Replacement });
+    const bool shouldMarkSpelling = textCheckingOptions.contains(TextCheckingType::Spelling);
+    const bool shouldMarkGrammar = textCheckingOptions.contains(TextCheckingType::Grammar);
+    const bool shouldMarkLink = textCheckingOptions.contains(TextCheckingType::Link);
+    const bool shouldShowCorrectionPanel = textCheckingOptions.contains(TextCheckingType::ShowCorrectionPanel);
+    const bool shouldCheckForCorrection = shouldShowCorrectionPanel || textCheckingOptions.contains(TextCheckingType::Correction);
 #if !USE(AUTOCORRECTION_PANEL)
     ASSERT(!shouldShowCorrectionPanel);
 #endif
@@ -2696,7 +2697,7 @@
         // 2. Result falls within spellingRange.
         // 3. The word in question doesn't end at an ambiguous boundary. For instance, we would not mark
         //    "wouldn'" as misspelled right after apostrophe is typed.
-        if (shouldMarkSpelling && !shouldShowCorrectionPanel && resultType == TextCheckingTypeSpelling
+        if (shouldMarkSpelling && !shouldShowCorrectionPanel && resultType == TextCheckingType::Spelling
             && resultLocation >= paragraph.checkingStart() && resultEndLocation <= spellingRangeEndOffset && !resultEndsAtAmbiguousBoundary) {
             ASSERT(resultLength > 0 && resultLocation >= 0);
             auto misspellingRange = paragraph.subrange(resultLocation, resultLength);
@@ -2703,7 +2704,7 @@
             if (!m_alternativeTextController->isSpellingMarkerAllowed(misspellingRange))
                 continue;
             misspellingRange->startContainer().document().markers().addMarker(misspellingRange.ptr(), DocumentMarker::Spelling, replacement);
-        } else if (shouldMarkGrammar && resultType == TextCheckingTypeGrammar && paragraph.checkingRangeCovers(resultLocation, resultLength)) {
+        } else if (shouldMarkGrammar && resultType == TextCheckingType::Grammar && paragraph.checkingRangeCovers(resultLocation, resultLength)) {
             ASSERT(resultLength > 0 && resultLocation >= 0);
             for (auto& detail : results[i].details) {
                 ASSERT(detail.length > 0 && detail.location >= 0);
@@ -2718,7 +2719,7 @@
             ASSERT(resultLength > 0 && resultLocation >= 0);
 
             if (shouldShowCorrectionPanel && (resultEndLocation < automaticReplacementEndLocation
-                || !(resultType & (TextCheckingTypeReplacement | TextCheckingTypeCorrection))))
+                || (resultType != TextCheckingType::Replacement && resultType != TextCheckingType::Correction)))
                 continue;
 
             // Apply replacement if:
@@ -2728,8 +2729,8 @@
             bool doReplacement = replacement.length() > 0 && !resultEndsAtAmbiguousBoundary;
             auto rangeToReplace = paragraph.subrange(resultLocation, resultLength);
 
-            // adding links should be done only immediately after they are typed
-            if (resultType == TextCheckingTypeLink && selectionOffset != resultEndLocation + 1)
+            // Adding links should be done only immediately after they are typed.
+            if (resultType == TextCheckingType::Link && selectionOffset != resultEndLocation + 1)
                 continue;
 
             if (!(shouldPerformReplacement || shouldCheckForCorrection || shouldMarkLink) || !doReplacement)
@@ -2756,7 +2757,7 @@
                     continue;
             }
 
-            if (resultType == TextCheckingTypeLink) {
+            if (resultType == TextCheckingType::Link) {
                 m_frame.selection().setSelection(selectionToReplace);
                 selectionChanged = true;
                 restoreSelectionAfterChange = false;
@@ -2779,7 +2780,7 @@
                 if (resultLocation < selectionOffset)
                     selectionOffset += replacement.length() - resultLength;
 
-                if (resultType == TextCheckingTypeCorrection) {
+                if (resultType == TextCheckingType::Correction) {
                     auto replacementRange = paragraph.subrange(resultLocation, replacement.length());
                     m_alternativeTextController->recordAutocorrectionResponse(AutocorrectionResponse::Accepted, replacedString, replacementRange.ptr());
 
@@ -2839,9 +2840,9 @@
             return;
 
         // markMisspellingsAndBadGrammar() is triggered by selection change, in which case we check spelling and grammar, but don't autocorrect misspellings.
-        TextCheckingTypeMask textCheckingOptions = TextCheckingTypeSpelling;
+        OptionSet<TextCheckingType> textCheckingOptions { TextCheckingType::Spelling };
         if (markGrammar && isGrammarCheckingEnabled())
-            textCheckingOptions |= TextCheckingTypeGrammar;
+            textCheckingOptions |= TextCheckingType::Grammar;
         auto spellCheckingRange = spellingSelection.toNormalizedRange();
         markAllMisspellingsAndBadGrammarInRanges(textCheckingOptions, spellCheckingRange.copyRef(), spellCheckingRange.copyRef(), grammarSelection.toNormalizedRange());
         return;
@@ -2863,7 +2864,7 @@
     if (!document().markers().hasMarkers())
         return;
 
-    if (!m_alternativeTextController->shouldRemoveMarkersUponEditing() && (!textChecker() || textChecker()->shouldEraseMarkersAfterChangeSelection(TextCheckingTypeSpelling)))
+    if (!m_alternativeTextController->shouldRemoveMarkersUponEditing() && (!textChecker() || textChecker()->shouldEraseMarkersAfterChangeSelection(TextCheckingType::Spelling)))
         return;
 
     // We want to remove the markers from a word if an editing command will change the word. This can happen in one of
@@ -3654,11 +3655,11 @@
             }
         }
 
-        if (!textChecker() || textChecker()->shouldEraseMarkersAfterChangeSelection(TextCheckingTypeSpelling)) {
+        if (!textChecker() || textChecker()->shouldEraseMarkersAfterChangeSelection(TextCheckingType::Spelling)) {
             if (RefPtr<Range> wordRange = newAdjacentWords.toNormalizedRange())
                 document().markers().removeMarkers(wordRange.get(), DocumentMarker::Spelling);
         }
-        if (!textChecker() || textChecker()->shouldEraseMarkersAfterChangeSelection(TextCheckingTypeGrammar)) {
+        if (!textChecker() || textChecker()->shouldEraseMarkersAfterChangeSelection(TextCheckingType::Grammar)) {
             if (RefPtr<Range> sentenceRange = newSelectedSentence.toNormalizedRange())
                 document().markers().removeMarkers(sentenceRange.get(), DocumentMarker::Grammar);
         }
@@ -3715,7 +3716,7 @@
     return false;
 }       
 
-TextCheckingTypeMask Editor::resolveTextCheckingTypeMask(const Node& rootEditableElement, TextCheckingTypeMask textCheckingOptions)
+OptionSet<TextCheckingType> Editor::resolveTextCheckingTypeMask(const Node& rootEditableElement, OptionSet<TextCheckingType> textCheckingOptions)
 {
 #if USE(AUTOMATIC_TEXT_REPLACEMENT) && !PLATFORM(IOS)
     bool _onlyAllowsTextReplacement_ = false;
@@ -3722,44 +3723,44 @@
     if (auto* host = rootEditableElement.shadowHost())
         _onlyAllowsTextReplacement_ = is<HTMLInputElement>(host) && downcast<HTMLInputElement>(*host).isSpellcheckDisabledExceptTextReplacement();
     if (onlyAllowsTextReplacement)
-        textCheckingOptions &= TextCheckingTypeReplacement;
+        textCheckingOptions = textCheckingOptions & TextCheckingType::Replacement;
 #else
     UNUSED_PARAM(rootEditableElement);
 #endif
 
-    bool shouldMarkSpelling = textCheckingOptions & TextCheckingTypeSpelling;
-    bool shouldMarkGrammar = textCheckingOptions & TextCheckingTypeGrammar;
+    bool shouldMarkSpelling = textCheckingOptions.contains(TextCheckingType::Spelling);
+    bool shouldMarkGrammar = textCheckingOptions.contains(TextCheckingType::Grammar);
 #if !PLATFORM(IOS)
-    bool shouldShowCorrectionPanel = textCheckingOptions & TextCheckingTypeShowCorrectionPanel;
-    bool shouldCheckForCorrection = shouldShowCorrectionPanel || (textCheckingOptions & TextCheckingTypeCorrection);
+    bool shouldShowCorrectionPanel = textCheckingOptions.contains(TextCheckingType::ShowCorrectionPanel);
+    bool shouldCheckForCorrection = shouldShowCorrectionPanel || textCheckingOptions.contains(TextCheckingType::Correction);
 #endif
 
-    TextCheckingTypeMask checkingTypes = 0;
+    OptionSet<TextCheckingType> checkingTypes;
     if (shouldMarkSpelling)
-        checkingTypes |= TextCheckingTypeSpelling;
+        checkingTypes |= TextCheckingType::Spelling;
     if (shouldMarkGrammar)
-        checkingTypes |= TextCheckingTypeGrammar;
+        checkingTypes |= TextCheckingType::Grammar;
 #if !PLATFORM(IOS)
     if (shouldCheckForCorrection)
-        checkingTypes |= TextCheckingTypeCorrection;
+        checkingTypes |= TextCheckingType::Correction;
     if (shouldShowCorrectionPanel)
-        checkingTypes |= TextCheckingTypeShowCorrectionPanel;
+        checkingTypes |= TextCheckingType::ShowCorrectionPanel;
 
 #if USE(AUTOMATIC_TEXT_REPLACEMENT)
-    bool shouldPerformReplacement = textCheckingOptions & TextCheckingTypeReplacement;
+    bool shouldPerformReplacement = textCheckingOptions.contains(TextCheckingType::Replacement);
     if (shouldPerformReplacement) {
         if (!onlyAllowsTextReplacement) {
             if (isAutomaticLinkDetectionEnabled())
-                checkingTypes |= TextCheckingTypeLink;
+                checkingTypes |= TextCheckingType::Link;
             if (isAutomaticQuoteSubstitutionEnabled())
-                checkingTypes |= TextCheckingTypeQuote;
+                checkingTypes |= TextCheckingType::Quote;
             if (isAutomaticDashSubstitutionEnabled())
-                checkingTypes |= TextCheckingTypeDash;
+                checkingTypes |= TextCheckingType::Dash;
             if (shouldMarkSpelling && isAutomaticSpellingCorrectionEnabled())
-                checkingTypes |= TextCheckingTypeCorrection;
+                checkingTypes |= TextCheckingType::Correction;
         }
         if (isAutomaticTextReplacementEnabled())
-            checkingTypes |= TextCheckingTypeReplacement;
+            checkingTypes |= TextCheckingType::Replacement;
     }
 #endif
 #endif // !PLATFORM(IOS)

Modified: releases/WebKitGTK/webkit-2.22/Source/WebCore/editing/Editor.h (235298 => 235299)


--- releases/WebKitGTK/webkit-2.22/Source/WebCore/editing/Editor.h	2018-08-24 08:09:07 UTC (rev 235298)
+++ releases/WebKitGTK/webkit-2.22/Source/WebCore/editing/Editor.h	2018-08-24 08:09:35 UTC (rev 235299)
@@ -289,7 +289,7 @@
     bool isOverwriteModeEnabled() const { return m_overwriteModeEnabled; }
     WEBCORE_EXPORT void toggleOverwriteModeEnabled();
 
-    void markAllMisspellingsAndBadGrammarInRanges(TextCheckingTypeMask, RefPtr<Range>&& spellingRange, RefPtr<Range>&& automaticReplacementRange, RefPtr<Range>&& grammarRange);
+    void markAllMisspellingsAndBadGrammarInRanges(OptionSet<TextCheckingType>, RefPtr<Range>&& spellingRange, RefPtr<Range>&& automaticReplacementRange, RefPtr<Range>&& grammarRange);
 #if PLATFORM(IOS)
     NO_RETURN_DUE_TO_ASSERT
 #endif
@@ -528,7 +528,7 @@
 
     void revealSelectionAfterEditingOperation(const ScrollAlignment& = ScrollAlignment::alignCenterIfNeeded, RevealExtentOption = DoNotRevealExtent);
     void markMisspellingsOrBadGrammar(const VisibleSelection&, bool checkSpelling, RefPtr<Range>& firstMisspellingRange);
-    TextCheckingTypeMask resolveTextCheckingTypeMask(const Node& rootEditableElement, TextCheckingTypeMask);
+    OptionSet<TextCheckingType> resolveTextCheckingTypeMask(const Node& rootEditableElement, OptionSet<TextCheckingType>);
 
     WEBCORE_EXPORT String selectedText(TextIteratorBehavior) const;
 

Modified: releases/WebKitGTK/webkit-2.22/Source/WebCore/editing/SpellChecker.cpp (235298 => 235299)


--- releases/WebKitGTK/webkit-2.22/Source/WebCore/editing/SpellChecker.cpp	2018-08-24 08:09:07 UTC (rev 235298)
+++ releases/WebKitGTK/webkit-2.22/Source/WebCore/editing/SpellChecker.cpp	2018-08-24 08:09:35 UTC (rev 235299)
@@ -40,7 +40,7 @@
 
 namespace WebCore {
 
-SpellCheckRequest::SpellCheckRequest(Ref<Range>&& checkingRange, Ref<Range>&& automaticReplacementRange, Ref<Range>&& paragraphRange, const String& text, TextCheckingTypeMask mask, TextCheckingProcessType processType)
+SpellCheckRequest::SpellCheckRequest(Ref<Range>&& checkingRange, Ref<Range>&& automaticReplacementRange, Ref<Range>&& paragraphRange, const String& text, OptionSet<TextCheckingType> mask, TextCheckingProcessType processType)
     : m_checkingRange(WTFMove(checkingRange))
     , m_automaticReplacementRange(WTFMove(automaticReplacementRange))
     , m_paragraphRange(WTFMove(paragraphRange))
@@ -51,7 +51,7 @@
 
 SpellCheckRequest::~SpellCheckRequest() = default;
 
-RefPtr<SpellCheckRequest> SpellCheckRequest::create(TextCheckingTypeMask textCheckingOptions, TextCheckingProcessType processType, Ref<Range>&& checkingRange, Ref<Range>&& automaticReplacementRange, Ref<Range>&& paragraphRange)
+RefPtr<SpellCheckRequest> SpellCheckRequest::create(OptionSet<TextCheckingType> textCheckingOptions, TextCheckingProcessType processType, Ref<Range>&& checkingRange, Ref<Range>&& automaticReplacementRange, Ref<Range>&& paragraphRange)
 {
     String text = checkingRange->text();
     if (!text.length())
@@ -217,9 +217,9 @@
     TextCheckingRequestData requestData = m_processingRequest->data();
     if (requestData.sequence() == sequence) {
         OptionSet<DocumentMarker::MarkerType> markerTypes;
-        if (requestData.mask() & TextCheckingTypeSpelling)
+        if (requestData.checkingTypes().contains(TextCheckingType::Spelling))
             markerTypes |= DocumentMarker::Spelling;
-        if (requestData.mask() & TextCheckingTypeGrammar)
+        if (requestData.checkingTypes().contains(TextCheckingType::Grammar))
             markerTypes |= DocumentMarker::Grammar;
         if (!markerTypes.isEmpty())
             m_frame.document()->markers().removeMarkers(&m_processingRequest->checkingRange(), markerTypes);

Modified: releases/WebKitGTK/webkit-2.22/Source/WebCore/editing/SpellChecker.h (235298 => 235299)


--- releases/WebKitGTK/webkit-2.22/Source/WebCore/editing/SpellChecker.h	2018-08-24 08:09:07 UTC (rev 235298)
+++ releases/WebKitGTK/webkit-2.22/Source/WebCore/editing/SpellChecker.h	2018-08-24 08:09:35 UTC (rev 235299)
@@ -44,7 +44,7 @@
 
 class SpellCheckRequest : public TextCheckingRequest {
 public:
-    static RefPtr<SpellCheckRequest> create(TextCheckingTypeMask, TextCheckingProcessType, Ref<Range>&& checkingRange, Ref<Range>&& automaticReplacementRange, Ref<Range>&& paragraphRange);
+    static RefPtr<SpellCheckRequest> create(OptionSet<TextCheckingType>, TextCheckingProcessType, Ref<Range>&& checkingRange, Ref<Range>&& automaticReplacementRange, Ref<Range>&& paragraphRange);
     virtual ~SpellCheckRequest();
 
     Range& checkingRange() const { return m_checkingRange.get(); }
@@ -61,7 +61,7 @@
     void didCancel() override;
 
 private:
-    SpellCheckRequest(Ref<Range>&& checkingRange, Ref<Range>&& automaticReplacementRange, Ref<Range>&& paragraphRange, const String&, TextCheckingTypeMask, TextCheckingProcessType);
+    SpellCheckRequest(Ref<Range>&& checkingRange, Ref<Range>&& automaticReplacementRange, Ref<Range>&& paragraphRange, const String&, OptionSet<TextCheckingType>, TextCheckingProcessType);
 
     SpellChecker* m_checker { nullptr };
     Ref<Range> m_checkingRange;

Modified: releases/WebKitGTK/webkit-2.22/Source/WebCore/editing/TextCheckingHelper.cpp (235298 => 235299)


--- releases/WebKitGTK/webkit-2.22/Source/WebCore/editing/TextCheckingHelper.cpp	2018-08-24 08:09:07 UTC (rev 235298)
+++ releases/WebKitGTK/webkit-2.22/Source/WebCore/editing/TextCheckingHelper.cpp	2018-08-24 08:09:35 UTC (rev 235299)
@@ -62,7 +62,7 @@
         ASSERT(static_cast<unsigned>(badGrammarLength) <= text.length() - checkLocation - badGrammarLocation);
 
         TextCheckingResult badGrammar;
-        badGrammar.type = TextCheckingTypeGrammar;
+        badGrammar.type = TextCheckingType::Grammar;
         badGrammar.location = checkLocation + badGrammarLocation;
         badGrammar.length = badGrammarLength;
         badGrammar.details = WTFMove(badGrammarDetails);
@@ -96,7 +96,7 @@
             ASSERT(misspellingLocation + misspellingLength <= wordLength);
 
             TextCheckingResult misspelling;
-            misspelling.type = TextCheckingTypeSpelling;
+            misspelling.type = TextCheckingType::Spelling;
             misspelling.location = wordStart + misspellingLocation;
             misspelling.length = misspellingLength;
             misspelling.replacement = client.getAutoCorrectSuggestionForMisspelledWord(text.substring(misspelling.location, misspelling.length).toStringWithoutCopying());
@@ -351,7 +351,9 @@
                 unsigned grammarDetailIndex = 0;
                 
                 Vector<TextCheckingResult> results;
-                TextCheckingTypeMask checkingTypes = checkGrammar ? (TextCheckingTypeSpelling | TextCheckingTypeGrammar) : TextCheckingTypeSpelling;
+                OptionSet<TextCheckingType> checkingTypes { TextCheckingType::Spelling };
+                if (checkGrammar)
+                    checkingTypes |= TextCheckingType::Grammar;
                 VisibleSelection currentSelection;
                 if (Frame* frame = paragraphRange->ownerDocument().frame())
                     currentSelection = frame->selection().selection();
@@ -358,7 +360,7 @@
                 checkTextOfParagraph(*m_client.textChecker(), paragraphString, checkingTypes, results, currentSelection);
 
                 for (auto& result : results) {
-                    if (result.type == TextCheckingTypeSpelling && result.location >= currentStartOffset && result.location + result.length <= currentEndOffset) {
+                    if (result.type == TextCheckingType::Spelling && result.location >= currentStartOffset && result.location + result.length <= currentEndOffset) {
                         ASSERT(result.length > 0);
                         ASSERT(result.location >= 0);
                         spellingLocation = result.location;
@@ -366,7 +368,7 @@
                         ASSERT(misspelledWord.length());
                         break;
                     }
-                    if (checkGrammar && result.type == TextCheckingTypeGrammar && result.location < currentEndOffset && result.location + result.length > currentStartOffset) {
+                    if (checkGrammar && result.type == TextCheckingType::Grammar && result.location < currentEndOffset && result.location + result.length > currentStartOffset) {
                         ASSERT(result.length > 0);
                         ASSERT(result.location >= 0);
                         // We can't stop after the first grammar result, since there might still be a spelling result after
@@ -583,7 +585,9 @@
         return guesses;
 
     Vector<TextCheckingResult> results;
-    TextCheckingTypeMask checkingTypes = checkGrammar ? (TextCheckingTypeSpelling | TextCheckingTypeGrammar) : TextCheckingTypeSpelling;
+    OptionSet<TextCheckingType> checkingTypes { TextCheckingType::Spelling };
+    if (checkGrammar)
+        checkingTypes |= TextCheckingType::Grammar;
     VisibleSelection currentSelection;
     if (Frame* frame = m_range->ownerDocument().frame())
         currentSelection = frame->selection().selection();
@@ -590,7 +594,7 @@
     checkTextOfParagraph(*m_client.textChecker(), paragraph.text(), checkingTypes, results, currentSelection);
 
     for (auto& result : results) {
-        if (result.type == TextCheckingTypeSpelling && paragraph.checkingRangeMatches(result.location, result.length)) {
+        if (result.type == TextCheckingType::Spelling && paragraph.checkingRangeMatches(result.location, result.length)) {
             String misspelledWord = paragraph.checkingSubstring();
             ASSERT(misspelledWord.length());
             m_client.textChecker()->getGuessesForWord(misspelledWord, String(), currentSelection, guesses);
@@ -604,7 +608,7 @@
         return guesses;
 
     for (auto& result : results) {
-        if (result.type == TextCheckingTypeGrammar && paragraph.isCheckingRangeCoveredBy(result.location, result.length)) {
+        if (result.type == TextCheckingType::Grammar && paragraph.isCheckingRangeCoveredBy(result.location, result.length)) {
             for (auto& detail : result.details) {
                 ASSERT(detail.length > 0);
                 ASSERT(detail.location >= 0);
@@ -647,7 +651,7 @@
     return WebCore::unifiedTextCheckerEnabled(m_range->ownerDocument().frame());
 }
 
-void checkTextOfParagraph(TextCheckerClient& client, StringView text, TextCheckingTypeMask checkingTypes, Vector<TextCheckingResult>& results, const VisibleSelection& currentSelection)
+void checkTextOfParagraph(TextCheckerClient& client, StringView text, OptionSet<TextCheckingType> checkingTypes, Vector<TextCheckingResult>& results, const VisibleSelection& currentSelection)
 {
 #if USE(UNIFIED_TEXT_CHECKING)
     results = client.checkTextOfParagraph(text, checkingTypes, currentSelection);
@@ -655,13 +659,13 @@
     UNUSED_PARAM(currentSelection);
 
     Vector<TextCheckingResult> mispellings;
-    if (checkingTypes & TextCheckingTypeSpelling)
+    if (checkingTypes.contains(TextCheckingType::Spelling))
         findMisspellings(client, text, mispellings);
 
 #if USE(GRAMMAR_CHECKING)
     // Look for grammatical errors that occur before the first misspelling.
     Vector<TextCheckingResult> grammaticalErrors;
-    if (checkingTypes & TextCheckingTypeGrammar) {
+    if (checkingTypes.contains(TextCheckingType::Grammar)) {
         unsigned grammarCheckLength = text.length();
         for (auto& mispelling : mispellings)
             grammarCheckLength = std::min<unsigned>(grammarCheckLength, mispelling.location);

Modified: releases/WebKitGTK/webkit-2.22/Source/WebCore/editing/TextCheckingHelper.h (235298 => 235299)


--- releases/WebKitGTK/webkit-2.22/Source/WebCore/editing/TextCheckingHelper.h	2018-08-24 08:09:07 UTC (rev 235298)
+++ releases/WebKitGTK/webkit-2.22/Source/WebCore/editing/TextCheckingHelper.h	2018-08-24 08:09:35 UTC (rev 235299)
@@ -108,7 +108,7 @@
 #endif
 };
 
-void checkTextOfParagraph(TextCheckerClient&, StringView, TextCheckingTypeMask, Vector<TextCheckingResult>&, const VisibleSelection& currentSelection);
+void checkTextOfParagraph(TextCheckerClient&, StringView, OptionSet<TextCheckingType>, Vector<TextCheckingResult>&, const VisibleSelection& currentSelection);
 
 bool unifiedTextCheckerEnabled(const Frame*);
 

Modified: releases/WebKitGTK/webkit-2.22/Source/WebCore/loader/EmptyClients.cpp (235298 => 235299)


--- releases/WebKitGTK/webkit-2.22/Source/WebCore/loader/EmptyClients.cpp	2018-08-24 08:09:07 UTC (rev 235298)
+++ releases/WebKitGTK/webkit-2.22/Source/WebCore/loader/EmptyClients.cpp	2018-08-24 08:09:35 UTC (rev 235299)
@@ -264,7 +264,7 @@
         void checkGrammarOfString(StringView, Vector<GrammarDetail>&, int*, int*) final { }
 
 #if USE(UNIFIED_TEXT_CHECKING)
-        Vector<TextCheckingResult> checkTextOfParagraph(StringView, TextCheckingTypeMask, const VisibleSelection&) final { return Vector<TextCheckingResult>(); }
+        Vector<TextCheckingResult> checkTextOfParagraph(StringView, OptionSet<TextCheckingType>, const VisibleSelection&) final { return Vector<TextCheckingResult>(); }
 #endif
 
         void getGuessesForWord(const String&, const String&, const VisibleSelection&, Vector<String>&) final { }

Modified: releases/WebKitGTK/webkit-2.22/Source/WebCore/platform/text/TextCheckerClient.h (235298 => 235299)


--- releases/WebKitGTK/webkit-2.22/Source/WebCore/platform/text/TextCheckerClient.h	2018-08-24 08:09:07 UTC (rev 235298)
+++ releases/WebKitGTK/webkit-2.22/Source/WebCore/platform/text/TextCheckerClient.h	2018-08-24 08:09:35 UTC (rev 235299)
@@ -45,7 +45,7 @@
     virtual void checkGrammarOfString(StringView, Vector<GrammarDetail>&, int* badGrammarLocation, int* badGrammarLength) = 0;
 
 #if USE(UNIFIED_TEXT_CHECKING)
-    virtual Vector<TextCheckingResult> checkTextOfParagraph(StringView, TextCheckingTypeMask checkingTypes, const VisibleSelection& currentSelection) = 0;
+    virtual Vector<TextCheckingResult> checkTextOfParagraph(StringView, OptionSet<TextCheckingType> checkingTypes, const VisibleSelection& currentSelection) = 0;
 #endif
 
     // For spellcheckers that support multiple languages, it's often important to be able to identify the language in order to

Modified: releases/WebKitGTK/webkit-2.22/Source/WebCore/platform/text/TextChecking.h (235298 => 235299)


--- releases/WebKitGTK/webkit-2.22/Source/WebCore/platform/text/TextChecking.h	2018-08-24 08:09:07 UTC (rev 235298)
+++ releases/WebKitGTK/webkit-2.22/Source/WebCore/platform/text/TextChecking.h	2018-08-24 08:09:35 UTC (rev 235299)
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2011 Google Inc. All rights reserved.
+ * Copyright (C) 2018 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
@@ -28,9 +29,9 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef TextChecking_h
-#define TextChecking_h
+#pragma once
 
+#include <wtf/OptionSet.h>
 #include <wtf/RefCounted.h>
 #include <wtf/Vector.h>
 #include <wtf/text/WTFString.h>
@@ -37,19 +38,22 @@
 
 namespace WebCore {
 
-enum TextCheckingType {
-    TextCheckingTypeNone        = 0,
-    TextCheckingTypeSpelling    = 1 << 1,
-    TextCheckingTypeGrammar     = 1 << 2,
-    TextCheckingTypeLink        = 1 << 5,
-    TextCheckingTypeQuote       = 1 << 6,
-    TextCheckingTypeDash        = 1 << 7,
-    TextCheckingTypeReplacement = 1 << 8,
-    TextCheckingTypeCorrection  = 1 << 9,
-    TextCheckingTypeShowCorrectionPanel = 1 << 10
+enum class TextCheckingType : uint8_t {
+    None = 0,
+    Spelling = 1 << 0,
+    Grammar = 1 << 1,
+    Link = 1 << 2,
+    Quote = 1 << 3,
+    Dash = 1 << 4,
+    Replacement = 1 << 5,
+    Correction = 1 << 6,
+    ShowCorrectionPanel = 1 << 7,
 };
 
-typedef unsigned TextCheckingTypeMask;
+#if PLATFORM(MAC)
+typedef uint64_t NSTextCheckingTypes;
+WEBCORE_EXPORT NSTextCheckingTypes nsTextCheckingTypes(OptionSet<TextCheckingType>);
+#endif
 
 enum TextCheckingProcessType {
     TextCheckingProcessBatch,
@@ -76,28 +80,25 @@
 class TextCheckingRequestData {
     friend class SpellCheckRequest; // For access to m_sequence.
 public:
-    TextCheckingRequestData()
-        : m_sequence(unrequestedTextCheckingSequence)
-        , m_mask(TextCheckingTypeNone)
-        , m_processType(TextCheckingProcessIncremental)
-    { }
-    TextCheckingRequestData(int sequence, const String& text, TextCheckingTypeMask mask, TextCheckingProcessType processType)
-        : m_sequence(sequence)
-        , m_text(text)
-        , m_mask(mask)
-        , m_processType(processType)
-    { }
+    TextCheckingRequestData() = default;
+    TextCheckingRequestData(int sequence, const String& text, OptionSet<TextCheckingType> checkingTypes, TextCheckingProcessType processType)
+        : m_text { text }
+        , m_sequence { sequence }
+        , m_processType { processType }
+        , m_checkingTypes { checkingTypes }
+    {
+    }
 
     int sequence() const { return m_sequence; }
-    String text() const { return m_text; }
-    TextCheckingTypeMask mask() const { return m_mask; }
+    const String& text() const { return m_text; }
+    OptionSet<TextCheckingType> checkingTypes() const { return m_checkingTypes; }
     TextCheckingProcessType processType() const { return m_processType; }
 
 private:
-    int m_sequence;
     String m_text;
-    TextCheckingTypeMask m_mask;
-    TextCheckingProcessType m_processType;
+    int m_sequence { unrequestedTextCheckingSequence };
+    TextCheckingProcessType m_processType { TextCheckingProcessIncremental };
+    OptionSet<TextCheckingType> m_checkingTypes;
 };
 
 class TextCheckingRequest : public RefCounted<TextCheckingRequest> {
@@ -110,5 +111,3 @@
 };
 
 }
-
-#endif // TextChecking_h

Added: releases/WebKitGTK/webkit-2.22/Source/WebCore/platform/text/mac/TextCheckingMac.mm (0 => 235299)


--- releases/WebKitGTK/webkit-2.22/Source/WebCore/platform/text/mac/TextCheckingMac.mm	                        (rev 0)
+++ releases/WebKitGTK/webkit-2.22/Source/WebCore/platform/text/mac/TextCheckingMac.mm	2018-08-24 08:09:35 UTC (rev 235299)
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2018 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 "config.h"
+#import "TextChecking.h"
+
+#if PLATFORM(MAC)
+
+#import <Foundation/Foundation.h>
+
+namespace WebCore {
+
+NSTextCheckingTypes nsTextCheckingTypes(OptionSet<TextCheckingType> types)
+{
+    NSTextCheckingTypes mask = 0;
+    if (types.contains(TextCheckingType::Spelling))
+        mask |= NSTextCheckingTypeSpelling;
+    if (types.contains(TextCheckingType::Grammar))
+        mask |= NSTextCheckingTypeGrammar;
+    if (types.contains(TextCheckingType::Link))
+        mask |= NSTextCheckingTypeLink;
+    if (types.contains(TextCheckingType::Quote))
+        mask |= NSTextCheckingTypeQuote;
+    if (types.contains(TextCheckingType::Dash))
+        mask |= NSTextCheckingTypeDash;
+    if (types.contains(TextCheckingType::Replacement))
+        mask |= NSTextCheckingTypeReplacement;
+    if (types.contains(TextCheckingType::Correction))
+        mask |= NSTextCheckingTypeCorrection;
+    return mask;
+}
+
+} // namespace WebCore
+
+#endif // PLATFORM(MAC)

Modified: releases/WebKitGTK/webkit-2.22/Source/WebCore/testing/Internals.cpp (235298 => 235299)


--- releases/WebKitGTK/webkit-2.22/Source/WebCore/testing/Internals.cpp	2018-08-24 08:09:07 UTC (rev 235298)
+++ releases/WebKitGTK/webkit-2.22/Source/WebCore/testing/Internals.cpp	2018-08-24 08:09:35 UTC (rev 235299)
@@ -2195,7 +2195,7 @@
         return;
 
     TextCheckingResult result;
-    result.type = TextCheckingTypeNone;
+    result.type = TextCheckingType::None;
     result.location = location;
     result.length = length;
     result.replacement = candidate;

Modified: releases/WebKitGTK/webkit-2.22/Source/WebKit/ChangeLog (235298 => 235299)


--- releases/WebKitGTK/webkit-2.22/Source/WebKit/ChangeLog	2018-08-24 08:09:07 UTC (rev 235298)
+++ releases/WebKitGTK/webkit-2.22/Source/WebKit/ChangeLog	2018-08-24 08:09:35 UTC (rev 235299)
@@ -1,3 +1,37 @@
+2018-08-21  Daniel Bates  <daba...@apple.com>
+
+        Replace TextCheckingTypeMask with OptionSet
+        https://bugs.webkit.org/show_bug.cgi?id=188678
+
+        Reviewed by Antti Koivisto.
+
+        * Scripts/webkit/messages.py: Add WebCore::TextCheckingType to the special case map so that
+        the generator knows what header has the definition for this type.
+        * Shared/WebCoreArgumentCoders.cpp:
+        (IPC::ArgumentCoder<TextCheckingRequestData>::encode):
+        (IPC::ArgumentCoder<TextCheckingRequestData>::decode):
+        * UIProcess/Cocoa/WebViewImpl.mm:
+        (WebKit::coreTextCheckingType):
+        (WebKit::textCheckingResultFromNSTextCheckingResult):
+        * UIProcess/TextChecker.h:
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::checkTextOfParagraph):
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebPageProxy.messages.in:
+        * UIProcess/gtk/TextCheckerGtk.cpp:
+        (WebKit::TextChecker::requestCheckingOfString):
+        (WebKit::TextChecker::checkTextOfParagraph): Also simplified return expressions.
+        * UIProcess/ios/TextCheckerIOS.mm:
+        (WebKit::TextChecker::checkTextOfParagraph):
+        * UIProcess/mac/TextCheckerMac.mm:
+        (WebKit::TextChecker::checkTextOfParagraph):
+        * UIProcess/win/TextCheckerWin.cpp:
+        (WebKit::TextChecker::checkTextOfParagraph):
+        * WebProcess/WebCoreSupport/WebEditorClient.cpp:
+        (WebKit::WebEditorClient::shouldEraseMarkersAfterChangeSelection const):
+        (WebKit::WebEditorClient::checkTextOfParagraph):
+        * WebProcess/WebCoreSupport/WebEditorClient.h:
+
 2018-08-20  Michael Catanzaro  <mcatanz...@igalia.com>
 
         Use unified build for NetworkProcess

Modified: releases/WebKitGTK/webkit-2.22/Source/WebKit/Scripts/webkit/messages.py (235298 => 235299)


--- releases/WebKitGTK/webkit-2.22/Source/WebKit/Scripts/webkit/messages.py	2018-08-24 08:09:07 UTC (rev 235298)
+++ releases/WebKitGTK/webkit-2.22/Source/WebKit/Scripts/webkit/messages.py	2018-08-24 08:09:35 UTC (rev 235299)
@@ -414,6 +414,7 @@
         'WebCore::SupportedPluginIdentifier': ['<WebCore/PluginData.h>'],
         'WebCore::TextCheckingRequestData': ['<WebCore/TextChecking.h>'],
         'WebCore::TextCheckingResult': ['<WebCore/TextCheckerClient.h>'],
+        'WebCore::TextCheckingType': ['<WebCore/TextChecking.h>'],
         'WebCore::TextIndicatorData': ['<WebCore/TextIndicator.h>'],
         'WebCore::ViewportAttributes': ['<WebCore/ViewportArguments.h>'],
         'WebCore::SelectionRect': ['"EditorState.h"'],

Modified: releases/WebKitGTK/webkit-2.22/Source/WebKit/Shared/WebCoreArgumentCoders.cpp (235298 => 235299)


--- releases/WebKitGTK/webkit-2.22/Source/WebKit/Shared/WebCoreArgumentCoders.cpp	2018-08-24 08:09:07 UTC (rev 235298)
+++ releases/WebKitGTK/webkit-2.22/Source/WebKit/Shared/WebCoreArgumentCoders.cpp	2018-08-24 08:09:35 UTC (rev 235299)
@@ -1947,7 +1947,7 @@
 {
     encoder << request.sequence();
     encoder << request.text();
-    encoder << request.mask();
+    encoder << request.checkingTypes();
     encoder.encodeEnum(request.processType());
 }
 
@@ -1961,8 +1961,8 @@
     if (!decoder.decode(text))
         return false;
 
-    TextCheckingTypeMask mask;
-    if (!decoder.decode(mask))
+    OptionSet<TextCheckingType> checkingTypes;
+    if (!decoder.decode(checkingTypes))
         return false;
 
     TextCheckingProcessType processType;
@@ -1969,7 +1969,7 @@
     if (!decoder.decodeEnum(processType))
         return false;
 
-    request = TextCheckingRequestData(sequence, text, mask, processType);
+    request = TextCheckingRequestData { sequence, text, checkingTypes, processType };
     return true;
 }
 

Modified: releases/WebKitGTK/webkit-2.22/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm (235298 => 235299)


--- releases/WebKitGTK/webkit-2.22/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm	2018-08-24 08:09:07 UTC (rev 235298)
+++ releases/WebKitGTK/webkit-2.22/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm	2018-08-24 08:09:35 UTC (rev 235299)
@@ -3090,31 +3090,29 @@
 #endif
 }
 
-static WebCore::TextCheckingResult textCheckingResultFromNSTextCheckingResult(NSTextCheckingResult *nsResult)
+static constexpr WebCore::TextCheckingType coreTextCheckingType(NSTextCheckingType type)
 {
-    WebCore::TextCheckingResult result;
-
-    // FIXME: Right now we only request candidates for spelling, replacement, and correction, but we plan to
-    // support more types, and we will have to update this at that time.
-    switch ([nsResult resultType]) {
+    switch (type) {
+    case NSTextCheckingTypeCorrection:
+        return WebCore::TextCheckingType::Correction;
+    case NSTextCheckingTypeReplacement:
+        return WebCore::TextCheckingType::Replacement;
     case NSTextCheckingTypeSpelling:
-        result.type = WebCore::TextCheckingTypeSpelling;
-        break;
-    case NSTextCheckingTypeReplacement:
-        result.type = WebCore::TextCheckingTypeReplacement;
-        break;
-    case NSTextCheckingTypeCorrection:
-        result.type = WebCore::TextCheckingTypeCorrection;
-        break;
+        return WebCore::TextCheckingType::Spelling;
     default:
-        result.type = WebCore::TextCheckingTypeNone;
+        return WebCore::TextCheckingType::None;
     }
+}
 
+static WebCore::TextCheckingResult textCheckingResultFromNSTextCheckingResult(NSTextCheckingResult *nsResult)
+{
     NSRange resultRange = [nsResult range];
+
+    WebCore::TextCheckingResult result;
+    result.type = coreTextCheckingType(nsResult.resultType);
     result.location = resultRange.location;
     result.length = resultRange.length;
-    result.replacement = [nsResult replacementString];
-
+    result.replacement = nsResult.replacementString;
     return result;
 }
 

Modified: releases/WebKitGTK/webkit-2.22/Source/WebKit/UIProcess/TextChecker.h (235298 => 235299)


--- releases/WebKitGTK/webkit-2.22/Source/WebKit/UIProcess/TextChecker.h	2018-08-24 08:09:07 UTC (rev 235298)
+++ releases/WebKitGTK/webkit-2.22/Source/WebKit/UIProcess/TextChecker.h	2018-08-24 08:09:35 UTC (rev 235299)
@@ -74,7 +74,7 @@
     static int64_t uniqueSpellDocumentTag(WebPageProxy*);
     static void closeSpellDocumentWithTag(int64_t);
 #if USE(UNIFIED_TEXT_CHECKING)
-    static Vector<WebCore::TextCheckingResult> checkTextOfParagraph(int64_t spellDocumentTag, StringView text, int32_t insertionPoint, uint64_t checkingTypes, bool initialCapitalizationEnabled);
+    static Vector<WebCore::TextCheckingResult> checkTextOfParagraph(int64_t spellDocumentTag, StringView, int32_t insertionPoint, OptionSet<WebCore::TextCheckingType>, bool initialCapitalizationEnabled);
 #endif
     static void checkSpellingOfString(int64_t spellDocumentTag, StringView text, int32_t& misspellingLocation, int32_t& misspellingLength);
     static void checkGrammarOfString(int64_t spellDocumentTag, StringView text, Vector<WebCore::GrammarDetail>&, int32_t& badGrammarLocation, int32_t& badGrammarLength);

Modified: releases/WebKitGTK/webkit-2.22/Source/WebKit/UIProcess/WebPageProxy.cpp (235298 => 235299)


--- releases/WebKitGTK/webkit-2.22/Source/WebKit/UIProcess/WebPageProxy.cpp	2018-08-24 08:09:07 UTC (rev 235298)
+++ releases/WebKitGTK/webkit-2.22/Source/WebKit/UIProcess/WebPageProxy.cpp	2018-08-24 08:09:35 UTC (rev 235299)
@@ -5337,7 +5337,7 @@
 }
 
 #if USE(UNIFIED_TEXT_CHECKING)
-void WebPageProxy::checkTextOfParagraph(const String& text, uint64_t checkingTypes, int32_t insertionPoint, Vector<TextCheckingResult>& results)
+void WebPageProxy::checkTextOfParagraph(const String& text, OptionSet<TextCheckingType> checkingTypes, int32_t insertionPoint, Vector<TextCheckingResult>& results)
 {
     results = TextChecker::checkTextOfParagraph(spellDocumentTag(), text, insertionPoint, checkingTypes, m_initialCapitalizationEnabled);
 }

Modified: releases/WebKitGTK/webkit-2.22/Source/WebKit/UIProcess/WebPageProxy.h (235298 => 235299)


--- releases/WebKitGTK/webkit-2.22/Source/WebKit/UIProcess/WebPageProxy.h	2018-08-24 08:09:07 UTC (rev 235298)
+++ releases/WebKitGTK/webkit-2.22/Source/WebKit/UIProcess/WebPageProxy.h	2018-08-24 08:09:35 UTC (rev 235299)
@@ -1217,7 +1217,7 @@
 #endif
 
 #if USE(UNIFIED_TEXT_CHECKING)
-    void checkTextOfParagraph(const String& text, uint64_t checkingTypes, int32_t insertionPoint, Vector<WebCore::TextCheckingResult>& results);
+    void checkTextOfParagraph(const String& text, OptionSet<WebCore::TextCheckingType> checkingTypes, int32_t insertionPoint, Vector<WebCore::TextCheckingResult>& results);
 #endif
     void getGuessesForWord(const String& word, const String& context, int32_t insertionPoint, Vector<String>& guesses);
 

Modified: releases/WebKitGTK/webkit-2.22/Source/WebKit/UIProcess/WebPageProxy.messages.in (235298 => 235299)


--- releases/WebKitGTK/webkit-2.22/Source/WebKit/UIProcess/WebPageProxy.messages.in	2018-08-24 08:09:07 UTC (rev 235298)
+++ releases/WebKitGTK/webkit-2.22/Source/WebKit/UIProcess/WebPageProxy.messages.in	2018-08-24 08:09:35 UTC (rev 235299)
@@ -298,7 +298,7 @@
 
     # Spelling and grammar messages
 #if USE(UNIFIED_TEXT_CHECKING)  
-    CheckTextOfParagraph(String text, uint64_t checkingTypes, int32_t insertionPoint) -> (Vector<WebCore::TextCheckingResult> results)
+    CheckTextOfParagraph(String text, OptionSet<WebCore::TextCheckingType> checkingTypes, int32_t insertionPoint) -> (Vector<WebCore::TextCheckingResult> results)
 #endif
     CheckSpellingOfString(String text) -> (int32_t misspellingLocation, int32_t misspellingLength)
     CheckGrammarOfString(String text) -> (Vector<WebCore::GrammarDetail> results, int32_t badGrammarLocation, int32_t badGrammarLength)

Modified: releases/WebKitGTK/webkit-2.22/Source/WebKit/UIProcess/gtk/TextCheckerGtk.cpp (235298 => 235299)


--- releases/WebKitGTK/webkit-2.22/Source/WebKit/UIProcess/gtk/TextCheckerGtk.cpp	2018-08-24 08:09:07 UTC (rev 235298)
+++ releases/WebKitGTK/webkit-2.22/Source/WebKit/UIProcess/gtk/TextCheckerGtk.cpp	2018-08-24 08:09:35 UTC (rev 235299)
@@ -203,9 +203,9 @@
 #if ENABLE(SPELLCHECK)
     TextCheckingRequestData request = completion->textCheckingRequestData();
     ASSERT(request.sequence() != unrequestedTextCheckingSequence);
-    ASSERT(request.mask() != TextCheckingTypeNone);
+    ASSERT(request.checkingTypes());
 
-    completion->didFinishCheckingText(checkTextOfParagraph(completion->spellDocumentTag(), request.text(), insertionPoint, request.mask(), false));
+    completion->didFinishCheckingText(checkTextOfParagraph(completion->spellDocumentTag(), request.text(), insertionPoint, request.checkingTypes(), false));
 #else
     UNUSED_PARAM(completion);
 #endif
@@ -240,16 +240,16 @@
 #endif
 
 #if USE(UNIFIED_TEXT_CHECKING)
-Vector<TextCheckingResult> TextChecker::checkTextOfParagraph(int64_t spellDocumentTag, StringView text, int32_t insertionPoint, uint64_t checkingTypes, bool)
+Vector<TextCheckingResult> TextChecker::checkTextOfParagraph(int64_t spellDocumentTag, StringView text, int32_t insertionPoint, OptionSet<TextCheckingType> checkingTypes, bool)
 {
     UNUSED_PARAM(insertionPoint);
 #if ENABLE(SPELLCHECK)
-    if (!(checkingTypes & TextCheckingTypeSpelling))
-        return Vector<TextCheckingResult>();
+    if (!checkingTypes.contains(TextCheckingType::Spelling))
+        return { };
 
     UBreakIterator* textIterator = wordBreakIterator(text);
     if (!textIterator)
-        return Vector<TextCheckingResult>();
+        return { };
 
     // Omit the word separators at the beginning/end of the text to don't unnecessarily
     // involve the client to check spelling for them.
@@ -267,7 +267,7 @@
             break;
 
         TextCheckingResult misspellingResult;
-        misspellingResult.type = TextCheckingTypeSpelling;
+        misspellingResult.type = TextCheckingType::Spelling;
         misspellingResult.location = offset + misspellingLocation;
         misspellingResult.length = misspellingLength;
         paragraphCheckingResult.append(misspellingResult);

Modified: releases/WebKitGTK/webkit-2.22/Source/WebKit/UIProcess/ios/TextCheckerIOS.mm (235298 => 235299)


--- releases/WebKitGTK/webkit-2.22/Source/WebKit/UIProcess/ios/TextCheckerIOS.mm	2018-08-24 08:09:07 UTC (rev 235298)
+++ releases/WebKitGTK/webkit-2.22/Source/WebKit/UIProcess/ios/TextCheckerIOS.mm	2018-08-24 08:09:35 UTC (rev 235299)
@@ -145,7 +145,7 @@
 
 #if USE(UNIFIED_TEXT_CHECKING)
 
-Vector<TextCheckingResult> TextChecker::checkTextOfParagraph(int64_t, StringView, int32_t, uint64_t, bool)
+Vector<TextCheckingResult> TextChecker::checkTextOfParagraph(int64_t, StringView, int32_t, OptionSet<TextCheckingType>, bool)
 {
     notImplemented();
     return Vector<TextCheckingResult>();

Modified: releases/WebKitGTK/webkit-2.22/Source/WebKit/UIProcess/mac/TextCheckerMac.mm (235298 => 235299)


--- releases/WebKitGTK/webkit-2.22/Source/WebKit/UIProcess/mac/TextCheckerMac.mm	2018-08-24 08:09:07 UTC (rev 235298)
+++ releases/WebKitGTK/webkit-2.22/Source/WebKit/UIProcess/mac/TextCheckerMac.mm	2018-08-24 08:09:35 UTC (rev 235299)
@@ -326,7 +326,7 @@
 
 #if USE(UNIFIED_TEXT_CHECKING)
 
-Vector<TextCheckingResult> TextChecker::checkTextOfParagraph(int64_t spellDocumentTag, StringView text, int32_t insertionPoint, uint64_t checkingTypes, bool initialCapitalizationEnabled)
+Vector<TextCheckingResult> TextChecker::checkTextOfParagraph(int64_t spellDocumentTag, StringView text, int32_t insertionPoint, OptionSet<TextCheckingType> checkingTypes, bool initialCapitalizationEnabled)
 {
     Vector<TextCheckingResult> results;
 
@@ -340,7 +340,7 @@
 #endif
     NSArray *incomingResults = [[NSSpellChecker sharedSpellChecker] checkString:textString.get()
                                                                           range:NSMakeRange(0, text.length())
-                                                                          types:checkingTypes | NSTextCheckingTypeOrthography
+                                                                          types:nsTextCheckingTypes(checkingTypes) | NSTextCheckingTypeOrthography
                                                                         options:options
                                                          inSpellDocumentWithTag:spellDocumentTag 
                                                                     orthography:NULL
@@ -350,16 +350,16 @@
         NSTextCheckingType resultType = [incomingResult resultType];
         ASSERT(resultRange.location != NSNotFound);
         ASSERT(resultRange.length > 0);
-        if (resultType == NSTextCheckingTypeSpelling && (checkingTypes & NSTextCheckingTypeSpelling)) {
+        if (resultType == NSTextCheckingTypeSpelling && checkingTypes.contains(TextCheckingType::Spelling)) {
             TextCheckingResult result;
-            result.type = TextCheckingTypeSpelling;
+            result.type = TextCheckingType::Spelling;
             result.location = resultRange.location;
             result.length = resultRange.length;
             results.append(result);
-        } else if (resultType == NSTextCheckingTypeGrammar && (checkingTypes & NSTextCheckingTypeGrammar)) {
+        } else if (resultType == NSTextCheckingTypeGrammar && checkingTypes.contains(TextCheckingType::Grammar)) {
             TextCheckingResult result;
             NSArray *details = [incomingResult grammarDetails];
-            result.type = TextCheckingTypeGrammar;
+            result.type = TextCheckingType::Grammar;
             result.location = resultRange.location;
             result.length = resultRange.length;
             for (NSDictionary *incomingDetail in details) {
@@ -379,37 +379,37 @@
                 result.details.append(detail);
             }
             results.append(result);
-        } else if (resultType == NSTextCheckingTypeLink && (checkingTypes & NSTextCheckingTypeLink)) {
+        } else if (resultType == NSTextCheckingTypeLink && checkingTypes.contains(TextCheckingType::Link)) {
             TextCheckingResult result;
-            result.type = TextCheckingTypeLink;
+            result.type = TextCheckingType::Link;
             result.location = resultRange.location;
             result.length = resultRange.length;
             result.replacement = [[incomingResult URL] absoluteString];
             results.append(result);
-        } else if (resultType == NSTextCheckingTypeQuote && (checkingTypes & NSTextCheckingTypeQuote)) {
+        } else if (resultType == NSTextCheckingTypeQuote && checkingTypes.contains(TextCheckingType::Quote)) {
             TextCheckingResult result;
-            result.type = TextCheckingTypeQuote;
+            result.type = TextCheckingType::Quote;
             result.location = resultRange.location;
             result.length = resultRange.length;
             result.replacement = [incomingResult replacementString];
             results.append(result);
-        } else if (resultType == NSTextCheckingTypeDash && (checkingTypes & NSTextCheckingTypeDash)) {
+        } else if (resultType == NSTextCheckingTypeDash && checkingTypes.contains(TextCheckingType::Dash)) {
             TextCheckingResult result;
-            result.type = TextCheckingTypeDash;
+            result.type = TextCheckingType::Dash;
             result.location = resultRange.location;
             result.length = resultRange.length;
             result.replacement = [incomingResult replacementString];
             results.append(result);
-        } else if (resultType == NSTextCheckingTypeReplacement && (checkingTypes & NSTextCheckingTypeReplacement)) {
+        } else if (resultType == NSTextCheckingTypeReplacement && checkingTypes.contains(TextCheckingType::Replacement)) {
             TextCheckingResult result;
-            result.type = TextCheckingTypeReplacement;
+            result.type = TextCheckingType::Replacement;
             result.location = resultRange.location;
             result.length = resultRange.length;
             result.replacement = [incomingResult replacementString];
             results.append(result);
-        } else if (resultType == NSTextCheckingTypeCorrection && (checkingTypes & NSTextCheckingTypeCorrection)) {
+        } else if (resultType == NSTextCheckingTypeCorrection && checkingTypes.contains(TextCheckingType::Correction)) {
             TextCheckingResult result;
-            result.type = TextCheckingTypeCorrection;
+            result.type = TextCheckingType::Correction;
             result.location = resultRange.location;
             result.length = resultRange.length;
             result.replacement = [incomingResult replacementString];
@@ -420,7 +420,7 @@
     return results;
 }
 
-#endif
+#endif // USE(UNIFIED_TEXT_CHECKING)
 
 void TextChecker::checkSpellingOfString(int64_t, StringView, int32_t&, int32_t&)
 {

Modified: releases/WebKitGTK/webkit-2.22/Source/WebKit/UIProcess/win/TextCheckerWin.cpp (235298 => 235299)


--- releases/WebKitGTK/webkit-2.22/Source/WebKit/UIProcess/win/TextCheckerWin.cpp	2018-08-24 08:09:07 UTC (rev 235298)
+++ releases/WebKitGTK/webkit-2.22/Source/WebKit/UIProcess/win/TextCheckerWin.cpp	2018-08-24 08:09:35 UTC (rev 235299)
@@ -129,10 +129,12 @@
 }
 
 #if USE(UNIFIED_TEXT_CHECKING)
-Vector<TextCheckingResult> TextChecker::checkTextOfParagraph(int64_t, StringView, int32_t, uint64_t, bool)
+
+Vector<TextCheckingResult> TextChecker::checkTextOfParagraph(int64_t, StringView, int32_t, OptionSet<TextCheckingType>, bool)
 {
-    return Vector<TextCheckingResult>();
+    return { };
 }
-#endif // USE(UNIFIED_TEXT_CHECKING)
 
+#endif
+
 } // namespace WebKit

Modified: releases/WebKitGTK/webkit-2.22/Source/WebKit/WebProcess/WebCoreSupport/WebEditorClient.cpp (235298 => 235299)


--- releases/WebKitGTK/webkit-2.22/Source/WebKit/WebProcess/WebCoreSupport/WebEditorClient.cpp	2018-08-24 08:09:07 UTC (rev 235298)
+++ releases/WebKitGTK/webkit-2.22/Source/WebKit/WebProcess/WebCoreSupport/WebEditorClient.cpp	2018-08-24 08:09:35 UTC (rev 235299)
@@ -467,7 +467,7 @@
 {
     // This prevents erasing spelling markers on OS X Lion or later to match AppKit on these Mac OS X versions.
 #if PLATFORM(COCOA)
-    return type != TextCheckingTypeSpelling;
+    return type != TextCheckingType::Spelling;
 #else
     UNUSED_PARAM(type);
     return true;
@@ -518,12 +518,10 @@
 }
 
 #if USE(UNIFIED_TEXT_CHECKING)
-Vector<TextCheckingResult> WebEditorClient::checkTextOfParagraph(StringView stringView, WebCore::TextCheckingTypeMask checkingTypes, const VisibleSelection& currentSelection)
+Vector<TextCheckingResult> WebEditorClient::checkTextOfParagraph(StringView stringView, OptionSet<WebCore::TextCheckingType> checkingTypes, const VisibleSelection& currentSelection)
 {
     Vector<TextCheckingResult> results;
-
     m_page->sendSync(Messages::WebPageProxy::CheckTextOfParagraph(stringView.toStringWithoutCopying(), checkingTypes, insertionPointFromCurrentSelection(currentSelection)), Messages::WebPageProxy::CheckTextOfParagraph::Reply(results));
-
     return results;
 }
 #endif

Modified: releases/WebKitGTK/webkit-2.22/Source/WebKit/WebProcess/WebCoreSupport/WebEditorClient.h (235298 => 235299)


--- releases/WebKitGTK/webkit-2.22/Source/WebKit/WebProcess/WebCoreSupport/WebEditorClient.h	2018-08-24 08:09:07 UTC (rev 235298)
+++ releases/WebKitGTK/webkit-2.22/Source/WebKit/WebProcess/WebCoreSupport/WebEditorClient.h	2018-08-24 08:09:35 UTC (rev 235299)
@@ -143,7 +143,7 @@
     void checkGrammarOfString(StringView, Vector<WebCore::GrammarDetail>&, int* badGrammarLocation, int* badGrammarLength) final;
 
 #if USE(UNIFIED_TEXT_CHECKING)
-    Vector<WebCore::TextCheckingResult> checkTextOfParagraph(StringView, WebCore::TextCheckingTypeMask checkingTypes, const WebCore::VisibleSelection& currentSelection) final;
+    Vector<WebCore::TextCheckingResult> checkTextOfParagraph(StringView, OptionSet<WebCore::TextCheckingType> checkingTypes, const WebCore::VisibleSelection& currentSelection) final;
 #endif
 
     void updateSpellingUIWithGrammarString(const String&, const WebCore::GrammarDetail&) final;

Modified: releases/WebKitGTK/webkit-2.22/Source/WebKitLegacy/mac/ChangeLog (235298 => 235299)


--- releases/WebKitGTK/webkit-2.22/Source/WebKitLegacy/mac/ChangeLog	2018-08-24 08:09:07 UTC (rev 235298)
+++ releases/WebKitGTK/webkit-2.22/Source/WebKitLegacy/mac/ChangeLog	2018-08-24 08:09:35 UTC (rev 235299)
@@ -1,3 +1,27 @@
+2018-08-21  Daniel Bates  <daba...@apple.com>
+
+        Replace TextCheckingTypeMask with OptionSet
+        https://bugs.webkit.org/show_bug.cgi?id=188678
+
+        Reviewed by Antti Koivisto.
+
+        Currently we have code in WebEditorClient::checkTextOfParagraph() that incorrectly assumes
+        that the enumerators of TextCheckingType have a one-to-one correspondence with NSTextCheckingType.
+        (This is not the case because there is not corresponding NSTextCheckingType for TextCheckingTypeShowCorrectionPanel).
+        We now explicitly convert from OptionSet<TextCheckingType> to NSTextCheckingTypes.
+
+        * WebCoreSupport/WebEditorClient.h:
+        * WebCoreSupport/WebEditorClient.mm:
+        (WebEditorClient::checkTextOfParagraph):
+        (WebEditorClient::shouldEraseMarkersAfterChangeSelection const):
+        (core): Fix up code style nits; compare resultType on the right-hand side instead of the
+        left as this is more readable and unncessary now that modern compilers like Clang have
+        diagnostics to catch accidental assignments when equality was intended.
+        (WebEditorClient::didCheckSucceed):
+        * WebView/WebView.mm:
+        (coreTextCheckingType):
+        (textCheckingResultFromNSTextCheckingResult):
+
 2018-08-16  Ryosuke Niwa  <rn...@webkit.org>
 
         Replace canBubble and cancelable booleans in Event by enum classes

Modified: releases/WebKitGTK/webkit-2.22/Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.h (235298 => 235299)


--- releases/WebKitGTK/webkit-2.22/Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.h	2018-08-24 08:09:07 UTC (rev 235298)
+++ releases/WebKitGTK/webkit-2.22/Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.h	2018-08-24 08:09:35 UTC (rev 235299)
@@ -154,7 +154,7 @@
     void checkSpellingOfString(StringView, int* misspellingLocation, int* misspellingLength) final;
     String getAutoCorrectSuggestionForMisspelledWord(const String&) final;
     void checkGrammarOfString(StringView, Vector<WebCore::GrammarDetail>&, int* badGrammarLocation, int* badGrammarLength) final;
-    Vector<WebCore::TextCheckingResult> checkTextOfParagraph(StringView, WebCore::TextCheckingTypeMask checkingTypes, const WebCore::VisibleSelection& currentSelection) final;
+    Vector<WebCore::TextCheckingResult> checkTextOfParagraph(StringView, OptionSet<WebCore::TextCheckingType> checkingTypes, const WebCore::VisibleSelection& currentSelection) final;
     void updateSpellingUIWithGrammarString(const String&, const WebCore::GrammarDetail&) final;
     void updateSpellingUIWithMisspelledWord(const String&) final;
     void showSpellingUI(bool show) final;

Modified: releases/WebKitGTK/webkit-2.22/Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.mm (235298 => 235299)


--- releases/WebKitGTK/webkit-2.22/Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.mm	2018-08-24 08:09:07 UTC (rev 235298)
+++ releases/WebKitGTK/webkit-2.22/Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.mm	2018-08-24 08:09:35 UTC (rev 235299)
@@ -933,9 +933,9 @@
     return false;
 }
 
-Vector<TextCheckingResult> WebEditorClient::checkTextOfParagraph(StringView string, TextCheckingTypeMask checkingTypes, const VisibleSelection&)
+Vector<TextCheckingResult> WebEditorClient::checkTextOfParagraph(StringView string, OptionSet<TextCheckingType> checkingTypes, const VisibleSelection&)
 {
-    ASSERT(checkingTypes & NSTextCheckingTypeSpelling);
+    ASSERT(checkingTypes.contains(TextCheckingType::Spelling));
 
     Vector<TextCheckingResult> results;
 
@@ -944,7 +944,7 @@
         NSRange resultRange = [incomingResult rangeValue];
         ASSERT(resultRange.location != NSNotFound && resultRange.length > 0);
         TextCheckingResult result;
-        result.type = TextCheckingTypeSpelling;
+        result.type = TextCheckingType::Spelling;
         result.location = resultRange.location;
         result.length = resultRange.length;
         results.append(result);
@@ -965,7 +965,7 @@
 bool WebEditorClient::shouldEraseMarkersAfterChangeSelection(TextCheckingType type) const
 {
     // This prevents erasing spelling markers on OS X Lion or later to match AppKit on these Mac OS X versions.
-    return type != TextCheckingTypeSpelling;
+    return type != TextCheckingType::Spelling;
 }
 
 void WebEditorClient::ignoreWordInSpellDocument(const String& text)
@@ -1028,7 +1028,7 @@
     }
 }
 
-static Vector<TextCheckingResult> core(NSArray *incomingResults, TextCheckingTypeMask checkingTypes)
+static Vector<TextCheckingResult> core(NSArray *incomingResults, OptionSet<TextCheckingType> checkingTypes)
 {
     Vector<TextCheckingResult> results;
 
@@ -1037,16 +1037,16 @@
         NSTextCheckingType resultType = [incomingResult resultType];
         ASSERT(resultRange.location != NSNotFound);
         ASSERT(resultRange.length > 0);
-        if (NSTextCheckingTypeSpelling == resultType && 0 != (checkingTypes & NSTextCheckingTypeSpelling)) {
+        if (resultType == NSTextCheckingTypeSpelling && checkingTypes.contains(TextCheckingType::Spelling)) {
             TextCheckingResult result;
-            result.type = TextCheckingTypeSpelling;
+            result.type = TextCheckingType::Spelling;
             result.location = resultRange.location;
             result.length = resultRange.length;
             results.append(result);
-        } else if (NSTextCheckingTypeGrammar == resultType && 0 != (checkingTypes & NSTextCheckingTypeGrammar)) {
+        } else if (resultType == NSTextCheckingTypeGrammar && checkingTypes.contains(TextCheckingType::Grammar)) {
             TextCheckingResult result;
             NSArray *details = [incomingResult grammarDetails];
-            result.type = TextCheckingTypeGrammar;
+            result.type = TextCheckingType::Grammar;
             result.location = resultRange.location;
             result.length = resultRange.length;
             for (NSDictionary *incomingDetail in details) {
@@ -1066,37 +1066,37 @@
                 result.details.append(detail);
             }
             results.append(result);
-        } else if (NSTextCheckingTypeLink == resultType && 0 != (checkingTypes & NSTextCheckingTypeLink)) {
+        } else if (resultType == NSTextCheckingTypeLink && checkingTypes.contains(TextCheckingType::Link)) {
             TextCheckingResult result;
-            result.type = TextCheckingTypeLink;
+            result.type = TextCheckingType::Link;
             result.location = resultRange.location;
             result.length = resultRange.length;
             result.replacement = [[incomingResult URL] absoluteString];
             results.append(result);
-        } else if (NSTextCheckingTypeQuote == resultType && 0 != (checkingTypes & NSTextCheckingTypeQuote)) {
+        } else if (resultType == NSTextCheckingTypeQuote && checkingTypes.contains(TextCheckingType::Quote)) {
             TextCheckingResult result;
-            result.type = TextCheckingTypeQuote;
+            result.type = TextCheckingType::Quote;
             result.location = resultRange.location;
             result.length = resultRange.length;
             result.replacement = [incomingResult replacementString];
             results.append(result);
-        } else if (NSTextCheckingTypeDash == resultType && 0 != (checkingTypes & NSTextCheckingTypeDash)) {
+        } else if (resultType == NSTextCheckingTypeDash && checkingTypes.contains(TextCheckingType::Dash)) {
             TextCheckingResult result;
-            result.type = TextCheckingTypeDash;
+            result.type = TextCheckingType::Dash;
             result.location = resultRange.location;
             result.length = resultRange.length;
             result.replacement = [incomingResult replacementString];
             results.append(result);
-        } else if (NSTextCheckingTypeReplacement == resultType && 0 != (checkingTypes & NSTextCheckingTypeReplacement)) {
+        } else if (resultType == NSTextCheckingTypeReplacement && checkingTypes.contains(TextCheckingType::Replacement)) {
             TextCheckingResult result;
-            result.type = TextCheckingTypeReplacement;
+            result.type = TextCheckingType::Replacement;
             result.location = resultRange.location;
             result.length = resultRange.length;
             result.replacement = [incomingResult replacementString];
             results.append(result);
-        } else if (NSTextCheckingTypeCorrection == resultType && 0 != (checkingTypes & NSTextCheckingTypeCorrection)) {
+        } else if (resultType == NSTextCheckingTypeCorrection && checkingTypes.contains(TextCheckingType::Correction)) {
             TextCheckingResult result;
-            result.type = TextCheckingTypeCorrection;
+            result.type = TextCheckingType::Correction;
             result.location = resultRange.location;
             result.length = resultRange.length;
             result.replacement = [incomingResult replacementString];
@@ -1116,13 +1116,13 @@
 }
 #endif
 
-Vector<TextCheckingResult> WebEditorClient::checkTextOfParagraph(StringView string, TextCheckingTypeMask checkingTypes, const VisibleSelection& currentSelection)
+Vector<TextCheckingResult> WebEditorClient::checkTextOfParagraph(StringView string, OptionSet<TextCheckingType> coreCheckingTypes, const VisibleSelection& currentSelection)
 {
     NSDictionary *options = nil;
 #if HAVE(ADVANCED_SPELL_CHECKING)
     options = @{ NSTextCheckingInsertionPointKey :  [NSNumber numberWithUnsignedInteger:insertionPointFromCurrentSelection(currentSelection)] };
 #endif
-    return core([[NSSpellChecker sharedSpellChecker] checkString:string.createNSStringWithoutCopying().get() range:NSMakeRange(0, string.length()) types:(checkingTypes | NSTextCheckingTypeOrthography) options:options inSpellDocumentWithTag:spellCheckerDocumentTag() orthography:NULL wordCount:NULL], checkingTypes);
+    return core([[NSSpellChecker sharedSpellChecker] checkString:string.createNSStringWithoutCopying().get() range:NSMakeRange(0, string.length()) types:(nsTextCheckingTypes(coreCheckingTypes) | NSTextCheckingTypeOrthography) options:options inSpellDocumentWithTag:spellCheckerDocumentTag() orthography:NULL wordCount:NULL], coreCheckingTypes);
 }
 
 void WebEditorClient::updateSpellingUIWithGrammarString(const String& badGrammarPhrase, const GrammarDetail& grammarDetail)
@@ -1327,7 +1327,7 @@
 void WebEditorClient::didCheckSucceed(int sequence, NSArray* results)
 {
     ASSERT_UNUSED(sequence, sequence == m_textCheckingRequest->data().sequence());
-    m_textCheckingRequest->didSucceed(core(results, m_textCheckingRequest->data().mask()));
+    m_textCheckingRequest->didSucceed(core(results, m_textCheckingRequest->data().checkingTypes()));
     m_textCheckingRequest = nullptr;
 }
 

Modified: releases/WebKitGTK/webkit-2.22/Source/WebKitLegacy/mac/WebView/WebView.mm (235298 => 235299)


--- releases/WebKitGTK/webkit-2.22/Source/WebKitLegacy/mac/WebView/WebView.mm	2018-08-24 08:09:07 UTC (rev 235298)
+++ releases/WebKitGTK/webkit-2.22/Source/WebKitLegacy/mac/WebView/WebView.mm	2018-08-24 08:09:35 UTC (rev 235299)
@@ -7282,29 +7282,29 @@
     return nil;
 }
 
-static TextCheckingResult textCheckingResultFromNSTextCheckingResult(NSTextCheckingResult *nsResult)
+constexpr TextCheckingType coreTextCheckingType(NSTextCheckingType type)
 {
-    WebCore::TextCheckingResult result;
-
-    switch ([nsResult resultType]) {
+    switch (type) {
+    case NSTextCheckingTypeCorrection:
+        return TextCheckingType::Correction;
+    case NSTextCheckingTypeReplacement:
+        return TextCheckingType::Replacement;
     case NSTextCheckingTypeSpelling:
-        result.type = WebCore::TextCheckingTypeSpelling;
-        break;
-    case NSTextCheckingTypeReplacement:
-        result.type = WebCore::TextCheckingTypeReplacement;
-        break;
-    case NSTextCheckingTypeCorrection:
-        result.type = WebCore::TextCheckingTypeCorrection;
-        break;
+        return TextCheckingType::Spelling;
     default:
-        result.type = WebCore::TextCheckingTypeNone;
+        return TextCheckingType::None;
     }
+}
 
+static TextCheckingResult textCheckingResultFromNSTextCheckingResult(NSTextCheckingResult *nsResult)
+{
     NSRange resultRange = nsResult.range;
+
+    TextCheckingResult result;
+    result.type = coreTextCheckingType(nsResult.resultType);
     result.location = resultRange.location;
     result.length = resultRange.length;
     result.replacement = nsResult.replacementString;
-
     return result;
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to