summaryrefslogtreecommitdiff
path: root/Source/WebCore/platform/text/enchant
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/platform/text/enchant
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/WebCore/platform/text/enchant')
-rw-r--r--Source/WebCore/platform/text/enchant/TextCheckerEnchant.cpp47
-rw-r--r--Source/WebCore/platform/text/enchant/TextCheckerEnchant.h4
2 files changed, 25 insertions, 26 deletions
diff --git a/Source/WebCore/platform/text/enchant/TextCheckerEnchant.cpp b/Source/WebCore/platform/text/enchant/TextCheckerEnchant.cpp
index d2d2c6f04..638f76c46 100644
--- a/Source/WebCore/platform/text/enchant/TextCheckerEnchant.cpp
+++ b/Source/WebCore/platform/text/enchant/TextCheckerEnchant.cpp
@@ -24,7 +24,8 @@
#include <Language.h>
#include <glib.h>
-#include <text/TextBreakIterator.h>
+#include <unicode/ubrk.h>
+#include <wtf/text/TextBreakIterator.h>
namespace WebCore {
@@ -53,14 +54,14 @@ TextCheckerEnchant::~TextCheckerEnchant()
void TextCheckerEnchant::ignoreWord(const String& word)
{
- for (Vector<EnchantDict*>::const_iterator iter = m_enchantDictionaries.begin(); iter != m_enchantDictionaries.end(); ++iter)
- enchant_dict_add_to_session(*iter, word.utf8().data(), -1);
+ for (auto& dictionary : m_enchantDictionaries)
+ enchant_dict_add_to_session(dictionary, word.utf8().data(), -1);
}
void TextCheckerEnchant::learnWord(const String& word)
{
- for (Vector<EnchantDict*>::const_iterator iter = m_enchantDictionaries.begin(); iter != m_enchantDictionaries.end(); ++iter)
- enchant_dict_add(*iter, word.utf8().data(), -1);
+ for (auto& dictionary : m_enchantDictionaries)
+ enchant_dict_add(dictionary, word.utf8().data(), -1);
}
void TextCheckerEnchant::checkSpellingOfWord(const CString& word, int start, int end, int& misspellingLocation, int& misspellingLength)
@@ -69,8 +70,8 @@ void TextCheckerEnchant::checkSpellingOfWord(const CString& word, int start, int
char* startPtr = g_utf8_offset_to_pointer(string, start);
int numberOfBytes = static_cast<int>(g_utf8_offset_to_pointer(string, end) - startPtr);
- for (Vector<EnchantDict*>::const_iterator dictIter = m_enchantDictionaries.begin(); dictIter != m_enchantDictionaries.end(); ++dictIter) {
- if (!enchant_dict_check(*dictIter, startPtr, numberOfBytes)) {
+ for (auto& dictionary : m_enchantDictionaries) {
+ if (!enchant_dict_check(dictionary, startPtr, numberOfBytes)) {
// Stop checking, this word is ok in at least one dict.
misspellingLocation = -1;
misspellingLength = 0;
@@ -91,13 +92,13 @@ void TextCheckerEnchant::checkSpellingOfString(const String& string, int& misspe
if (!hasDictionary())
return;
- TextBreakIterator* iter = wordBreakIterator(string);
+ UBreakIterator* iter = wordBreakIterator(string);
if (!iter)
return;
CString utf8String = string.utf8();
- int start = textBreakFirst(iter);
- for (int end = textBreakNext(iter); end != TextBreakDone; end = textBreakNext(iter)) {
+ int start = ubrk_first(iter);
+ for (int end = ubrk_next(iter); end != UBRK_DONE; end = ubrk_next(iter)) {
if (isWordTextBreak(iter)) {
checkSpellingOfWord(utf8String, start, end, misspellingLocation, misspellingLength);
// Stop checking the next words If the current word is misspelled, to do not overwrite its misspelled location and length.
@@ -114,11 +115,11 @@ Vector<String> TextCheckerEnchant::getGuessesForWord(const String& word)
if (!hasDictionary())
return guesses;
- for (Vector<EnchantDict*>::const_iterator iter = m_enchantDictionaries.begin(); iter != m_enchantDictionaries.end(); ++iter) {
+ for (auto& dictionary : m_enchantDictionaries) {
size_t numberOfSuggestions;
size_t i;
- char** suggestions = enchant_dict_suggest(*iter, word.utf8().data(), -1, &numberOfSuggestions);
+ char** suggestions = enchant_dict_suggest(dictionary, word.utf8().data(), -1, &numberOfSuggestions);
if (numberOfSuggestions <= 0)
continue;
@@ -128,7 +129,7 @@ Vector<String> TextCheckerEnchant::getGuessesForWord(const String& word)
for (i = 0; i < numberOfSuggestions; i++)
guesses.append(String::fromUTF8(suggestions[i]));
- enchant_dict_free_suggestions(*iter, suggestions);
+ enchant_dict_free_suggestions(dictionary, suggestions);
}
return guesses;
@@ -139,8 +140,8 @@ void TextCheckerEnchant::updateSpellCheckingLanguages(const Vector<String>& lang
Vector<EnchantDict*> spellDictionaries;
if (!languages.isEmpty()) {
- for (Vector<String>::const_iterator iter = languages.begin(); iter != languages.end(); ++iter) {
- CString currentLanguage = iter->utf8();
+ for (auto& language : languages) {
+ CString currentLanguage = language.utf8();
if (enchant_broker_dict_exists(m_broker, currentLanguage.data())) {
EnchantDict* dict = enchant_broker_request_dict(m_broker, currentLanguage.data());
spellDictionaries.append(dict);
@@ -175,11 +176,11 @@ Vector<String> TextCheckerEnchant::loadedSpellCheckingLanguages() const
// Get a Vector<CString> with the list of languages in use.
Vector<CString> currentDictionaries;
- for (Vector<EnchantDict*>::const_iterator iter = m_enchantDictionaries.begin(); iter != m_enchantDictionaries.end(); ++iter)
- enchant_dict_describe(*iter, enchantDictDescribeCallback, &currentDictionaries);
+ for (auto& dictionary : m_enchantDictionaries)
+ enchant_dict_describe(dictionary, enchantDictDescribeCallback, &currentDictionaries);
- for (Vector<CString>::const_iterator iter = currentDictionaries.begin(); iter != currentDictionaries.end(); ++iter)
- languages.append(String::fromUTF8(iter->data()));
+ for (auto& dictionary : currentDictionaries)
+ languages.append(String::fromUTF8(dictionary.data()));
return languages;
}
@@ -190,16 +191,16 @@ Vector<String> TextCheckerEnchant::availableSpellCheckingLanguages() const
enchant_broker_list_dicts(m_broker, enchantDictDescribeCallback, &allDictionaries);
Vector<String> languages;
- for (Vector<CString>::const_iterator iter = allDictionaries.begin(); iter != allDictionaries.end(); ++iter)
- languages.append(String::fromUTF8(iter->data()));
+ for (auto& dictionary : allDictionaries)
+ languages.append(String::fromUTF8(dictionary.data()));
return languages;
}
void TextCheckerEnchant::freeEnchantBrokerDictionaries()
{
- for (Vector<EnchantDict*>::const_iterator iter = m_enchantDictionaries.begin(); iter != m_enchantDictionaries.end(); ++iter)
- enchant_broker_free_dict(m_broker, *iter);
+ for (auto& dictionary : m_enchantDictionaries)
+ enchant_broker_free_dict(m_broker, dictionary);
}
} // namespace WebCore
diff --git a/Source/WebCore/platform/text/enchant/TextCheckerEnchant.h b/Source/WebCore/platform/text/enchant/TextCheckerEnchant.h
index eb9be3e1f..3bd73c205 100644
--- a/Source/WebCore/platform/text/enchant/TextCheckerEnchant.h
+++ b/Source/WebCore/platform/text/enchant/TextCheckerEnchant.h
@@ -24,7 +24,6 @@
#include <enchant.h>
#include <wtf/FastMalloc.h>
-#include <wtf/PassOwnPtr.h>
#include <wtf/Vector.h>
#include <wtf/text/CString.h>
#include <wtf/text/WTFString.h>
@@ -35,7 +34,7 @@ class TextCheckerEnchant {
WTF_MAKE_FAST_ALLOCATED;
public:
- static PassOwnPtr<TextCheckerEnchant> create() { return adoptPtr(new TextCheckerEnchant); }
+ TextCheckerEnchant();
virtual ~TextCheckerEnchant();
void ignoreWord(const String&);
@@ -48,7 +47,6 @@ public:
Vector<String> availableSpellCheckingLanguages() const;
private:
- TextCheckerEnchant();
void freeEnchantBrokerDictionaries();
void checkSpellingOfWord(const CString&, int start, int end, int& misspellingLocation, int& misspellingLength);