void checkTextOfParagraph(TextCheckerClient& client, StringView text, TextCheckingTypeMask checkingTypes, Vector<TextCheckingResult>& results) { #if USE(UNIFIED_TEXT_CHECKING) results = client.checkTextOfParagraph(text, checkingTypes); #else Vector<TextCheckingResult> mispellings; if (checkingTypes & TextCheckingTypeSpelling) findMisspellings(client, text, mispellings); #if USE(GRAMMAR_CHECKING) // Look for grammatical errors that occur before the first misspelling. Vector<TextCheckingResult> grammaticalErrors; if (checkingTypes & TextCheckingTypeGrammar) { unsigned grammarCheckLength = text.length(); for (auto& mispelling : mispellings) grammarCheckLength = std::min<unsigned>(grammarCheckLength, mispelling.location); findGrammaticalErrors(client, text.substring(0, grammarCheckLength), grammaticalErrors); } results = std::move(grammaticalErrors); #endif if (results.isEmpty()) results = std::move(mispellings); else results.appendVector(mispellings); #endif // USE(UNIFIED_TEXT_CHECKING) }