[Webkit-unassigned] [Bug 24419] New: WordAwareIterator not working in WebCore/editing/Editor.cpp
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Thu Mar 5 22:26:41 PST 2009
https://bugs.webkit.org/show_bug.cgi?id=24419
Summary: WordAwareIterator not working in
WebCore/editing/Editor.cpp
Product: WebKit
Version: 528+ (Nightly build)
Platform: PC
OS/Version: Linux
Status: UNCONFIRMED
Severity: Normal
Priority: P2
Component: WebCore Misc.
AssignedTo: webkit-unassigned at lists.webkit.org
ReportedBy: diegoe at gnome.org
So in WebCore/editing/Editor.cpp there's the code calling checkSpellingOfString
of the current backend, while implementing the one for GTK+ I realized that
this code (and I might be wrong) should be handling me the string analyzed
/word by word/ and not as a whole.
Example:
- wrong:
client->checkSpellingOfString("helol john", len,
&misspellingLocation, &misspellingLength);
- right:
client->checkSpellingOfString("helol", len, &misspellingLocation,
&misspellingLength);
(second iteration)
client->checkSpellingOfString("john", len, &misspellingLocation,
&misspellingLength);
I base my theory in the name of the text iterator (WordAwareIterator?) and that
there's a while() loop for calling checkSpellingOfString with an .advance()
method and a check for .atEnd(). If this was not supposed to split by word,
then why the while()? why .advance() the iterator?.
Based on all that, I suggest that this is a bug in the text iterator and that
it should actually be giving me words and not the full phrase.
static String findFirstMisspellingInRange(EditorClient* client, Range*
searchRange, int& firstMisspellingOffset, bool markAll)
{
ASSERT_ARG(client, client);
ASSERT_ARG(searchRange, searchRange);
WordAwareIterator it(searchRange);
firstMisspellingOffset = 0;
String firstMisspelling;
int currentChunkOffset = 0;
while (!it.atEnd()) {
const UChar* chars = it.characters();
int len = it.length();
// Skip some work for one-space-char hunks
if (!(len == 1 && chars[0] == ' ')) {
int misspellingLocation = -1;
int misspellingLength = 0;
client->checkSpellingOfString(chars, len, &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 == 0 || misspellingLocation >= 0);
ASSERT(misspellingLocation < len);
ASSERT(misspellingLength <= len);
ASSERT(misspellingLocation + misspellingLength <= len);
if (misspellingLocation >= 0 && misspellingLength > 0 &&
misspellingLocation < len && misspellingLength <= len && misspellingLocation +
misspellingLength <= len) {
// Remember first-encountered misspelling and its offset
if (!firstMisspelling) {
firstMisspellingOffset = currentChunkOffset +
misspellingLocation;
firstMisspelling = String(chars + misspellingLocation,
misspellingLength);
}
// Mark this instance if we're marking all instances. Otherwise
bail out because we found the first one.
if (!markAll)
break;
// Compute range of misspelled word
RefPtr<Range> misspellingRange =
TextIterator::subrange(searchRange, currentChunkOffset + misspellingLocation,
misspellingLength);
// Store marker for misspelled word
ExceptionCode ec = 0;
misspellingRange->startContainer(ec)->document()->addMarker(misspellingRange.get(),
DocumentMarker::Spelling);
ASSERT(ec == 0);
}
}
currentChunkOffset += len;
it.advance();
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
}
return firstMisspelling;
}
--
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
More information about the webkit-unassigned
mailing list