From a6d92e37c93b224e7f8d682bf602456b4b412264 Mon Sep 17 00:00:00 2001 From: "tony@chromium.org" Date: Thu, 1 Aug 2013 04:13:48 +0000 Subject: 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 --- webkit/mocks/mock_webhyphenator.cc | 69 +------------------------------------- 1 file changed, 1 insertion(+), 68 deletions(-) (limited to 'webkit/mocks') 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 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(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; } -- cgit v1.1