bool MockSpellCheck::spellCheckWord(const WebString& text, int* misspelledOffset, int* misspelledLength) { ASSERT(misspelledOffset); ASSERT(misspelledLength); // Initialize this spellchecker. initializeIfNeeded(); // Reset the result values as our spellchecker does. *misspelledOffset = 0; *misspelledLength = 0; // Convert to a String because we store String instances in // m_misspelledWords and WebString has no find(). const WTF::String stringText(text.data(), text.length()); // Extract the first possible English word from the given string. // The given string may include non-ASCII characters or numbers. So, we // should filter out such characters before start looking up our // misspelled-word table. // (This is a simple version of our SpellCheckWordIterator class.) // If the given string doesn't include any ASCII characters, we can treat the // string as valid one. // Unfortunately, This implementation splits a contraction, i.e. "isn't" is // split into two pieces "isn" and "t". This is OK because webkit tests // don't have misspelled contractions. int wordOffset = stringText.find(isASCIIAlpha); if (wordOffset == -1) return true; int wordEnd = stringText.find(isNotASCIIAlpha, wordOffset); int wordLength = wordEnd == -1 ? stringText.length() - wordOffset : wordEnd - wordOffset; // Look up our misspelled-word table to check if the extracted word is a // known misspelled word, and return the offset and the length of the // extracted word if this word is a known misspelled word. // (See the comment in MockSpellCheck::initializeIfNeeded() why we use a // misspelled-word table.) WTF::String word = stringText.substring(wordOffset, wordLength); if (!m_misspelledWords.contains(word)) return true; *misspelledOffset = wordOffset; *misspelledLength = wordLength; return false; }
static void onConsoleMessage(Ewk_View_Smart_Data*, const char* message, unsigned int lineNumber, const char*) { // Tests expect only the filename part of local URIs WTF::String newMessage = message; if (!newMessage.isEmpty()) { const size_t fileProtocol = newMessage.find("file://"); if (fileProtocol != WTF::notFound) newMessage = newMessage.left(fileProtocol) + urlSuitableForTestResult(newMessage.substring(fileProtocol)); } // Ignore simple translation-related messages and unnecessary messages if (newMessage.contains("Localized string") || newMessage.contains("Protocol Error: the message is for non-existing domain 'Profiler'")) return; printf("CONSOLE MESSAGE: "); if (lineNumber) printf("line %u: ", lineNumber); printf("%s\n", newMessage.utf8().data()); }