Diff
Modified: trunk/Source/WTF/ChangeLog (261233 => 261234)
--- trunk/Source/WTF/ChangeLog 2020-05-06 16:15:16 UTC (rev 261233)
+++ trunk/Source/WTF/ChangeLog 2020-05-06 16:24:03 UTC (rev 261234)
@@ -1,3 +1,12 @@
+2020-05-06 Darin Adler <da...@apple.com>
+
+ Remove now-unneeded USE(GRAMMAR_CHECKING)
+ https://bugs.webkit.org/show_bug.cgi?id=211452
+
+ Reviewed by Anders Carlsson.
+
+ * wtf/PlatformUse.h: Don't set USE_GRAMMAR_CHECKING.
+
2020-05-06 Devin Rousso <drou...@apple.com>
ASSERT_WITH_MESSAGE(m_isOwnedByMainThread == isMainThread()) when web inspecting
Modified: trunk/Source/WTF/wtf/PlatformUse.h (261233 => 261234)
--- trunk/Source/WTF/wtf/PlatformUse.h 2020-05-06 16:15:16 UTC (rev 261233)
+++ trunk/Source/WTF/wtf/PlatformUse.h 2020-05-06 16:24:03 UTC (rev 261234)
@@ -195,8 +195,6 @@
#define USE_ZLIB 1
#endif
-#define USE_GRAMMAR_CHECKING 1
-
#if PLATFORM(COCOA) || PLATFORM(GTK)
#define USE_UNIFIED_TEXT_CHECKING 1
#endif
Modified: trunk/Source/WebCore/ChangeLog (261233 => 261234)
--- trunk/Source/WebCore/ChangeLog 2020-05-06 16:15:16 UTC (rev 261233)
+++ trunk/Source/WebCore/ChangeLog 2020-05-06 16:24:03 UTC (rev 261234)
@@ -1,3 +1,21 @@
+2020-05-06 Darin Adler <da...@apple.com>
+
+ Remove now-unneeded USE(GRAMMAR_CHECKING)
+ https://bugs.webkit.org/show_bug.cgi?id=211452
+
+ Reviewed by Anders Carlsson.
+
+ * editing/Editor.cpp:
+ (WebCore::Editor::advanceToNextMisspelling): Remove USE(GRAMMAR_CHECKING).
+ (WebCore::Editor::isSelectionUngrammatical): Ditto.
+ (WebCore::Editor::markMisspellingsOrBadGrammar): Ditto.
+ (WebCore::Editor::markBadGrammar): Ditto.
+ * editing/TextCheckingHelper.cpp:
+ (WebCore::TextCheckingHelper::markAllBadGrammar): Ditto.
+ (WebCore::checkTextOfParagraph): Ditto. Also correct misspelling of the
+ word "misspelling".
+ * editing/TextCheckingHelper.h: Ditto.
+
2020-05-06 Devin Rousso <drou...@apple.com>
ASSERT_WITH_MESSAGE(m_isOwnedByMainThread == isMainThread()) when web inspecting
Modified: trunk/Source/WebCore/editing/Editor.cpp (261233 => 261234)
--- trunk/Source/WebCore/editing/Editor.cpp 2020-05-06 16:15:16 UTC (rev 261233)
+++ trunk/Source/WebCore/editing/Editor.cpp 2020-05-06 16:24:03 UTC (rev 261234)
@@ -2241,7 +2241,6 @@
} else {
misspelledWord = TextCheckingHelper(*client(), spellingSearchRange).findFirstMisspelling(misspellingOffset, false, firstMisspellingRange);
-#if USE(GRAMMAR_CHECKING)
grammarSearchRange = spellingSearchRange->cloneRange();
if (!misspelledWord.isEmpty()) {
// Stop looking at start of next misspelled word
@@ -2252,7 +2251,6 @@
if (isGrammarCheckingEnabled())
badGrammarPhrase = TextCheckingHelper(*client(), *grammarSearchRange).findFirstBadGrammar(grammarDetail, grammarPhraseOffset, false);
-#endif
}
// If we found neither bad grammar nor a misspelled word, wrap and try again (but don't bother if we started at the beginning of the
@@ -2276,7 +2274,6 @@
} else {
misspelledWord = TextCheckingHelper(*client(), spellingSearchRange).findFirstMisspelling(misspellingOffset, false, firstMisspellingRange);
-#if USE(GRAMMAR_CHECKING)
grammarSearchRange = spellingSearchRange->cloneRange();
if (!misspelledWord.isEmpty()) {
// Stop looking at start of next misspelled word
@@ -2287,14 +2284,9 @@
if (isGrammarCheckingEnabled())
badGrammarPhrase = TextCheckingHelper(*client(), *grammarSearchRange).findFirstBadGrammar(grammarDetail, grammarPhraseOffset, false);
-#endif
}
}
-#if !USE(GRAMMAR_CHECKING)
- ASSERT(badGrammarPhrase.isEmpty());
- UNUSED_PARAM(grammarPhraseOffset);
-#else
if (!badGrammarPhrase.isEmpty()) {
// We found bad grammar. Since we only searched for bad grammar up to the first misspelled word, the bad grammar
// takes precedence and we ignore any potential misspelled word. Select the grammar detail, update the spelling
@@ -2310,9 +2302,7 @@
client()->updateSpellingUIWithGrammarString(badGrammarPhrase, grammarDetail);
document().markers().addMarker(badGrammarRange, DocumentMarker::Grammar, grammarDetail.userDescription);
- } else
-#endif
- if (!misspelledWord.isEmpty()) {
+ } else if (!misspelledWord.isEmpty()) {
// We found a misspelling, but not any earlier bad grammar. Select the misspelling, update the spelling panel, and store
// a marker so we draw the red squiggle later.
@@ -2385,14 +2375,10 @@
bool Editor::isSelectionUngrammatical()
{
-#if USE(GRAMMAR_CHECKING)
auto range = m_document.selection().selection().toNormalizedRange();
if (!range || !client())
return false;
return TextCheckingHelper(*client(), *range).isUngrammatical();
-#else
- return false;
-#endif
}
Vector<String> Editor::guessesForMisspelledWord(const String& word) const
@@ -2644,15 +2630,9 @@
TextCheckingHelper checker(*client(), *searchRange);
if (checkSpelling)
checker.markAllMisspellings(firstMisspellingRange);
- else {
-#if USE(GRAMMAR_CHECKING)
- if (isGrammarCheckingEnabled())
- checker.markAllBadGrammar();
+ else if (isGrammarCheckingEnabled())
+ checker.markAllBadGrammar();
#else
- ASSERT_NOT_REACHED();
-#endif
- }
-#else
UNUSED_PARAM(selection);
UNUSED_PARAM(checkSpelling);
UNUSED_PARAM(firstMisspellingRange);
@@ -2685,12 +2665,8 @@
void Editor::markBadGrammar(const VisibleSelection& selection)
{
-#if USE(GRAMMAR_CHECKING)
RefPtr<Range> firstMisspellingRange;
markMisspellingsOrBadGrammar(selection, false, firstMisspellingRange);
-#else
- ASSERT_NOT_REACHED();
-#endif
}
void Editor::markAllMisspellingsAndBadGrammarInRanges(OptionSet<TextCheckingType> textCheckingOptions, RefPtr<Range>&& spellingRange, RefPtr<Range>&& automaticReplacementRange, RefPtr<Range>&& grammarRange)
Modified: trunk/Source/WebCore/editing/TextCheckingHelper.cpp (261233 => 261234)
--- trunk/Source/WebCore/editing/TextCheckingHelper.cpp 2020-05-06 16:15:16 UTC (rev 261233)
+++ trunk/Source/WebCore/editing/TextCheckingHelper.cpp 2020-05-06 16:24:03 UTC (rev 261234)
@@ -44,8 +44,6 @@
#if !USE(UNIFIED_TEXT_CHECKING)
-#if USE(GRAMMAR_CHECKING)
-
static void findGrammaticalErrors(TextCheckerClient& client, StringView text, Vector<TextCheckingResult>& results)
{
for (unsigned checkLocation = 0; checkLocation < text.length(); ) {
@@ -71,8 +69,6 @@
}
}
-#endif
-
static void findMisspellings(TextCheckerClient& client, StringView text, Vector<TextCheckingResult>& results)
{
UBreakIterator* iterator = wordBreakIterator(text);
@@ -420,8 +416,6 @@
return firstFoundItem;
}
-#if USE(GRAMMAR_CHECKING)
-
int TextCheckingHelper::findFirstGrammarDetail(const Vector<GrammarDetail>& grammarDetails, uint64_t badGrammarPhraseLocation, uint64_t startOffset, uint64_t endOffset, bool markAll) const
{
// Found some bad grammar. Find the earliest detail range that starts in our search range (if any).
@@ -555,8 +549,6 @@
return true;
}
-#endif // USE(GRAMMAR_CHECKING)
-
Vector<String> TextCheckingHelper::guessesForMisspelledOrUngrammaticalRange(bool checkGrammar, bool& misspelled, bool& ungrammatical) const
{
if (!unifiedTextCheckerEnabled())
@@ -628,7 +620,6 @@
findFirstMisspelling(ignoredOffset, true, firstMisspellingRange);
}
-#if USE(GRAMMAR_CHECKING)
void TextCheckingHelper::markAllBadGrammar()
{
// Use the "markAll" feature of ofindFirstBadGrammar. Ignore the return value and "out parameters"; all we need to
@@ -637,7 +628,6 @@
uint64_t ignoredOffset;
findFirstBadGrammar(ignoredGrammarDetail, ignoredOffset, true);
}
-#endif
bool TextCheckingHelper::unifiedTextCheckerEnabled() const
{
@@ -651,27 +641,25 @@
#else
UNUSED_PARAM(currentSelection);
- Vector<TextCheckingResult> mispellings;
+ Vector<TextCheckingResult> misspellings;
if (checkingTypes.contains(TextCheckingType::Spelling))
- findMisspellings(client, text, mispellings);
+ findMisspellings(client, text, misspellings);
-#if USE(GRAMMAR_CHECKING)
// Look for grammatical errors that occur before the first misspelling.
Vector<TextCheckingResult> grammaticalErrors;
if (checkingTypes.contains(TextCheckingType::Grammar)) {
unsigned grammarCheckLength = text.length();
- for (auto& mispelling : mispellings)
- grammarCheckLength = std::min<unsigned>(grammarCheckLength, mispelling.range.location);
+ for (auto& misspelling : misspellings)
+ grammarCheckLength = std::min<unsigned>(grammarCheckLength, misspelling.range.location);
findGrammaticalErrors(client, text.substring(0, grammarCheckLength), grammaticalErrors);
}
results = WTFMove(grammaticalErrors);
-#endif
if (results.isEmpty())
- results = WTFMove(mispellings);
+ results = WTFMove(misspellings);
else
- results.appendVector(mispellings);
+ results.appendVector(misspellings);
#endif // USE(UNIFIED_TEXT_CHECKING)
}
Modified: trunk/Source/WebCore/editing/TextCheckingHelper.h (261233 => 261234)
--- trunk/Source/WebCore/editing/TextCheckingHelper.h 2020-05-06 16:15:16 UTC (rev 261233)
+++ trunk/Source/WebCore/editing/TextCheckingHelper.h 2020-05-06 16:24:03 UTC (rev 261234)
@@ -83,11 +83,9 @@
String findFirstMisspelling(uint64_t& firstMisspellingOffset, bool markAll, RefPtr<Range>& firstMisspellingRange);
String findFirstMisspellingOrBadGrammar(bool checkGrammar, bool& outIsSpelling, uint64_t& outFirstFoundOffset, GrammarDetail& outGrammarDetail);
void markAllMisspellings(RefPtr<Range>& firstMisspellingRange);
-#if USE(GRAMMAR_CHECKING)
String findFirstBadGrammar(GrammarDetail& outGrammarDetail, uint64_t& outGrammarPhraseOffset, bool markAll) const;
void markAllBadGrammar();
bool isUngrammatical() const;
-#endif
Vector<String> guessesForMisspelledOrUngrammaticalRange(bool checkGrammar, bool& misspelled, bool& ungrammatical) const;
private:
@@ -95,9 +93,7 @@
SimpleRange m_range;
bool unifiedTextCheckerEnabled() const;
-#if USE(GRAMMAR_CHECKING)
int findFirstGrammarDetail(const Vector<GrammarDetail>&, uint64_t badGrammarPhraseLocation, uint64_t startOffset, uint64_t endOffset, bool markAll) const;
-#endif
};
void checkTextOfParagraph(TextCheckerClient&, StringView, OptionSet<TextCheckingType>, Vector<TextCheckingResult>&, const VisibleSelection& currentSelection);