Title: [169203] trunk/Source/WebCore
- Revision
- 169203
- Author
- [email protected]
- Date
- 2014-05-22 09:23:05 -0700 (Thu, 22 May 2014)
Log Message
REGRESSION(r163712): [GTK] Misspelling and grammar underline marks are no longer drawn
https://bugs.webkit.org/show_bug.cgi?id=133047
Reviewed by Darin Adler.
Change two conditions changed by mistake in r163712.
* editing/TextCheckingHelper.cpp:
(WebCore::findMisspellings): Enter the loop also when wordStart is 0.
(WebCore::TextCheckingHelper::findFirstMisspelling): Skip the work
when the text is a single character. Also reworked it to use a for
loop to improve the readability.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (169202 => 169203)
--- trunk/Source/WebCore/ChangeLog 2014-05-22 15:51:47 UTC (rev 169202)
+++ trunk/Source/WebCore/ChangeLog 2014-05-22 16:23:05 UTC (rev 169203)
@@ -1,3 +1,18 @@
+2014-05-22 Carlos Garcia Campos <[email protected]>
+
+ REGRESSION(r163712): [GTK] Misspelling and grammar underline marks are no longer drawn
+ https://bugs.webkit.org/show_bug.cgi?id=133047
+
+ Reviewed by Darin Adler.
+
+ Change two conditions changed by mistake in r163712.
+
+ * editing/TextCheckingHelper.cpp:
+ (WebCore::findMisspellings): Enter the loop also when wordStart is 0.
+ (WebCore::TextCheckingHelper::findFirstMisspelling): Skip the work
+ when the text is a single character. Also reworked it to use a for
+ loop to improve the readability.
+
2014-05-22 Piotr Grad <[email protected]>
Video is resumed with old playback rate.
Modified: trunk/Source/WebCore/editing/TextCheckingHelper.cpp (169202 => 169203)
--- trunk/Source/WebCore/editing/TextCheckingHelper.cpp 2014-05-22 15:51:47 UTC (rev 169202)
+++ trunk/Source/WebCore/editing/TextCheckingHelper.cpp 2014-05-22 16:23:05 UTC (rev 169203)
@@ -77,7 +77,7 @@
TextBreakIterator* iterator = wordBreakIterator(text);
if (!iterator)
return;
- for (int wordStart = textBreakCurrent(iterator); wordStart > 0; ) {
+ for (int wordStart = textBreakCurrent(iterator); wordStart >= 0; ) {
int wordEnd = textBreakNext(iterator);
if (wordEnd < 0)
break;
@@ -244,56 +244,53 @@
String TextCheckingHelper::findFirstMisspelling(int& firstMisspellingOffset, bool markAll, RefPtr<Range>& firstMisspellingRange)
{
- WordAwareIterator it(*m_range);
firstMisspellingOffset = 0;
-
+
String firstMisspelling;
int currentChunkOffset = 0;
- while (!it.atEnd()) {
+ for (WordAwareIterator it(*m_range); !it.atEnd(); currentChunkOffset += it.text().length(), it.advance()) {
StringView text = it.text();
int textLength = text.length();
- // Skip some work for one-space-char hunks
- if (textLength == 1 && text[0] == ' ') {
- int misspellingLocation = -1;
- int misspellingLength = 0;
- m_client->textChecker()->checkSpellingOfString(text, &misspellingLocation, &misspellingLength);
+ // Skip some work for one-space-char hunks.
+ if (textLength == 1 && text[0] == ' ')
+ continue;
- // 5490627 shows that there was some code path here where the String constructor below crashes.
- // We don't know exactly what combination of bad input caused this, so we're making this much
- // more robust against bad input on release builds.
- ASSERT(misspellingLength >= 0);
- ASSERT(misspellingLocation >= -1);
- ASSERT(!misspellingLength || misspellingLocation >= 0);
- ASSERT(misspellingLocation < textLength);
- ASSERT(misspellingLength <= textLength);
- ASSERT(misspellingLocation + misspellingLength <= textLength);
+ int misspellingLocation = -1;
+ int misspellingLength = 0;
+ m_client->textChecker()->checkSpellingOfString(text, &misspellingLocation, &misspellingLength);
- if (misspellingLocation >= 0 && misspellingLength > 0 && misspellingLocation < textLength && misspellingLength <= textLength && misspellingLocation + misspellingLength <= textLength) {
- // Compute range of misspelled word
- RefPtr<Range> misspellingRange = TextIterator::subrange(m_range.get(), currentChunkOffset + misspellingLocation, misspellingLength);
+ // 5490627 shows that there was some code path here where the String constructor below crashes.
+ // We don't know exactly what combination of bad input caused this, so we're making this much
+ // more robust against bad input on release builds.
+ ASSERT(misspellingLength >= 0);
+ ASSERT(misspellingLocation >= -1);
+ ASSERT(!misspellingLength || misspellingLocation >= 0);
+ ASSERT(misspellingLocation < textLength);
+ ASSERT(misspellingLength <= textLength);
+ ASSERT(misspellingLocation + misspellingLength <= textLength);
- // Remember first-encountered misspelling and its offset.
- if (!firstMisspelling) {
- firstMisspellingOffset = currentChunkOffset + misspellingLocation;
- firstMisspelling = text.substring(misspellingLocation, misspellingLength).toString();
- firstMisspellingRange = misspellingRange;
- }
+ if (misspellingLocation >= 0 && misspellingLength > 0 && misspellingLocation < textLength && misspellingLength <= textLength && misspellingLocation + misspellingLength <= textLength) {
+ // Compute range of misspelled word
+ RefPtr<Range> misspellingRange = TextIterator::subrange(m_range.get(), currentChunkOffset + misspellingLocation, misspellingLength);
- // Store marker for misspelled word.
- misspellingRange->startContainer()->document().markers().addMarker(misspellingRange.get(), DocumentMarker::Spelling);
-
- // Bail out if we're marking only the first misspelling, and not all instances.
- if (!markAll)
- break;
+ // Remember first-encountered misspelling and its offset.
+ if (!firstMisspelling) {
+ firstMisspellingOffset = currentChunkOffset + misspellingLocation;
+ firstMisspelling = text.substring(misspellingLocation, misspellingLength).toString();
+ firstMisspellingRange = misspellingRange;
}
+
+ // Store marker for misspelled word.
+ misspellingRange->startContainer()->document().markers().addMarker(misspellingRange.get(), DocumentMarker::Spelling);
+
+ // Bail out if we're marking only the first misspelling, and not all instances.
+ if (!markAll)
+ break;
}
-
- currentChunkOffset += textLength;
- it.advance();
}
-
+
return firstMisspelling;
}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes