summaryrefslogtreecommitdiffstats
path: root/webkit/mocks
diff options
context:
space:
mode:
authorabarth@chromium.org <abarth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-18 10:04:24 +0000
committerabarth@chromium.org <abarth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-18 10:04:24 +0000
commit548c74396980c10f9a337821c607d0920b5bd169 (patch)
tree74afe6fdb40da3b7f0df17d0f816be656ac57ed5 /webkit/mocks
parentf12cd9747d944f4a1afa3d046fd86337303d304a (diff)
downloadchromium_src-548c74396980c10f9a337821c607d0920b5bd169.zip
chromium_src-548c74396980c10f9a337821c607d0920b5bd169.tar.gz
chromium_src-548c74396980c10f9a337821c607d0920b5bd169.tar.bz2
WebHyphenator::computeLastHyphenLocation should use WebString
Previously, this API forced its caller to call WTF::String::bloatedCharacters to create a UChar array. If we accept a WebString instead, we can use a more efficient conversion from WTF::String to string16 that doesn't involve bloating the string. R=jamesr BUG=254708 Review URL: https://chromiumcodereview.appspot.com/19646004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@212316 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/mocks')
-rw-r--r--webkit/mocks/mock_webhyphenator.cc12
-rw-r--r--webkit/mocks/mock_webhyphenator.h10
2 files changed, 19 insertions, 3 deletions
diff --git a/webkit/mocks/mock_webhyphenator.cc b/webkit/mocks/mock_webhyphenator.cc
index 0432933..918c0e4 100644
--- a/webkit/mocks/mock_webhyphenator.cc
+++ b/webkit/mocks/mock_webhyphenator.cc
@@ -44,10 +44,20 @@ bool MockWebHyphenator::canHyphenate(const WebKit::WebString& locale) {
locale.equals("en_GB");
}
+// DEPRECATED
size_t MockWebHyphenator::computeLastHyphenLocation(
const char16* characters,
size_t length,
size_t before_index,
+ const WebKit::WebString& locale)
+{
+ return computeLastHyphenLocation(
+ WebKit::WebString(characters, length), before_index, locale);
+}
+
+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"));
@@ -57,7 +67,7 @@ size_t MockWebHyphenator::computeLastHyphenLocation(
// 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, length);
+ base::string16 word_utf16(characters);
if (!IsStringASCII(word_utf16))
return 0;
std::string word = StringToLowerASCII(UTF16ToASCII(word_utf16));
diff --git a/webkit/mocks/mock_webhyphenator.h b/webkit/mocks/mock_webhyphenator.h
index b42b17c9..456ba45 100644
--- a/webkit/mocks/mock_webhyphenator.h
+++ b/webkit/mocks/mock_webhyphenator.h
@@ -27,12 +27,18 @@ class MockWebHyphenator : public WebKit::WebHyphenator {
void LoadDictionary(base::PlatformFile dict_file);
// WebHyphenator implementation.
- virtual bool canHyphenate(const WebKit::WebString& locale) OVERRIDE;
+ virtual bool canHyphenate(const WebKit::WebString& locale);
+ virtual size_t computeLastHyphenLocation(
+ const WebKit::WebString& word,
+ size_t before_index,
+ const WebKit::WebString& locale);
+
+ // DEPRECATED
virtual size_t computeLastHyphenLocation(
const char16* characters,
size_t length,
size_t before_index,
- const WebKit::WebString& locale) OVERRIDE;
+ const WebKit::WebString& locale);
private:
HyphenDict* hyphen_dictionary_;