WebKit Bugzilla
Attachment 347313 Details for
Bug 188678
: Replace TextCheckingTypeMask with OptionSet
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-188678-20180816153158.patch (text/plain), 72.04 KB, created by
Daniel Bates
on 2018-08-16 15:31:59 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Daniel Bates
Created:
2018-08-16 15:31:59 PDT
Size:
72.04 KB
patch
obsolete
>Subversion Revision: 234848 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 6eb7da9f613a06de1b4518e02133c48f9bc75bcd..add43cb91713e7f79a0961c2441e9a53ca62007c 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,48 @@ >+2018-08-16 Daniel Bates <dabates@apple.com> >+ >+ Make TextCheckingTypeMask an OptionSet >+ https://bugs.webkit.org/show_bug.cgi?id=188678 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Make TextCheckingTypeMask 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): >+ (WebCore::Editor::markMisspellingsAndBadGrammar): >+ (WebCore::Editor::updateMarkersForWordsAffectedByEditing): >+ (WebCore::Editor::editorUIUpdateTimerFired): >+ (WebCore::Editor::resolveTextCheckingTypeMask): >+ * editing/SpellChecker.cpp: >+ (WebCore::SpellChecker::didCheckSucceed): >+ * editing/TextCheckingHelper.cpp: >+ (WebCore::findGrammaticalErrors): >+ (WebCore::findMisspellings): >+ (WebCore::TextCheckingHelper::findFirstMisspellingOrBadGrammar): >+ (WebCore::TextCheckingHelper::guessesForMisspelledOrUngrammaticalRange const): >+ (WebCore::checkTextOfParagraph): >+ * platform/text/TextChecking.h: >+ (WebCore::TextCheckingRequestData::TextCheckingRequestData): >+ * platform/text/mac/TextCheckingMac.mm: Added. >+ (WebCore::nsTextCheckingTypes): >+ * testing/Internals.cpp: >+ (WebCore::Internals::handleAcceptedCandidate): >+ > 2018-08-14 Antoine Quint <graouts@apple.com> > > [Web Animations] Crash under AnimationTimeline::cancelOrRemoveDeclarativeAnimation() >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 91b71f7bfc9b73f757f8b74ae88fbfcb4b4f3d2a..edcebb2af21340ea2649f2780c50e1ca43f65c3e 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,29 @@ >+2018-08-16 Daniel Bates <dabates@apple.com> >+ >+ Make TextCheckingTypeMask an OptionSet >+ https://bugs.webkit.org/show_bug.cgi?id=188678 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * Scripts/webkit/messages.py: Add WebCore::TextCheckingType to the special case map so that >+ the generator knows what headers defines this type. >+ * 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/mac/TextCheckerMac.mm: >+ (WebKit::TextChecker::checkTextOfParagraph): >+ * WebProcess/WebCoreSupport/WebEditorClient.cpp: >+ (WebKit::WebEditorClient::shouldEraseMarkersAfterChangeSelection const): >+ (WebKit::WebEditorClient::checkTextOfParagraph): >+ > 2018-08-13 Wenson Hsieh <wenson_hsieh@apple.com> > > [WK2] [macOS] Implement a mechanism to test drag and drop >diff --git a/Source/WebKitLegacy/mac/ChangeLog b/Source/WebKitLegacy/mac/ChangeLog >index 77093f102445849d564e90ff87bad866f1a160df..7b4167dd389e8cbae14b361248c4786ab9061798 100644 >--- a/Source/WebKitLegacy/mac/ChangeLog >+++ b/Source/WebKitLegacy/mac/ChangeLog >@@ -1,3 +1,25 @@ >+2018-08-16 Daniel Bates <dabates@apple.com> >+ >+ Make TextCheckingTypeMask an OptionSet >+ https://bugs.webkit.org/show_bug.cgi?id=188678 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ 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 TextCheckingTypeMask to NSTextCheckingTypes. >+ >+ * 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. >+ * WebView/WebView.mm: >+ (coreTextCheckingType): >+ (textCheckingResultFromNSTextCheckingResult): >+ > 2018-08-13 Alex Christensen <achristensen@webkit.org> > > Use a 1-byte enum class for TextDirection >diff --git a/Source/WebCore/PlatformMac.cmake b/Source/WebCore/PlatformMac.cmake >index e2f95b42635b1be82a89d6955c75946c892aa2e9..0d98396764d28049bbf5cbcd48737b4604761090 100644 >--- a/Source/WebCore/PlatformMac.cmake >+++ b/Source/WebCore/PlatformMac.cmake >@@ -452,6 +452,7 @@ list(APPEND WebCore_SOURCES > > platform/text/mac/LocaleMac.mm > platform/text/mac/TextBoundaries.mm >+ platform/text/mac/TextCheckingMac.mm > platform/text/mac/TextEncodingRegistryMac.mm > > rendering/RenderThemeCocoa.mm >diff --git a/Source/WebCore/SourcesCocoa.txt b/Source/WebCore/SourcesCocoa.txt >index ee9e8b0a1f3175352f25520704533895b3b19b4c..66f7f16bd64f82c432beaed8e70d1b5ff063a517 100644 >--- a/Source/WebCore/SourcesCocoa.txt >+++ b/Source/WebCore/SourcesCocoa.txt >@@ -527,6 +527,7 @@ platform/text/ios/TextEncodingRegistryIOS.mm > > platform/text/mac/LocaleMac.mm > platform/text/mac/TextBoundaries.mm >+platform/text/mac/TextCheckingMac.mm > platform/text/mac/TextEncodingRegistryMac.mm > > rendering/RenderThemeCocoa.mm >diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >index d34f8b009380c32c935e8790b7eddad0898df738..3aea9fae32010dc47c6827ea057bbec498937612 100644 >--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj >+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >@@ -7170,7 +7170,6 @@ > 3FFFF9AC159D9B060020BBD5 /* ViewportStyleResolver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewportStyleResolver.h; sourceTree = "<group>"; }; > 4107908A1FC3E4F20061B27A /* ClientOrigin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ClientOrigin.h; sourceTree = "<group>"; }; > 410B7E711045FAB000D8224F /* JSMessageEventCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMessageEventCustom.cpp; sourceTree = "<group>"; }; >- D2CDB5ED638F43AF86F07AA2 /* JSErrorEventCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSErrorEventCustom.cpp; sourceTree = "<group>"; }; > 41103AA71E39790A00769F03 /* RealtimeOutgoingAudioSource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RealtimeOutgoingAudioSource.cpp; sourceTree = "<group>"; }; > 41103AA71E39790A00769F14 /* RealtimeOutgoingAudioSourceCocoa.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RealtimeOutgoingAudioSourceCocoa.cpp; sourceTree = "<group>"; }; > 41103AA81E39790A00769F03 /* RealtimeOutgoingAudioSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RealtimeOutgoingAudioSource.h; sourceTree = "<group>"; }; >@@ -9256,7 +9255,6 @@ > 71EFCEDA202B388F00D7C411 /* AnimationEffectReadOnly.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AnimationEffectReadOnly.cpp; sourceTree = "<group>"; }; > 71EFCEDB202B389000D7C411 /* KeyframeEffectReadOnly.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = KeyframeEffectReadOnly.idl; sourceTree = "<group>"; }; > 71EFCEDE202B39C700D7C411 /* JSAnimationEffectReadOnlyCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSAnimationEffectReadOnlyCustom.cpp; sourceTree = "<group>"; }; >- A4A69B8BB91B49D0A804C31D /* JSPromiseRejectionEventCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSPromiseRejectionEventCustom.cpp; sourceTree = "<group>"; }; > 71EFCEDF202B3AA100D7C411 /* JSKeyframeEffectReadOnly.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSKeyframeEffectReadOnly.h; sourceTree = "<group>"; }; > 71EFCEE0202B3AA300D7C411 /* JSKeyframeEffectReadOnly.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSKeyframeEffectReadOnly.cpp; sourceTree = "<group>"; }; > 71F936F71DD4F99B00922CC7 /* tracks-support.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = "tracks-support.js"; sourceTree = "<group>"; }; >@@ -11178,6 +11176,7 @@ > A454424D119B3687009BE912 /* RenderMeter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderMeter.h; sourceTree = "<group>"; }; > A456FA2411AD4A830020B420 /* LabelsNodeList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LabelsNodeList.cpp; sourceTree = "<group>"; }; > A456FA2511AD4A830020B420 /* LabelsNodeList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LabelsNodeList.h; sourceTree = "<group>"; }; >+ A4A69B8BB91B49D0A804C31D /* JSPromiseRejectionEventCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSPromiseRejectionEventCustom.cpp; sourceTree = "<group>"; }; > A501920C132EBF2E008BFE55 /* Autocapitalize.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Autocapitalize.h; sourceTree = "<group>"; }; > A5071E821C56D079009951BE /* ResourceUsageData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceUsageData.h; sourceTree = "<group>"; }; > A5071E831C56D079009951BE /* ResourceUsageThread.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResourceUsageThread.cpp; sourceTree = "<group>"; }; >@@ -13530,6 +13529,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>"; }; >@@ -13580,6 +13580,7 @@ > D0EDA773143E303C0028E383 /* CachedRawResource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CachedRawResource.h; sourceTree = "<group>"; }; > D0FF2A5B11F8C45A007E74E0 /* PingLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PingLoader.cpp; sourceTree = "<group>"; }; > D0FF2A5C11F8C45A007E74E0 /* PingLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PingLoader.h; sourceTree = "<group>"; }; >+ D2CDB5ED638F43AF86F07AA2 /* JSErrorEventCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSErrorEventCustom.cpp; sourceTree = "<group>"; }; > D302754512A5FE84004BD828 /* RenderDetailsMarker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderDetailsMarker.cpp; sourceTree = "<group>"; }; > D302754612A5FE84004BD828 /* RenderDetailsMarker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderDetailsMarker.h; sourceTree = "<group>"; }; > D359D786129CA2710006E5D2 /* HTMLDetailsElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLDetailsElement.cpp; sourceTree = "<group>"; }; >@@ -23903,6 +23904,7 @@ > F5973DDE15CFB2030027F804 /* LocaleMac.h */, > F5973DDF15CFB2030027F804 /* LocaleMac.mm */, > B2AFFC8C0D00A5DF0030074D /* TextBoundaries.mm */, >+ CEA84720212622AD00940809 /* TextCheckingMac.mm */, > A1F55DC41F54D3F000EDB75F /* TextEncodingRegistryMac.mm */, > ); > path = mac; >diff --git a/Source/WebCore/accessibility/AccessibilityObject.cpp b/Source/WebCore/accessibility/AccessibilityObject.cpp >index 77d1fdbc4ea0604dcc26b3b0afb945267bfdbef9..766e98497cd94748841bbb67335d15e5ae4ec0fc 100644 >--- a/Source/WebCore/accessibility/AccessibilityObject.cpp >+++ b/Source/WebCore/accessibility/AccessibilityObject.cpp >@@ -437,7 +437,7 @@ bool AccessibilityObject::hasMisspelling() const > > 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; >diff --git a/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm b/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm >index e3af278d3450a4cb791b3541138ef5f4882d3bb7..04c186a08ac8af28607c41ba7edd0a017c92bf66 100644 >--- a/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm >+++ b/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm >@@ -909,7 +909,7 @@ static void AXAttributeStringSetSpelling(NSMutableAttributedString* attrString, > > // 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++) { >diff --git a/Source/WebCore/editing/AlternativeTextController.cpp b/Source/WebCore/editing/AlternativeTextController.cpp >index 83f83dda4249f345d40508d8177013f59a363abb..e64f9478a249b1b5e2289fc809ee038978342541 100644 >--- a/Source/WebCore/editing/AlternativeTextController.cpp >+++ b/Source/WebCore/editing/AlternativeTextController.cpp >@@ -284,7 +284,7 @@ void AlternativeTextController::timerFired() > 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 @@ bool AlternativeTextController::processMarkersOnTextToBeReplacedByResult(const T > { > 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; > } >diff --git a/Source/WebCore/editing/Editor.cpp b/Source/WebCore/editing/Editor.cpp >index 1bac7f4e36df365eb2ef2b7280cc842442a94aea..4a79274368b592569845d4ab12552c083f38b9ed 100644 >--- a/Source/WebCore/editing/Editor.cpp >+++ b/Source/WebCore/editing/Editor.cpp >@@ -667,7 +667,7 @@ void Editor::replaceSelectionWithFragment(DocumentFragment& fragment, bool selec > 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()); > } > >@@ -2339,10 +2339,10 @@ void Editor::markMisspellingsAfterTypingToWord(const VisiblePosition &wordStart, > #if PLATFORM(IOS) > UNUSED_PARAM(selectionAfterTyping); > UNUSED_PARAM(doReplacement); >- TextCheckingTypeMask textCheckingOptions = 0; >+ TextCheckingTypeMask 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)); >@@ -2356,10 +2356,10 @@ void Editor::markMisspellingsAfterTypingToWord(const VisiblePosition &wordStart, > if (unifiedTextCheckerEnabled()) { > m_alternativeTextController->applyPendingCorrection(selectionAfterTyping); > >- TextCheckingTypeMask textCheckingOptions = 0; >+ TextCheckingTypeMask textCheckingOptions; > > if (isContinuousSpellCheckingEnabled()) >- textCheckingOptions |= TextCheckingTypeSpelling; >+ textCheckingOptions |= TextCheckingType::Spelling; > > #if USE(AUTOMATIC_TEXT_REPLACEMENT) > if (doReplacement >@@ -2367,14 +2367,14 @@ void Editor::markMisspellingsAfterTypingToWord(const VisiblePosition &wordStart, > || 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); >@@ -2563,8 +2563,8 @@ void Editor::markAllMisspellingsAndBadGrammarInRanges(TextCheckingTypeMask textC > // 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)) >@@ -2605,16 +2605,16 @@ void Editor::markAllMisspellingsAndBadGrammarInRanges(TextCheckingTypeMask textC > 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(); >@@ -2647,12 +2647,12 @@ void Editor::markAndReplaceFor(const SpellCheckRequest& request, const Vector<Te > TextCheckingTypeMask textCheckingOptions = request.data().mask(); > 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); >+ const bool shouldMarkSpelling = textCheckingOptions.contains(TextCheckingType::Spelling); >+ const bool shouldMarkGrammar = textCheckingOptions.contains(TextCheckingType::Grammar); >+ const bool shouldMarkLink = textCheckingOptions.contains(TextCheckingType::Link); >+ const bool shouldPerformReplacement = textCheckingOptions.containsAny({ TextCheckingType::Quote, TextCheckingType::Dash, TextCheckingType::Replacement }); >+ const bool shouldShowCorrectionPanel = textCheckingOptions.contains(TextCheckingType::ShowCorrectionPanel); >+ const bool shouldCheckForCorrection = shouldShowCorrectionPanel || textCheckingOptions.contains(TextCheckingType::Correction); > #if !USE(AUTOCORRECTION_PANEL) > ASSERT(!shouldShowCorrectionPanel); > #endif >@@ -2694,14 +2694,14 @@ void Editor::markAndReplaceFor(const SpellCheckRequest& request, const Vector<Te > // 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); > 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); >@@ -2716,7 +2716,7 @@ void Editor::markAndReplaceFor(const SpellCheckRequest& request, const Vector<Te > ASSERT(resultLength > 0 && resultLocation >= 0); > > if (shouldShowCorrectionPanel && (resultEndLocation < automaticReplacementEndLocation >- || !(resultType & (TextCheckingTypeReplacement | TextCheckingTypeCorrection)))) >+ || (resultType != TextCheckingType::Replacement && resultType != TextCheckingType::Correction))) > continue; > > // Apply replacement if: >@@ -2726,8 +2726,8 @@ void Editor::markAndReplaceFor(const SpellCheckRequest& request, const Vector<Te > 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) >@@ -2754,7 +2754,7 @@ void Editor::markAndReplaceFor(const SpellCheckRequest& request, const Vector<Te > continue; > } > >- if (resultType == TextCheckingTypeLink) { >+ if (resultType == TextCheckingType::Link) { > m_frame.selection().setSelection(selectionToReplace); > selectionChanged = true; > restoreSelectionAfterChange = false; >@@ -2777,7 +2777,7 @@ void Editor::markAndReplaceFor(const SpellCheckRequest& request, const Vector<Te > 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()); > >@@ -2837,9 +2837,9 @@ void Editor::markMisspellingsAndBadGrammar(const VisibleSelection& spellingSelec > return; > > // markMisspellingsAndBadGrammar() is triggered by selection change, in which case we check spelling and grammar, but don't autocorrect misspellings. >- TextCheckingTypeMask textCheckingOptions = TextCheckingTypeSpelling; >+ TextCheckingTypeMask textCheckingOptions { TextCheckingType::Spelling }; > if (markGrammar && isGrammarCheckingEnabled()) >- textCheckingOptions |= TextCheckingTypeGrammar; >+ textCheckingOptions |= TextCheckingType::Grammar; > auto spellCheckingRange = spellingSelection.toNormalizedRange(); > markAllMisspellingsAndBadGrammarInRanges(textCheckingOptions, spellCheckingRange.copyRef(), spellCheckingRange.copyRef(), grammarSelection.toNormalizedRange()); > return; >@@ -2861,7 +2861,7 @@ void Editor::updateMarkersForWordsAffectedByEditing(bool doNotRemoveIfSelectionA > 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 >@@ -3652,11 +3652,11 @@ void Editor::editorUIUpdateTimerFired() > } > } > >- 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); > } >@@ -3720,44 +3720,44 @@ TextCheckingTypeMask Editor::resolveTextCheckingTypeMask(const Node& rootEditabl > if (auto* host = rootEditableElement.shadowHost()) > onlyAllowsTextReplacement = is<HTMLInputElement>(host) && downcast<HTMLInputElement>(*host).isSpellcheckDisabledExceptTextReplacement(); > if (onlyAllowsTextReplacement) >- textCheckingOptions &= TextCheckingTypeReplacement; >+ 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; >+ TextCheckingTypeMask 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) >diff --git a/Source/WebCore/editing/SpellChecker.cpp b/Source/WebCore/editing/SpellChecker.cpp >index c054c5ade540904223b9093c140a3586667961e3..3c19c41bd2a8addb382e9cedb3f6f27ab4e4e29d 100644 >--- a/Source/WebCore/editing/SpellChecker.cpp >+++ b/Source/WebCore/editing/SpellChecker.cpp >@@ -217,9 +217,9 @@ void SpellChecker::didCheckSucceed(int sequence, const Vector<TextCheckingResult > TextCheckingRequestData requestData = m_processingRequest->data(); > if (requestData.sequence() == sequence) { > OptionSet<DocumentMarker::MarkerType> markerTypes; >- if (requestData.mask() & TextCheckingTypeSpelling) >+ if (requestData.mask() & TextCheckingType::Spelling) > markerTypes |= DocumentMarker::Spelling; >- if (requestData.mask() & TextCheckingTypeGrammar) >+ if (requestData.mask() & TextCheckingType::Grammar) > markerTypes |= DocumentMarker::Grammar; > if (!markerTypes.isEmpty()) > m_frame.document()->markers().removeMarkers(&m_processingRequest->checkingRange(), markerTypes); >diff --git a/Source/WebCore/editing/TextCheckingHelper.cpp b/Source/WebCore/editing/TextCheckingHelper.cpp >index d5190666c05cccfb55eaf97548fbd88065050e68..bc9629b23a3a712fe093af2dd4983c876de9c9de 100644 >--- a/Source/WebCore/editing/TextCheckingHelper.cpp >+++ b/Source/WebCore/editing/TextCheckingHelper.cpp >@@ -62,7 +62,7 @@ static void findGrammaticalErrors(TextCheckerClient& client, StringView text, Ve > 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 @@ static void findMisspellings(TextCheckerClient& client, StringView text, Vector< > 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,14 +351,14 @@ String TextCheckingHelper::findFirstMisspellingOrBadGrammar(bool checkGrammar, b > unsigned grammarDetailIndex = 0; > > Vector<TextCheckingResult> results; >- TextCheckingTypeMask checkingTypes = checkGrammar ? (TextCheckingTypeSpelling | TextCheckingTypeGrammar) : TextCheckingTypeSpelling; >+ TextCheckingTypeMask checkingTypes = checkGrammar ? TextCheckingTypeMask { TextCheckingType::Spelling, TextCheckingType::Grammar } : TextCheckingTypeMask { TextCheckingType::Spelling }; > VisibleSelection currentSelection; > if (Frame* frame = paragraphRange->ownerDocument().frame()) > currentSelection = frame->selection().selection(); > 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 +366,7 @@ String TextCheckingHelper::findFirstMisspellingOrBadGrammar(bool checkGrammar, b > 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,14 +583,14 @@ Vector<String> TextCheckingHelper::guessesForMisspelledOrUngrammaticalRange(bool > return guesses; > > Vector<TextCheckingResult> results; >- TextCheckingTypeMask checkingTypes = checkGrammar ? (TextCheckingTypeSpelling | TextCheckingTypeGrammar) : TextCheckingTypeSpelling; >+ TextCheckingTypeMask checkingTypes = checkGrammar ? TextCheckingTypeMask { TextCheckingType::Spelling, TextCheckingType::Grammar } : TextCheckingTypeMask { TextCheckingType::Spelling }; > VisibleSelection currentSelection; > if (Frame* frame = m_range->ownerDocument().frame()) > currentSelection = frame->selection().selection(); > 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 +604,7 @@ Vector<String> TextCheckingHelper::guessesForMisspelledOrUngrammaticalRange(bool > 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); >@@ -655,13 +655,13 @@ void checkTextOfParagraph(TextCheckerClient& client, StringView text, TextChecki > 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); >diff --git a/Source/WebCore/platform/text/TextChecking.h b/Source/WebCore/platform/text/TextChecking.h >index 7d58a5008bb330f98873370e6490771e7e842543..69d82a8ce8fdeb4234906667ef5c33f02f5c569e 100644 >--- a/Source/WebCore/platform/text/TextChecking.h >+++ b/Source/WebCore/platform/text/TextChecking.h >@@ -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,28 +29,33 @@ > * 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> > > 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; >+using TextCheckingTypeMask = OptionSet<TextCheckingType>; >+ >+#if PLATFORM(MAC) >+typedef uint64_t NSTextCheckingTypes; >+WEBCORE_EXPORT NSTextCheckingTypes nsTextCheckingTypes(TextCheckingTypeMask); >+#endif > > enum TextCheckingProcessType { > TextCheckingProcessBatch, >@@ -78,7 +84,7 @@ class TextCheckingRequestData { > public: > TextCheckingRequestData() > : m_sequence(unrequestedTextCheckingSequence) >- , m_mask(TextCheckingTypeNone) >+ , m_mask(TextCheckingType::None) > , m_processType(TextCheckingProcessIncremental) > { } > TextCheckingRequestData(int sequence, const String& text, TextCheckingTypeMask mask, TextCheckingProcessType processType) >@@ -110,5 +116,3 @@ public: > }; > > } >- >-#endif // TextChecking_h >diff --git a/Source/WebCore/platform/text/mac/TextCheckingMac.mm b/Source/WebCore/platform/text/mac/TextCheckingMac.mm >new file mode 100644 >index 0000000000000000000000000000000000000000..79771458c8508f8c57966bdcf0c27d15812db34a >--- /dev/null >+++ b/Source/WebCore/platform/text/mac/TextCheckingMac.mm >@@ -0,0 +1,53 @@ >+/* >+ * 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" >+ >+#import <Foundation/Foundation.h> >+ >+namespace WebCore { >+ >+NSTextCheckingTypes nsTextCheckingTypes(TextCheckingTypeMask 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 >diff --git a/Source/WebCore/testing/Internals.cpp b/Source/WebCore/testing/Internals.cpp >index 13b7b707e2738e33f810ce49ccd5a1af0bd72745..af1479e480eaa77ec53dcbe78a7a9db0210e09f7 100644 >--- a/Source/WebCore/testing/Internals.cpp >+++ b/Source/WebCore/testing/Internals.cpp >@@ -2195,7 +2195,7 @@ void Internals::handleAcceptedCandidate(const String& candidate, unsigned locati > return; > > TextCheckingResult result; >- result.type = TextCheckingTypeNone; >+ result.type = TextCheckingType::None; > result.location = location; > result.length = length; > result.replacement = candidate; >diff --git a/Source/WebKit/Scripts/webkit/messages.py b/Source/WebKit/Scripts/webkit/messages.py >index a782baac9d45bb3c9d0b8992622faa6252aa184d..16a26ecd9dfbacfdda10effef4d7e4e4785f1602 100644 >--- a/Source/WebKit/Scripts/webkit/messages.py >+++ b/Source/WebKit/Scripts/webkit/messages.py >@@ -414,6 +414,7 @@ def headers_for_type(type): > '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"'], >diff --git a/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm b/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm >index 56de23c36e44819bdd8e8c1c26124c9ceaddbcf2..3f9d539c46ea32b17f244969ed27b1e56baff06f 100644 >--- a/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm >+++ b/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm >@@ -3090,31 +3090,29 @@ void WebViewImpl::handleRequestedCandidates(NSInteger sequenceNumber, NSArray<NS > #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]) { >- case NSTextCheckingTypeSpelling: >- result.type = WebCore::TextCheckingTypeSpelling; >- break; >- case NSTextCheckingTypeReplacement: >- result.type = WebCore::TextCheckingTypeReplacement; >- break; >+ switch (type) { > case NSTextCheckingTypeCorrection: >- result.type = WebCore::TextCheckingTypeCorrection; >- break; >+ return WebCore::TextCheckingType::Correction; >+ case NSTextCheckingTypeReplacement: >+ return WebCore::TextCheckingType::Replacement; >+ case NSTextCheckingTypeSpelling: >+ 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; > } > >diff --git a/Source/WebKit/UIProcess/TextChecker.h b/Source/WebKit/UIProcess/TextChecker.h >index e7f3dd66cd03454364506b303a516c7706b5b59d..b0461963a346711875026bd5f25b6ba306b54804 100644 >--- a/Source/WebKit/UIProcess/TextChecker.h >+++ b/Source/WebKit/UIProcess/TextChecker.h >@@ -74,7 +74,7 @@ public: > 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, WebCore::TextCheckingTypeMask, 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); >diff --git a/Source/WebKit/UIProcess/WebPageProxy.cpp b/Source/WebKit/UIProcess/WebPageProxy.cpp >index 2dc0f33885b690584f47117e69deeef28c022a47..be305895711baef4bcc183aaa2d4594ea2391bbc 100644 >--- a/Source/WebKit/UIProcess/WebPageProxy.cpp >+++ b/Source/WebKit/UIProcess/WebPageProxy.cpp >@@ -5387,7 +5387,7 @@ int64_t WebPageProxy::spellDocumentTag() > } > > #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, TextCheckingTypeMask checkingTypes, int32_t insertionPoint, Vector<TextCheckingResult>& results) > { > results = TextChecker::checkTextOfParagraph(spellDocumentTag(), text, insertionPoint, checkingTypes, m_initialCapitalizationEnabled); > } >diff --git a/Source/WebKit/UIProcess/WebPageProxy.h b/Source/WebKit/UIProcess/WebPageProxy.h >index 6a5b259fcaea6d8928f09889c798045eb10d8815..e9e42bd2d747ed99f7a44ee2c19fdb38bbb39d00 100644 >--- a/Source/WebKit/UIProcess/WebPageProxy.h >+++ b/Source/WebKit/UIProcess/WebPageProxy.h >@@ -1219,7 +1219,7 @@ public: > #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, WebCore::TextCheckingTypeMask checkingTypes, int32_t insertionPoint, Vector<WebCore::TextCheckingResult>& results); > #endif > void getGuessesForWord(const String& word, const String& context, int32_t insertionPoint, Vector<String>& guesses); > >diff --git a/Source/WebKit/UIProcess/WebPageProxy.messages.in b/Source/WebKit/UIProcess/WebPageProxy.messages.in >index b31f5f0be34cc948927a9b136d0cc32c51bc9c2a..307c21c6a8e40e036dd2370484f221ca7e3c2824 100644 >--- a/Source/WebKit/UIProcess/WebPageProxy.messages.in >+++ b/Source/WebKit/UIProcess/WebPageProxy.messages.in >@@ -298,7 +298,7 @@ messages -> WebPageProxy { > > # 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) >diff --git a/Source/WebKit/UIProcess/gtk/TextCheckerGtk.cpp b/Source/WebKit/UIProcess/gtk/TextCheckerGtk.cpp >index faff0929db2e31fe86d83283f0c04c33a63de164..a0941464cff278b95afe925cfc33969827dfb260 100644 >--- a/Source/WebKit/UIProcess/gtk/TextCheckerGtk.cpp >+++ b/Source/WebKit/UIProcess/gtk/TextCheckerGtk.cpp >@@ -203,7 +203,7 @@ void TextChecker::requestCheckingOfString(Ref<TextCheckerCompletion>&& completio > #if ENABLE(SPELLCHECK) > TextCheckingRequestData request = completion->textCheckingRequestData(); > ASSERT(request.sequence() != unrequestedTextCheckingSequence); >- ASSERT(request.mask() != TextCheckingTypeNone); >+ ASSERT(request.mask() != TextCheckingType::None); > > completion->didFinishCheckingText(checkTextOfParagraph(completion->spellDocumentTag(), request.text(), insertionPoint, request.mask(), false)); > #else >@@ -240,16 +240,16 @@ static unsigned nextWordOffset(StringView text, unsigned currentOffset) > #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, TextCheckingTypeMask 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 @@ Vector<TextCheckingResult> TextChecker::checkTextOfParagraph(int64_t spellDocume > break; > > TextCheckingResult misspellingResult; >- misspellingResult.type = TextCheckingTypeSpelling; >+ misspellingResult.type = TextCheckingType::Spelling; > misspellingResult.location = offset + misspellingLocation; > misspellingResult.length = misspellingLength; > paragraphCheckingResult.append(misspellingResult); >diff --git a/Source/WebKit/UIProcess/mac/TextCheckerMac.mm b/Source/WebKit/UIProcess/mac/TextCheckerMac.mm >index c92fe5fcd945b22a20fe2e6b441a1844510046e0..641ee3c980b924680ccff86b547a4ae97e0ae8db 100644 >--- a/Source/WebKit/UIProcess/mac/TextCheckerMac.mm >+++ b/Source/WebKit/UIProcess/mac/TextCheckerMac.mm >@@ -326,7 +326,7 @@ void TextChecker::closeSpellDocumentWithTag(int64_t tag) > > #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, TextCheckingTypeMask checkingTypes, bool initialCapitalizationEnabled) > { > Vector<TextCheckingResult> results; > >@@ -340,7 +340,7 @@ Vector<TextCheckingResult> TextChecker::checkTextOfParagraph(int64_t spellDocume > #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 @@ Vector<TextCheckingResult> TextChecker::checkTextOfParagraph(int64_t spellDocume > 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 @@ Vector<TextCheckingResult> TextChecker::checkTextOfParagraph(int64_t spellDocume > 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]; >diff --git a/Source/WebKit/WebProcess/WebCoreSupport/WebEditorClient.cpp b/Source/WebKit/WebProcess/WebCoreSupport/WebEditorClient.cpp >index d87a5384cd7e0984b7814d590eb65956ff40b75a..a25c8231d18ac7defe24032ec010b6c1819f74eb 100644 >--- a/Source/WebKit/WebProcess/WebCoreSupport/WebEditorClient.cpp >+++ b/Source/WebKit/WebProcess/WebCoreSupport/WebEditorClient.cpp >@@ -467,7 +467,7 @@ bool WebEditorClient::shouldEraseMarkersAfterChangeSelection(WebCore::TextChecki > { > // 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; >@@ -521,9 +521,7 @@ static int32_t insertionPointFromCurrentSelection(const VisibleSelection& curren > Vector<TextCheckingResult> WebEditorClient::checkTextOfParagraph(StringView stringView, WebCore::TextCheckingTypeMask 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 >diff --git a/Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.mm b/Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.mm >index d311dd65f170c1b25d47a3279753a5d535b575eb..1e3d7fea2824a83fb58193b5bed3eb1655323577 100644 >--- a/Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.mm >+++ b/Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.mm >@@ -935,7 +935,7 @@ bool WebEditorClient::performTwoStepDrop(DocumentFragment& fragment, Range& dest > > Vector<TextCheckingResult> WebEditorClient::checkTextOfParagraph(StringView string, TextCheckingTypeMask checkingTypes, const VisibleSelection&) > { >- ASSERT(checkingTypes & NSTextCheckingTypeSpelling); >+ ASSERT(checkingTypes.contains(TextCheckingType::Spelling)); > > Vector<TextCheckingResult> results; > >@@ -944,7 +944,7 @@ Vector<TextCheckingResult> WebEditorClient::checkTextOfParagraph(StringView stri > 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::performTwoStepDrop(DocumentFragment&, Range&, bool) > 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) >@@ -1037,16 +1037,16 @@ static Vector<TextCheckingResult> core(NSArray *incomingResults, TextCheckingTyp > 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 @@ static Vector<TextCheckingResult> core(NSArray *incomingResults, TextCheckingTyp > 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 @@ static int insertionPointFromCurrentSelection(const VisibleSelection& currentSel > } > #endif > >-Vector<TextCheckingResult> WebEditorClient::checkTextOfParagraph(StringView string, TextCheckingTypeMask checkingTypes, const VisibleSelection& currentSelection) >+Vector<TextCheckingResult> WebEditorClient::checkTextOfParagraph(StringView string, TextCheckingTypeMask 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) >diff --git a/Source/WebKitLegacy/mac/WebView/WebView.mm b/Source/WebKitLegacy/mac/WebView/WebView.mm >index d4d1e6efceaa6dbc493e86e26ce4f81611ea03df..9e8a4f4e6be980bc0d8df96c1f3ebb1ac4077672 100644 >--- a/Source/WebKitLegacy/mac/WebView/WebView.mm >+++ b/Source/WebKitLegacy/mac/WebView/WebView.mm >@@ -7282,29 +7282,29 @@ - (NSTouchBarItem *)touchBar:(NSTouchBar *)touchBar makeItemForIdentifier:(NSStr > return nil; > } > >-static TextCheckingResult textCheckingResultFromNSTextCheckingResult(NSTextCheckingResult *nsResult) >+constexpr TextCheckingType coreTextCheckingType(NSTextCheckingType type) > { >- WebCore::TextCheckingResult result; >- >- switch ([nsResult resultType]) { >- case NSTextCheckingTypeSpelling: >- result.type = WebCore::TextCheckingTypeSpelling; >- break; >- case NSTextCheckingTypeReplacement: >- result.type = WebCore::TextCheckingTypeReplacement; >- break; >+ switch (type) { > case NSTextCheckingTypeCorrection: >- result.type = WebCore::TextCheckingTypeCorrection; >- break; >+ return TextCheckingType::Correction; >+ case NSTextCheckingTypeReplacement: >+ return TextCheckingType::Replacement; >+ case NSTextCheckingTypeSpelling: >+ 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; > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 188678
:
347303
|
347312
|
347313
|
347316
|
347318
|
347365
|
347562
|
347563
|
347565
|
347566
|
347603
|
347633