Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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):
- Loading branch information