summaryrefslogtreecommitdiffstats
path: root/webkit/mocks
diff options
context:
space:
mode:
authortony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-01 04:13:48 +0000
committertony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-01 04:13:48 +0000
commita6d92e37c93b224e7f8d682bf602456b4b412264 (patch)
tree3d46e064a8d5671cc6120a70cde137e76141b4c4 /webkit/mocks
parent0bd4039696bf111d3fc59d62871399749c65629e (diff)
downloadchromium_src-a6d92e37c93b224e7f8d682bf602456b4b412264.zip
chromium_src-a6d92e37c93b224e7f8d682bf602456b4b412264.tar.gz
chromium_src-a6d92e37c93b224e7f8d682bf602456b4b412264.tar.bz2
Remove code to load dictionary in testing code.
I can't remove the file from the isolate in blink because this code tries to load it and CHECK's to verify the file loaded. Remove the code that tries to load the dictionary, so I can remove the file from the isolate, so I can remove the rest of the Chromium code. BUG=None Review URL: https://chromiumcodereview.appspot.com/21439002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@214950 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/mocks')
-rw-r--r--webkit/mocks/mock_webhyphenator.cc69
1 files changed, 1 insertions, 68 deletions
diff --git a/webkit/mocks/mock_webhyphenator.cc b/webkit/mocks/mock_webhyphenator.cc
index 2ff288e..a148560 100644
--- a/webkit/mocks/mock_webhyphenator.cc
+++ b/webkit/mocks/mock_webhyphenator.cc
@@ -17,86 +17,19 @@ MockWebHyphenator::MockWebHyphenator()
}
MockWebHyphenator::~MockWebHyphenator() {
- if (hyphen_dictionary_)
- hnj_hyphen_free(hyphen_dictionary_);
}
void MockWebHyphenator::LoadDictionary(base::PlatformFile dict_file) {
- CHECK(!hyphen_dictionary_);
- // Initialize the hyphen library with a sample dictionary. To avoid test
- // flakiness, this code synchronously loads the dictionary.
- if (dict_file == base::kInvalidPlatformFileValue) {
- NOTREACHED();
- return;
- }
- ScopedStdioHandle dict_handle(base::FdopenPlatformFile(dict_file, "r"));
- if (!dict_handle.get()) {
- NOTREACHED();
- base::ClosePlatformFile(dict_file);
- return;
- }
- hyphen_dictionary_ = hnj_hyphen_load_file(dict_handle.get());
- DCHECK(hyphen_dictionary_);
}
bool MockWebHyphenator::canHyphenate(const WebKit::WebString& locale) {
- return locale.isEmpty() || locale.equals("en") || locale.equals("en_US") ||
- locale.equals("en_GB");
+ return false;
}
size_t MockWebHyphenator::computeLastHyphenLocation(
const WebKit::WebString& characters,
size_t before_index,
const WebKit::WebString& locale) {
- DCHECK(locale.isEmpty() || locale.equals("en") || locale.equals("en_US") ||
- locale.equals("en_GB"));
- if (!hyphen_dictionary_)
- return 0;
-
- // Retrieve the positions where we can insert hyphens. This function assumes
- // the input word is an English word so it can use the position returned by
- // the hyphen library without conversion.
- base::string16 word_utf16(characters);
- if (!IsStringASCII(word_utf16))
- return 0;
- std::string word = StringToLowerASCII(UTF16ToASCII(word_utf16));
- scoped_ptr<char[]> hyphens(new char[word.length() + 5]);
- char** rep = NULL;
- int* pos = NULL;
- int* cut = NULL;
- int error = hnj_hyphen_hyphenate2(hyphen_dictionary_,
- word.data(),
- static_cast<int>(word.length()),
- hyphens.get(),
- NULL,
- &rep,
- &pos,
- &cut);
- if (error)
- return 0;
-
- // Release all resources allocated by the hyphen library now because they are
- // not used when hyphenating English words.
- if (rep) {
- for (size_t i = 0; i < word.length(); ++i) {
- if (rep[i])
- free(rep[i]);
- }
- free(rep);
- }
- if (pos)
- free(pos);
- if (cut)
- free(cut);
-
- // Retrieve the last position where we can insert a hyphen before the given
- // index.
- if (before_index >= 2) {
- for (size_t index = before_index - 2; index > 0; --index) {
- if (hyphens[index] & 1)
- return index + 1;
- }
- }
return 0;
}