diff options
-rw-r--r-- | content/renderer/renderer_webkitplatformsupport_impl.cc | 22 | ||||
-rw-r--r-- | webkit/mocks/mock_webhyphenator.cc | 12 | ||||
-rw-r--r-- | webkit/mocks/mock_webhyphenator.h | 10 |
3 files changed, 39 insertions, 5 deletions
diff --git a/content/renderer/renderer_webkitplatformsupport_impl.cc b/content/renderer/renderer_webkitplatformsupport_impl.cc index b8b3795..c4d12b3 100644 --- a/content/renderer/renderer_webkitplatformsupport_impl.cc +++ b/content/renderer/renderer_webkitplatformsupport_impl.cc @@ -164,12 +164,19 @@ class RendererWebKitPlatformSupportImpl::Hyphenator Hyphenator(); virtual ~Hyphenator(); - 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: scoped_ptr<content::Hyphenator> hyphenator_; @@ -583,6 +590,7 @@ bool RendererWebKitPlatformSupportImpl::Hyphenator::canHyphenate( return hyphenator_->CanHyphenate(locale); } +// DEPRECATED size_t RendererWebKitPlatformSupportImpl::Hyphenator::computeLastHyphenLocation( const char16* characters, size_t length, @@ -595,6 +603,16 @@ size_t RendererWebKitPlatformSupportImpl::Hyphenator::computeLastHyphenLocation( before_index); } +size_t RendererWebKitPlatformSupportImpl::Hyphenator::computeLastHyphenLocation( + const WebKit::WebString& word, + size_t before_index, + const WebKit::WebString& locale) { + // Crash if WebKit calls this function when canHyphenate returns false. + DCHECK(locale.isEmpty() || locale.equals("en-US")); + DCHECK(hyphenator_.get()); + return hyphenator_->ComputeLastHyphenLocation(word, before_index); +} + //------------------------------------------------------------------------------ #if defined(OS_WIN) 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_; |