Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(103)

Unified Diff: content/renderer/renderer_webkitplatformsupport_impl.cc

Issue 10854245: In-te-grate hy-phen-ator to con-tent. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/renderer/renderer_webkitplatformsupport_impl.h ('k') | ipc/ipc_message_utils.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/renderer_webkitplatformsupport_impl.cc
===================================================================
--- content/renderer/renderer_webkitplatformsupport_impl.cc (revision 154648)
+++ content/renderer/renderer_webkitplatformsupport_impl.cc (working copy)
@@ -25,6 +25,7 @@
#include "content/public/renderer/content_renderer_client.h"
#include "content/renderer/dom_storage/webstoragenamespace_impl.h"
#include "content/renderer/gamepad_shared_memory_reader.h"
+#include "content/renderer/hyphenator/hyphenator.h"
#include "content/renderer/media/audio_hardware.h"
#include "content/renderer/media/renderer_webaudiodevice_impl.h"
#include "content/renderer/render_thread_impl.h"
@@ -708,3 +709,35 @@
RendererWebKitPlatformSupportImpl::GetGpuChannelHostFactory() {
return RenderThreadImpl::current();
}
+
+//------------------------------------------------------------------------------
+
+bool RendererWebKitPlatformSupportImpl::canHyphenate(
+ const WebKit::WebString& locale) {
+ // Return false unless WebKit asks for US English dictionaries because WebKit
+ // can currently hyphenate only English words.
+ if (!locale.isEmpty() && !locale.equals("en-US"))
+ return false;
+
+ // Create a hyphenator object and attach it to the render thread so it can
+ // receive a dictionary file opened by a browser.
+ if (!hyphenator_.get()) {
+ hyphenator_.reset(new content::Hyphenator(base::kInvalidPlatformFileValue));
+ if (!hyphenator_.get())
+ return false;
+ return hyphenator_->Attach(RenderThreadImpl::current(), locale);
+ }
+ return hyphenator_->CanHyphenate(locale);
+}
+
+size_t RendererWebKitPlatformSupportImpl::computeLastHyphenLocation(
+ const char16* characters,
+ size_t length,
+ 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(string16(characters, length),
+ before_index);
+}
« no previous file with comments | « content/renderer/renderer_webkitplatformsupport_impl.h ('k') | ipc/ipc_message_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698