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

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, 4 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
Index: content/renderer/renderer_webkitplatformsupport_impl.cc
===================================================================
--- content/renderer/renderer_webkitplatformsupport_impl.cc (revision 152650)
+++ 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"
@@ -737,3 +738,37 @@
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. (As of today, there are few
+ // pages that use the hyphens property and it is good to create this object
+ // only when WebKit finds a page that needs hyphenation.)
tony 2012/08/22 19:05:50 Nit: I would remove the sentence in ()s. I don't
Hironori Bono 2012/08/27 06:57:28 Done. Thanks for your suggestion.
+ 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);
+}

Powered by Google App Engine
This is Rietveld 408576698