diff options
Diffstat (limited to 'content')
26 files changed, 1 insertions, 1066 deletions
diff --git a/content/browser/hyphenator/hyphenator_message_filter.cc b/content/browser/hyphenator/hyphenator_message_filter.cc deleted file mode 100644 index 5e580d8..0000000 --- a/content/browser/hyphenator/hyphenator_message_filter.cc +++ /dev/null @@ -1,120 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "base/base_paths.h" -#include "base/bind.h" -#include "base/logging.h" -#include "base/path_service.h" -#include "base/strings/string16.h" -#include "content/browser/hyphenator/hyphenator_message_filter.h" -#include "content/common/hyphenator_messages.h" -#include "content/public/browser/browser_thread.h" -#include "content/public/browser/content_browser_client.h" -#include "content/public/browser/render_process_host.h" - -namespace content { - -namespace { - -// A helper function that closes the specified file in the FILE thread. This -// function may be called after the HyphenatorMessageFilter object that owns the -// specified file is deleted, i.e. this function must not depend on the object. -void CloseDictionary(base::PlatformFile file) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); - base::ClosePlatformFile(file); -} - -} // namespace - -HyphenatorMessageFilter::HyphenatorMessageFilter( - RenderProcessHost* render_process_host) - : render_process_host_(render_process_host), - dictionary_file_(base::kInvalidPlatformFileValue), - weak_factory_(this) { -} - -HyphenatorMessageFilter::~HyphenatorMessageFilter() { - // Post a FILE task that deletes the dictionary file. This message filter is - // usually deleted on the IO thread, which does not allow file operations. - if (dictionary_file_ != base::kInvalidPlatformFileValue) { - BrowserThread::PostTask( - BrowserThread::FILE, - FROM_HERE, - base::Bind(&CloseDictionary, dictionary_file_)); - } -} - -void HyphenatorMessageFilter::SetDictionaryBase(const base::FilePath& base) { - dictionary_base_ = base; -} - -void HyphenatorMessageFilter::OverrideThreadForMessage( - const IPC::Message& message, - BrowserThread::ID* thread) { - if (message.type() == HyphenatorHostMsg_OpenDictionary::ID) - *thread = BrowserThread::UI; -} - -bool HyphenatorMessageFilter::OnMessageReceived( - const IPC::Message& message, - bool* message_was_ok) { - bool handled = true; - IPC_BEGIN_MESSAGE_MAP_EX(HyphenatorMessageFilter, - message, - *message_was_ok) - IPC_MESSAGE_HANDLER(HyphenatorHostMsg_OpenDictionary, OnOpenDictionary) - IPC_MESSAGE_UNHANDLED(handled = false) - IPC_END_MESSAGE_MAP_EX() - return handled; -} - -void HyphenatorMessageFilter::OnOpenDictionary(const string16& locale) { - if (dictionary_file_ != base::kInvalidPlatformFileValue) { - SendDictionary(); - return; - } - BrowserThread::PostTaskAndReply( - BrowserThread::FILE, - FROM_HERE, - base::Bind(&HyphenatorMessageFilter::OpenDictionary, this, locale), - base::Bind(&HyphenatorMessageFilter::SendDictionary, - weak_factory_.GetWeakPtr())); -} - -void HyphenatorMessageFilter::OpenDictionary(const string16& locale) { - DCHECK(dictionary_file_ == base::kInvalidPlatformFileValue); - - if (dictionary_base_.empty()) { - dictionary_base_ = - GetContentClient()->browser()->GetHyphenDictionaryDirectory(); - } - std::string rule_file = locale.empty() ? "en-US" : UTF16ToASCII(locale); - - // Currently, only en-US is hyphenated. This is a quick fix for - // http://crbug.com/167122. - // TODO(groby): The proper fix entails validating if locale is a properly - // formatted locale string, but knowledge about valid locales currently - // resides in chrome, not content. - if (rule_file != "en-US") - return; - rule_file.append("-1-0.dic"); - base::FilePath rule_path = dictionary_base_.AppendASCII(rule_file); - dictionary_file_ = base::CreatePlatformFile( - rule_path, - base::PLATFORM_FILE_READ | base::PLATFORM_FILE_OPEN, - NULL, NULL); -} - -void HyphenatorMessageFilter::SendDictionary() { - IPC::PlatformFileForTransit file = IPC::InvalidPlatformFileForTransit(); - if (dictionary_file_ != base::kInvalidPlatformFileValue) { - file = IPC::GetFileHandleForProcess( - dictionary_file_, - render_process_host_->GetHandle(), - false); - } - Send(new HyphenatorMsg_SetDictionary(file)); -} - -} // namespace content diff --git a/content/browser/hyphenator/hyphenator_message_filter.h b/content/browser/hyphenator/hyphenator_message_filter.h deleted file mode 100644 index a5ed21c..0000000 --- a/content/browser/hyphenator/hyphenator_message_filter.h +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CONTENT_BROWSER_HYPHENATOR_HYPHENATOR_MESSAGE_FILTER_H_ -#define CONTENT_BROWSER_HYPHENATOR_HYPHENATOR_MESSAGE_FILTER_H_ - -#include "base/compiler_specific.h" -#include "base/files/file_path.h" -#include "base/memory/weak_ptr.h" -#include "base/platform_file.h" -#include "content/common/content_export.h" -#include "content/public/browser/browser_message_filter.h" - -namespace content { -class RenderProcessHost; - -// This class is a message filter that handles a HyphenatorHost message. When -// this class receives a HyphenatorHostMsg_OpenDictionary message, it opens the -// specified dictionary and sends its file handle. -class CONTENT_EXPORT HyphenatorMessageFilter : public BrowserMessageFilter { - public: - explicit HyphenatorMessageFilter(RenderProcessHost* render_process_host); - - // Changes the directory that includes dictionary files. This function - // provides a method that allows applications to change the directory - // containing hyphenation dictionaries. When a renderer requests a hyphnation - // dictionary, this class appends a file name (which consists of a locale, a - // version number, and an extension) and use it as a dictionary file. - void SetDictionaryBase(const base::FilePath& directory); - - // BrowserMessageFilter implementation. - virtual void OverrideThreadForMessage( - const IPC::Message& message, - BrowserThread::ID* thread) OVERRIDE; - virtual bool OnMessageReceived(const IPC::Message& message, - bool* message_was_ok) OVERRIDE; - - private: - friend class TestHyphenatorMessageFilter; - - virtual ~HyphenatorMessageFilter(); - - virtual void OnOpenDictionary(const string16& locale); - - // Opens a hyphenation dictionary for the specified locale. When this locale - // is an empty string, this function uses US English ("en-US"). - void OpenDictionary(const string16& locale); - - // Sends the hyphenation dictionary file to a renderer in response to its - // request. If this class cannot open the specified dictionary file, this - // function sends an IPC::InvalidPlatformFileForTransit value to tell the - // renderer that a browser cannot open the file. - void SendDictionary(); - - // The RenderProcessHost object that owns this filter. This class uses this - // object to retrieve the process handle used for creating - // PlatformFileForTransit objects. - RenderProcessHost* render_process_host_; - - // The directory that includes dictionary files. The default value is the - // directory containing the executable file. - base::FilePath dictionary_base_; - - // A cached dictionary file. - base::PlatformFile dictionary_file_; - - base::WeakPtrFactory<HyphenatorMessageFilter> weak_factory_; - - DISALLOW_COPY_AND_ASSIGN(HyphenatorMessageFilter); -}; - -} // namespace content - -#endif // CONTENT_BROWSER_HYPHENATOR_HYPHENATOR_MESSAGE_FILTER_H_ diff --git a/content/browser/hyphenator/hyphenator_message_filter_unittest.cc b/content/browser/hyphenator/hyphenator_message_filter_unittest.cc deleted file mode 100644 index e62210d..0000000 --- a/content/browser/hyphenator/hyphenator_message_filter_unittest.cc +++ /dev/null @@ -1,154 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "content/browser/hyphenator/hyphenator_message_filter.h" - -#include "base/base_paths.h" -#include "base/files/file_path.h" -#include "base/path_service.h" -#include "base/strings/string16.h" -#include "base/strings/utf_string_conversions.h" -#include "content/common/hyphenator_messages.h" -#include "content/public/test/mock_render_process_host.h" -#include "content/public/test/test_browser_context.h" -#include "ipc/ipc_message_utils.h" -#include "ipc/ipc_platform_file.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace content { - -// A class derived from the HyphenatorMessageFilter class used in unit tests. -// This class overrides some methods so we can test the HyphenatorMessageFilter -// class without posting tasks. -class TestHyphenatorMessageFilter : public HyphenatorMessageFilter { - public: - explicit TestHyphenatorMessageFilter(RenderProcessHost* host) - : HyphenatorMessageFilter(host), - type_(0), - file_(base::kInvalidPlatformFileValue) { - } - - const string16& locale() const { return locale_; } - uint32 type() const { return type_; } - base::PlatformFile file() const { return file_; } - - // BrowserMessageFilter implementation. - virtual bool Send(IPC::Message* message) OVERRIDE { - if (message->type() != HyphenatorMsg_SetDictionary::ID) - return false; - - // Read the PlatformFileForTransit object and check if its value is - // kInvalidPlatformFileValue. Close the incoming file if it is not - // kInvalidPlatformFileValue to prevent leaving the dictionary file open. - type_ = message->type(); - PickleIterator iter(*message); - IPC::PlatformFileForTransit file; - IPC::ParamTraits<IPC::PlatformFileForTransit>::Read(message, &iter, &file); - file_ = IPC::PlatformFileForTransitToPlatformFile(file); - delete message; - return true; - } - - void SetDictionary(base::PlatformFile file) { - dictionary_file_ = file; - } - - void Reset() { - if (dictionary_file_ != base::kInvalidPlatformFileValue) { - base::ClosePlatformFile(dictionary_file_); - dictionary_file_ = base::kInvalidPlatformFileValue; - } - locale_.clear(); - type_ = 0; - if (file_ != base::kInvalidPlatformFileValue) { - base::ClosePlatformFile(file_); - file_ = base::kInvalidPlatformFileValue; - } - } - - private: - virtual ~TestHyphenatorMessageFilter() { - } - - // HyphenatorMessageFilter implementation. This function emulates the - // original implementation without posting a task. - virtual void OnOpenDictionary(const string16& locale) OVERRIDE { - locale_ = locale; - if (dictionary_file_ == base::kInvalidPlatformFileValue) - OpenDictionary(locale); - SendDictionary(); - } - - string16 locale_; - uint32 type_; - base::PlatformFile file_; -}; - -class HyphenatorMessageFilterTest : public testing::Test { - public: - HyphenatorMessageFilterTest() { - context_.reset(new TestBrowserContext); - host_.reset(new MockRenderProcessHost(context_.get())); - filter_ = new TestHyphenatorMessageFilter(host_.get()); - } - - virtual ~HyphenatorMessageFilterTest() {} - - scoped_ptr<TestBrowserContext> context_; - scoped_ptr<MockRenderProcessHost> host_; - scoped_refptr<TestHyphenatorMessageFilter> filter_; -}; - -// Verifies IPC messages sent by the HyphenatorMessageFilter class when it -// receives IPC messages (HyphenatorHostMsg_OpenDictionary). -TEST_F(HyphenatorMessageFilterTest, OpenDictionary) { - // Send a HyphenatorHostMsg_OpenDictionary message with an invalid locale and - // verify it sends a HyphenatorMsg_SetDictionary message with an invalid file. - string16 invalid_locale(ASCIIToUTF16("xx-xx")); - IPC::Message invalid_message( - 0, HyphenatorHostMsg_OpenDictionary::ID, IPC::Message::PRIORITY_NORMAL); - invalid_message.WriteString16(invalid_locale); - - bool message_was_ok = false; - filter_->OnMessageReceived(invalid_message, &message_was_ok); - EXPECT_TRUE(message_was_ok); - EXPECT_EQ(invalid_locale, filter_->locale()); - EXPECT_EQ(HyphenatorMsg_SetDictionary::ID, filter_->type()); - EXPECT_EQ(base::kInvalidPlatformFileValue, filter_->file()); - - filter_->Reset(); - - // Open a sample dictionary file and attach it to the - // HyphenatorMessageFilter class so it can return a valid file. - base::FilePath path; - PathService::Get(base::DIR_SOURCE_ROOT, &path); - path = path.Append(FILE_PATH_LITERAL("third_party")); - path = path.Append(FILE_PATH_LITERAL("hyphen")); - path = path.Append(FILE_PATH_LITERAL("hyph_en_US.dic")); - base::PlatformFile file = base::CreatePlatformFile( - path, base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ, - NULL, NULL); - EXPECT_NE(base::kInvalidPlatformFileValue, file); - filter_->SetDictionary(file); - file = base::kInvalidPlatformFileValue; // Ownership has been transferred. - - // Send a HyphenatorHostMsg_OpenDictionary message with an empty locale and - // verify it sends a HyphenatorMsg_SetDictionary message with a valid file. - string16 empty_locale; - IPC::Message valid_message( - 0, HyphenatorHostMsg_OpenDictionary::ID, IPC::Message::PRIORITY_NORMAL); - valid_message.WriteString16(empty_locale); - - message_was_ok = false; - filter_->OnMessageReceived(valid_message, &message_was_ok); - EXPECT_TRUE(message_was_ok); - EXPECT_EQ(empty_locale, filter_->locale()); - EXPECT_EQ(HyphenatorMsg_SetDictionary::ID, filter_->type()); - EXPECT_NE(base::kInvalidPlatformFileValue, filter_->file()); - - // Delete all resources used by this test. - filter_->Reset(); -} - -} // namespace content diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc index c272ef9..53a6fde 100644 --- a/content/browser/renderer_host/render_process_host_impl.cc +++ b/content/browser/renderer_host/render_process_host_impl.cc @@ -54,7 +54,6 @@ #include "content/browser/gpu/gpu_process_host.h" #include "content/browser/gpu/shader_disk_cache.h" #include "content/browser/histogram_message_filter.h" -#include "content/browser/hyphenator/hyphenator_message_filter.h" #include "content/browser/indexed_db/indexed_db_context_impl.h" #include "content/browser/indexed_db/indexed_db_dispatcher_host.h" #include "content/browser/loader/resource_message_filter.h" @@ -721,7 +720,6 @@ void RenderProcessHostImpl::CreateMessageFilters() { channel_->AddFilter(new DeviceMotionBrowserMessageFilter()); channel_->AddFilter(new ProfilerMessageFilter(PROCESS_TYPE_RENDERER)); channel_->AddFilter(new HistogramMessageFilter()); - channel_->AddFilter(new HyphenatorMessageFilter(this)); #if defined(USE_TCMALLOC) && (defined(OS_LINUX) || defined(OS_ANDROID)) if (CommandLine::ForCurrentProcess()->HasSwitch( switches::kEnableMemoryBenchmarking)) diff --git a/content/common/content_message_generator.h b/content/common/content_message_generator.h index e7f0786..f1c88e9 100644 --- a/content/common/content_message_generator.h +++ b/content/common/content_message_generator.h @@ -25,7 +25,6 @@ #include "content/common/gamepad_messages.h" #include "content/common/geolocation_messages.h" #include "content/common/gpu/gpu_messages.h" -#include "content/common/hyphenator_messages.h" #include "content/common/image_messages.h" #include "content/common/indexed_db/indexed_db_messages.h" #include "content/common/input_messages.h" diff --git a/content/common/hyphenator_messages.h b/content/common/hyphenator_messages.h deleted file mode 100644 index e68985d..0000000 --- a/content/common/hyphenator_messages.h +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// IPC messages for hyphenation. -// Message definition file, included multiple times, hence no include guard. - -#include "ipc/ipc_message_macros.h" -#include "ipc/ipc_platform_file.h" - -#define IPC_MESSAGE_START HyphenatorMsgStart - -// Opens the specified hyphenation dictionary. This message is expected to be -// sent when WebKit calls the canHyphenate function, i.e. when it starts -// layouting text. At this time, WebKit does not actually need this dictionary -// to hyphenate words. Therefore, a renderer does not need to wait for a browser -// to open the specified dictionary. -IPC_MESSAGE_CONTROL1(HyphenatorHostMsg_OpenDictionary, - string16 /* locale */) - -// Sends the hyphenation dictionary to the renderer. This messages is sent in -// response to a HyphenatorHostMsg_OpenDictionary message. -IPC_MESSAGE_CONTROL1(HyphenatorMsg_SetDictionary, - IPC::PlatformFileForTransit /* dict_file */) diff --git a/content/content_browser.gypi b/content/content_browser.gypi index 315f502..66cfb54 100644 --- a/content/content_browser.gypi +++ b/content/content_browser.gypi @@ -574,8 +574,6 @@ 'browser/histogram_synchronizer.h', 'browser/host_zoom_map_impl.cc', 'browser/host_zoom_map_impl.h', - 'browser/hyphenator/hyphenator_message_filter.cc', - 'browser/hyphenator/hyphenator_message_filter.h', 'browser/indexed_db/indexed_db.h', 'browser/indexed_db/indexed_db_backing_store.cc', 'browser/indexed_db/indexed_db_backing_store.h', diff --git a/content/content_renderer.gypi b/content/content_renderer.gypi index f2117cf..0f61411 100644 --- a/content/content_renderer.gypi +++ b/content/content_renderer.gypi @@ -9,7 +9,6 @@ '../net/net.gyp:net', '../skia/skia.gyp:skia', '../third_party/WebKit/public/blink.gyp:blink', - '../third_party/hyphen/hyphen.gyp:hyphen', '../third_party/icu/icu.gyp:icui18n', '../third_party/icu/icu.gyp:icuuc', '../third_party/libjingle/libjingle.gyp:libjingle', @@ -135,8 +134,6 @@ 'renderer/gpu/stream_texture_host_android.h', 'renderer/gpu/render_widget_compositor.cc', 'renderer/gpu/render_widget_compositor.h', - 'renderer/hyphenator/hyphenator.cc', - 'renderer/hyphenator/hyphenator.h', 'renderer/idle_user_detector.cc', 'renderer/idle_user_detector.h', 'renderer/image_loading_helper.cc', diff --git a/content/content_tests.gypi b/content/content_tests.gypi index 76468fa..587234e 100644 --- a/content/content_tests.gypi +++ b/content/content_tests.gypi @@ -308,7 +308,6 @@ 'browser/geolocation/win7_location_provider_unittest_win.cc', 'browser/gpu/shader_disk_cache_unittest.cc', 'browser/host_zoom_map_impl_unittest.cc', - 'browser/hyphenator/hyphenator_message_filter_unittest.cc', 'browser/indexed_db/indexed_db_backing_store_unittest.cc', 'browser/indexed_db/indexed_db_cleanup_on_io_error_unittest.cc', 'browser/indexed_db/indexed_db_database_unittest.cc', @@ -418,7 +417,6 @@ 'renderer/disambiguation_popup_helper_unittest.cc', 'renderer/gpu/input_event_filter_unittest.cc', 'renderer/gpu/input_handler_proxy_unittest.cc', - 'renderer/hyphenator/hyphenator_unittest.cc', 'renderer/ico_image_decoder_unittest.cc', 'renderer/media/android/media_info_loader_unittest.cc', 'renderer/media/audio_message_filter_unittest.cc', diff --git a/content/content_unittests.isolate b/content/content_unittests.isolate index 9a9def4..94e3863 100644 --- a/content/content_unittests.isolate +++ b/content/content_unittests.isolate @@ -5,9 +5,6 @@ 'conditions': [ ['OS=="android" or OS=="linux" or OS=="mac" or OS=="win"', { 'variables': { - 'isolate_dependency_tracked': [ - '../third_party/hyphen/hyph_en_US.dic', - ], 'isolate_dependency_untracked': [ '../media/test/data/', '../webkit/data/', diff --git a/content/public/browser/content_browser_client.cc b/content/public/browser/content_browser_client.cc index 3d73a1e..c2bf137 100644 --- a/content/public/browser/content_browser_client.cc +++ b/content/public/browser/content_browser_client.cc @@ -273,10 +273,6 @@ bool ContentBrowserClient::AllowPepperSocketAPI( return false; } -base::FilePath ContentBrowserClient::GetHyphenDictionaryDirectory() { - return base::FilePath(); -} - ui::SelectFilePolicy* ContentBrowserClient::CreateSelectFilePolicy( WebContents* web_contents) { return NULL; diff --git a/content/public/browser/content_browser_client.h b/content/public/browser/content_browser_client.h index e169205..d1b022b 100644 --- a/content/public/browser/content_browser_client.h +++ b/content/public/browser/content_browser_client.h @@ -542,9 +542,6 @@ class CONTENT_EXPORT ContentBrowserClient { bool private_api, const SocketPermissionRequest& params); - // Returns the directory containing hyphenation dictionaries. - virtual base::FilePath GetHyphenDictionaryDirectory(); - // Returns an implementation of a file selecition policy. Can return NULL. virtual ui::SelectFilePolicy* CreateSelectFilePolicy( WebContents* web_contents); diff --git a/content/public/renderer/content_renderer_client.cc b/content/public/renderer/content_renderer_client.cc index 1f9e45a..a94fb2d 100644 --- a/content/public/renderer/content_renderer_client.cc +++ b/content/public/renderer/content_renderer_client.cc @@ -70,10 +70,6 @@ WebKit::WebClipboard* ContentRendererClient::OverrideWebClipboard() { return NULL; } -WebKit::WebHyphenator* ContentRendererClient::OverrideWebHyphenator() { - return NULL; -} - WebKit::WebThemeEngine* ContentRendererClient::OverrideThemeEngine() { return NULL; } diff --git a/content/public/renderer/content_renderer_client.h b/content/public/renderer/content_renderer_client.h index ebe9470..7730927 100644 --- a/content/public/renderer/content_renderer_client.h +++ b/content/public/renderer/content_renderer_client.h @@ -30,7 +30,6 @@ class WebAudioDevice; class WebClipboard; class WebCrypto; class WebFrame; -class WebHyphenator; class WebMIDIAccessor; class WebMIDIAccessorClient; class WebMediaStreamCenter; @@ -146,10 +145,6 @@ class CONTENT_EXPORT ContentRendererClient { // returns NULL the content layer will handle clipboard interactions. virtual WebKit::WebClipboard* OverrideWebClipboard(); - // Allows the embedder to override the WebKit::WebHyphenator used. If it - // returns NULL the content layer will handle hyphenation. - virtual WebKit::WebHyphenator* OverrideWebHyphenator(); - // Allows the embedder to override the WebThemeEngine used. If it returns NULL // the content layer will provide an engine. virtual WebKit::WebThemeEngine* OverrideThemeEngine(); diff --git a/content/renderer/hyphenator/hyphenator.cc b/content/renderer/hyphenator/hyphenator.cc deleted file mode 100644 index b94ba3c..0000000 --- a/content/renderer/hyphenator/hyphenator.cc +++ /dev/null @@ -1,270 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "content/renderer/hyphenator/hyphenator.h" - -#include "base/files/memory_mapped_file.h" -#include "base/logging.h" -#include "base/memory/scoped_ptr.h" -#include "base/strings/string_util.h" -#include "base/strings/utf_string_conversions.h" -#include "content/common/hyphenator_messages.h" -#include "content/public/renderer/render_thread.h" -#include "third_party/hyphen/hyphen.h" -#include "third_party/icu/source/common/unicode/uscript.h" - -namespace { - -// A class that converts a sequence of UTF-8 characters to UTF-16 ones and holds -// only the length of converted UTF-16 characters. This class is used for -// creating a mapping from the position of a UTF-8 string to a position of a -// UTF-16 string without unnecessary conversions. Even though the following -// snippet produces the same mapping, it needs to convert same characters many -// times. This class incrementally counts the number of converted UTF-16 -// characters to avoid this problem. -// -// scoped_ptr<size_t[]> position(new size_t[text.length()]); -// for (size_t i = 0; i < text.length(); ++i) -// position[i] = UTF8ToUTF16(text.substr(0, i)).length(); -// -class UTF16TextLength { - public: - UTF16TextLength(); - ~UTF16TextLength(); - - // Returns the current position. - int utf16_length() const { return utf16_length_; } - - // Appends one UTF-8 character to this converter and advances the converted - // position. This converter increases the position by one when it finishes - // reading a BMP character and increases by two when it finish reading a - // non-BMP character. - void Append(char c); - - private: - // The length of the converted UTF-16 text. - int utf16_length_; - - // The buffer that stores UTF-8 characters being converted. - std::string utf8_text_; - - DISALLOW_COPY_AND_ASSIGN(UTF16TextLength); -}; - -UTF16TextLength::UTF16TextLength() - : utf16_length_(0) { -} - -UTF16TextLength::~UTF16TextLength() { -} - -void UTF16TextLength::Append(char c) { - // Append the given character and try converting the UTF-8 characters in this - // buffer to Unicode codepoints. If this buffer includes a Unicode codepoint, - // get the number of UTF-16 characters representing this codepoint and advance - // the position. - int code = 0; - int index = 0; - utf8_text_.push_back(c); - U8_NEXT(utf8_text_.data(), index, static_cast<int>(utf8_text_.length()), - code); - if (code != U_SENTINEL) { - utf8_text_.clear(); - utf16_length_ += U16_LENGTH(code); - } -} - -// A class that encapsulates a hyphenation query. This class owns resources -// temporarily needed for hyphenating one word, and deletes them when it is -// deleted as listed in the following snippet. -// -// std::vector<int> hyphens; -// QUery query(UTF8ToUTF16("hyphenate")); -// query.Hyphenate(dict, &hyphens); -// -class Query { - public: - explicit Query(const string16& word); - ~Query(); - - // Hyphenates a word with the specified dictionary. This function hyphenates - // the word provided to its constructor and returns a list of hyphenation - // points, positions where we can insert hyphens. - bool Hyphenate(HyphenDict* dictionary, std::vector<int>* hyphen_offsets); - - private: - // A word to be hyphenated. - std::string word_utf8_; - - // Return variables from the hyphen library. - scoped_ptr<char[]> hyphen_vector_; - char** rep_; - int* pos_; - int* cut_; - - DISALLOW_COPY_AND_ASSIGN(Query); -}; - -Query::Query(const string16& word) - : rep_(NULL), - pos_(NULL), - cut_(NULL) { - // Remove trailing punctuation characters. WebKit does not remove these - // characters when it hyphenates a word. These characters prevent the hyphen - // library from applying some rules, i.e. they prevent the library from adding - // hyphens. - DCHECK(!word.empty()); - const char16* data = word.data(); - int length = static_cast<int>(word.length()); - while (length > 0) { - int previous = length; - int code = 0; - U16_PREV(data, 0, previous, code); - UErrorCode error = U_ZERO_ERROR; - if (uscript_getScript(code, &error) != USCRIPT_COMMON) - break; - length = previous; - } - UTF16ToUTF8(word.c_str(), length, &word_utf8_); - // Create a hyphen vector used by hnj_hyphen_hyphenate2(). We allocate a - // buffer of |word_.length()| + 5 as written in Line 112 of - // <http://cs.chromium.org/src/third_party/hyphen/hyphen.h>. - hyphen_vector_.reset(new char[word_utf8_.length() + 5]); -} - -Query::~Query() { - if (rep_) { - for (size_t i = 0; i < word_utf8_.length(); ++i) { - if (rep_[i]) - free(rep_[i]); - } - free(rep_); - } - if (pos_) - free(pos_); - if (cut_) - free(cut_); -} - -bool Query::Hyphenate(HyphenDict* dictionary, - std::vector<int>* hyphen_offsets) { - DCHECK(dictionary); - DCHECK(hyphen_offsets); - - int error_code = hnj_hyphen_hyphenate2(dictionary, - word_utf8_.data(), - static_cast<int>(word_utf8_.length()), - hyphen_vector_.get(), - NULL, - &rep_, - &pos_, - &cut_); - if (error_code) - return false; - - // WebKit needs hyphenation points counted in UTF-16 characters. On the other - // hand, the hyphen library returns hyphenation points counted in UTF-8 - // characters. We increamentally convert hyphenation points in UTF-8 - // characters to hyphenation points in UTF-16 characters and write the - // converted hyphenation points to the output vector. - UTF16TextLength text_length; - hyphen_offsets->clear(); - for (size_t i = 0; i < word_utf8_.length(); ++i) { - text_length.Append(word_utf8_[i]); - if (hyphen_vector_[i] & 1) - hyphen_offsets->push_back(text_length.utf16_length()); - } - return !hyphen_offsets->empty(); -} - -} // namespace - -namespace content { - -Hyphenator::Hyphenator(base::PlatformFile file) - : dictionary_(NULL), - dictionary_file_(base::FdopenPlatformFile(file, "r")), - result_(0) { -} - -Hyphenator::~Hyphenator() { - if (dictionary_) - hnj_hyphen_free(dictionary_); -} - -bool Hyphenator::Initialize() { - if (dictionary_) - return true; - - if (!dictionary_file_.get()) - return false; - dictionary_ = hnj_hyphen_load_file(dictionary_file_.get()); - return !!dictionary_; -} - -bool Hyphenator::Attach(RenderThread* thread, const string16& locale) { - if (!thread) - return false; - locale_.assign(locale); - thread->AddObserver(this); - return thread->Send(new HyphenatorHostMsg_OpenDictionary(locale)); -} - -bool Hyphenator::CanHyphenate(const string16& locale) { - return !locale_.compare(locale); -} - -size_t Hyphenator::ComputeLastHyphenLocation(const string16& word, - size_t before_index) { - if (!Initialize() || word.empty()) - return 0; - - // Call the hyphen library to get all hyphenation points, i.e. positions where - // we can insert hyphens. When WebKit finds a line-break, it calls this - // function twice or more with the same word to find the best hyphenation - // point. To avoid calling the hyphen library twice or more with the same - // word, we cache the last query. - if (word_ != word) { - word_ = word; - Query query(word); - result_ = query.Hyphenate(dictionary_, &hyphen_offsets_); - } - if (!result_) - return 0; - for (std::vector<int>::reverse_iterator it = hyphen_offsets_.rbegin(); - it != hyphen_offsets_.rend(); ++it) { - if (static_cast<size_t>(*it) < before_index) - return *it; - } - return 0; -} - -bool Hyphenator::OnControlMessageReceived(const IPC::Message& message) { - bool handled = true; - IPC_BEGIN_MESSAGE_MAP(Hyphenator, message) - IPC_MESSAGE_HANDLER(HyphenatorMsg_SetDictionary, OnSetDictionary) - IPC_MESSAGE_UNHANDLED(handled = false) - IPC_END_MESSAGE_MAP() - return handled; -} - -void Hyphenator::OnSetDictionary(IPC::PlatformFileForTransit file) { - base::PlatformFile rule_file = - IPC::PlatformFileForTransitToPlatformFile(file); - if (rule_file == base::kInvalidPlatformFileValue) - return; - // Delete the current dictionary and save the given file to this object. We - // initialize the hyphen library the first time when WebKit actually - // hyphenates a word, i.e. when WebKit calls the ComputeLastHyphenLocation - // function. (WebKit does not always hyphenate words even when it calls the - // CanHyphenate function, e.g. WebKit does not have to hyphenate words when it - // does not have to break text into lines.) - if (dictionary_) { - hnj_hyphen_free(dictionary_); - dictionary_ = NULL; - } - dictionary_file_.Set(base::FdopenPlatformFile(rule_file, "r")); -} - -} // namespace content diff --git a/content/renderer/hyphenator/hyphenator.h b/content/renderer/hyphenator/hyphenator.h deleted file mode 100644 index 24454cd..0000000 --- a/content/renderer/hyphenator/hyphenator.h +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CONTENT_RENDERER_HYPHENATOR_HYPHENATOR_H_ -#define CONTENT_RENDERER_HYPHENATOR_HYPHENATOR_H_ - -#include <vector> - -#include "base/memory/scoped_handle.h" -#include "base/platform_file.h" -#include "base/strings/string16.h" -#include "content/common/content_export.h" -#include "content/public/renderer/render_process_observer.h" -#include "ipc/ipc_platform_file.h" - -typedef struct _HyphenDict HyphenDict; - -namespace content { -class RenderThread; - -// A class that hyphenates a word. This class encapsulates the hyphen library -// and manages resources used by the library. When this class uses a huge -// dictionary, it takes lots of memory (~1.3MB for English). A renderer should -// create this object only when it renders a page that needs hyphenation and -// deletes it when it moves to a page that does not need hyphenation. -class CONTENT_EXPORT Hyphenator : public RenderProcessObserver { - public: - explicit Hyphenator(base::PlatformFile file); - virtual ~Hyphenator(); - - // Initializes the hyphen library and allocates resources needed for - // hyphenation. - bool Initialize(); - - bool Attach(RenderThread* thread, const string16& locale); - - // Returns whether this object can hyphenate words. When this object does not - // have a dictionary file attached, this function sends an IPC request to open - // the file. - bool CanHyphenate(const string16& locale); - - // Returns the last hyphenation point, the position where we can insert a - // hyphen, before the given position. If there are not any hyphenation points, - // this function returns 0. - size_t ComputeLastHyphenLocation(const string16& word, size_t before_index); - - // RenderProcessObserver implementation. - virtual bool OnControlMessageReceived(const IPC::Message& message) OVERRIDE; - - private: - void OnSetDictionary(IPC::PlatformFileForTransit rule_file); - - // The dictionary used by the hyphen library. - HyphenDict* dictionary_; - - string16 locale_; - ScopedStdioHandle dictionary_file_; - - // A cached result. WebKit often calls ComputeLastHyphenLocation with the same - // word multiple times to find the best hyphenation point when it finds a line - // break. On the other hand, the hyphen library returns all hyphenation points - // for a word. This class caches the hyphenation points returned by the hyphen - // library to avoid calling the library multiple times. - string16 word_; - bool result_; - std::vector<int> hyphen_offsets_; - - DISALLOW_COPY_AND_ASSIGN(Hyphenator); -}; - -} // namespace content - -#endif // CONTENT_RENDERER_HYPHENATOR_HYPHENATOR_H_ diff --git a/content/renderer/hyphenator/hyphenator_unittest.cc b/content/renderer/hyphenator/hyphenator_unittest.cc deleted file mode 100644 index 02e2bc9..0000000 --- a/content/renderer/hyphenator/hyphenator_unittest.cc +++ /dev/null @@ -1,191 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "content/renderer/hyphenator/hyphenator.h" - -#include "base/path_service.h" -#include "base/platform_file.h" -#include "base/strings/utf_string_conversions.h" -#include "content/common/hyphenator_messages.h" -#include "content/public/test/mock_render_thread.h" -#include "ipc/ipc_listener.h" -#include "testing/gtest/include/gtest/gtest.h" -#include "third_party/hyphen/hyphen.h" - -namespace content { -namespace { - -// A mock message listener that listens for HyphenatorHost messages. This class -// intercepts a HyphenatorHostMsg_OpenDictionary message sent to an -// IPC::TestSink object and emulates the HyphenatorMessageFilter class. -class MockListener : public IPC::Listener { - public: - MockListener(Hyphenator* hyphenator, const string16& locale) - : hyphenator_(hyphenator), - locale_(locale) { - } - virtual ~MockListener() { - } - - // IPC::ChannelProxy::MessageFilter implementation. - virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE { - if (message.type() != HyphenatorHostMsg_OpenDictionary::ID) - return false; - - // Retrieve the locale parameter directly because HyphenatorHost messages - // are internal messages and unit tests cannot access its member functions, - // i.e. unit tests cannot call the HyphenatorHostMsg_OpenDictionary::Read - // function. - PickleIterator iter(message); - string16 locale; - EXPECT_TRUE(message.ReadString16(&iter, &locale)); - EXPECT_EQ(locale_, locale); - - // Open the default dictionary and call the OnControllMessageReceived - // function with a HyphenatorMsg_SetDictionary message. - base::FilePath dictionary_path; - if (!PathService::Get(base::DIR_SOURCE_ROOT, &dictionary_path)) - return false; - dictionary_path = dictionary_path.AppendASCII("third_party"); - dictionary_path = dictionary_path.AppendASCII("hyphen"); - dictionary_path = dictionary_path.AppendASCII("hyph_en_US.dic"); - base::PlatformFile file = base::CreatePlatformFile( - dictionary_path, base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ, - NULL, NULL); - EXPECT_NE(base::kInvalidPlatformFileValue, file); - - IPC::Message response( - 0, HyphenatorMsg_SetDictionary::ID, IPC::Message::PRIORITY_NORMAL); - IPC::PlatformFileForTransit transit = IPC::GetFileHandleForProcess( - file, GetHandle(), false); - IPC::ParamTraits<IPC::PlatformFileForTransit>::Write(&response, transit); - hyphenator_->OnControlMessageReceived(response); - base::ClosePlatformFile(file); - return true; - } - - private: - base::ProcessHandle GetHandle() const { - return base::Process::Current().handle(); - } - - Hyphenator* hyphenator_; - string16 locale_; -}; - -} // namespace - -// A unit test for our hyphenator. This class loads a sample hyphenation -// dictionary and hyphenates words. -class HyphenatorTest : public testing::Test { - public: - HyphenatorTest() { - } - - bool Initialize() { - base::FilePath dictionary_path; - if (!PathService::Get(base::DIR_SOURCE_ROOT, &dictionary_path)) - return false; - dictionary_path = dictionary_path.AppendASCII("third_party"); - dictionary_path = dictionary_path.AppendASCII("hyphen"); - dictionary_path = dictionary_path.AppendASCII("hyph_en_US.dic"); - base::PlatformFile file = base::CreatePlatformFile( - dictionary_path, base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ, - NULL, NULL); - hyphenator_.reset(new Hyphenator(file)); - return hyphenator_->Initialize(); - } - - // Creates a human-readable hyphenated word. This function inserts '-' - // characters to all places where we can insert hyphens to improve the - // readability of this unit test. - string16 Hyphenate(const string16& word) { - string16 hyphenated_word(word); - size_t position = word.length(); - while (position > 0) { - size_t new_position = hyphenator_->ComputeLastHyphenLocation(word, - position); - EXPECT_LT(new_position, position); - if (new_position > 0) - hyphenated_word.insert(new_position, 1, '-'); - position = new_position; - } - return hyphenated_word; - } - - bool OpenDictionary(const string16& locale) { - hyphenator_.reset(new Hyphenator(base::kInvalidPlatformFileValue)); - thread_.reset(new MockRenderThread()); - listener_.reset(new MockListener(hyphenator_.get(), locale)); - thread_->sink().AddFilter(listener_.get()); - return hyphenator_->Attach(thread_.get(), locale); - } - - size_t GetMessageCount() const { - return thread_->sink().message_count(); - } - - private: - scoped_ptr<Hyphenator> hyphenator_; - scoped_ptr<MockRenderThread> thread_; - scoped_ptr<MockListener> listener_; -}; - -// Verifies that our hyphenator yields the same hyphenated words as the original -// hyphen library does. -TEST_F(HyphenatorTest, HyphenateWords) { - static const struct { - const char* input; - const char* expected; - } kTestCases[] = { - { "and", "and" }, - { "concupiscent,", "con-cu-pis-cent," }, - { "evidence.", "ev-i-dence." }, - { "first", "first" }, - { "getting", "get-ting" }, - { "hedgehog", "hedge-hog" }, - { "remarkable", "re-mark-able" }, - { "straightened", "straight-ened" }, - { "undid", "un-did" }, - { "were", "were" }, - { "Simply", "Sim-ply" }, - { "Undone.", "Un-done." }, - { "comfortably", "com-fort-ably"}, - { "declination", "dec-li-na-tion" }, - { "flamingo:", "flamin-go:" }, - { "lination", "lina-tion" }, - { "reciprocity", "rec-i-proc-i-ty" }, - { "throughout", "through-out" }, - { "undid", "un-did" }, - { "undone.", "un-done." }, - { "unnecessary", "un-nec-es-sary" }, - }; - Initialize(); - for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) { - string16 input = ASCIIToUTF16(kTestCases[i].input); - string16 expected = ASCIIToUTF16(kTestCases[i].expected); - EXPECT_EQ(expected, Hyphenate(input)); - } -} - -// Verifies that our hyphenator sends a HyphenatorHostMsg_OpenDictionary -// message to ask a browser to open a dictionary. Also, this test verifies that -// our hyphenator can hyphnate words when the Hyphenator::SetDictionary function -// is called. -TEST_F(HyphenatorTest, openDictionary) { - // Send a HyphenatorHostMsg_OpenDictionary message and verify it is handled by - // our MockListner class. - EXPECT_TRUE(OpenDictionary(string16())); - EXPECT_EQ(0U, GetMessageCount()); - - // Verify that we can now hyphenate words. When the MockListener class - // receives a HyphenatorHostMsg_OpenDictionary message, it calls the - // OnControlMessageReceived function with a HyphenatorMsg_SetDictionary - // message. So, the Hyphenate function should be able to hyphenate words now. - string16 input = ASCIIToUTF16("hyphenation"); - string16 expected = ASCIIToUTF16("hy-phen-ation"); - EXPECT_EQ(expected, Hyphenate(input)); -} - -} // namespace content diff --git a/content/renderer/renderer_webkitplatformsupport_impl.cc b/content/renderer/renderer_webkitplatformsupport_impl.cc index 917ce1f..09ceac1 100644 --- a/content/renderer/renderer_webkitplatformsupport_impl.cc +++ b/content/renderer/renderer_webkitplatformsupport_impl.cc @@ -34,7 +34,6 @@ #include "content/renderer/device_orientation/device_motion_event_pump.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_decoder.h" #include "content/renderer/media/crypto/key_systems.h" #include "content/renderer/media/media_stream_dependency_factory.h" @@ -57,7 +56,6 @@ #include "third_party/WebKit/public/platform/WebDeviceMotionListener.h" #include "third_party/WebKit/public/platform/WebFileInfo.h" #include "third_party/WebKit/public/platform/WebGamepads.h" -#include "third_party/WebKit/public/platform/WebHyphenator.h" #include "third_party/WebKit/public/platform/WebMediaStreamCenter.h" #include "third_party/WebKit/public/platform/WebMediaStreamCenterClient.h" #include "third_party/WebKit/public/platform/WebPluginListBuilder.h" @@ -163,24 +161,6 @@ class RendererWebKitPlatformSupportImpl::FileUtilities scoped_refptr<ThreadSafeSender> thread_safe_sender_; }; -class RendererWebKitPlatformSupportImpl::Hyphenator - : public WebKit::WebHyphenator { - public: - Hyphenator(); - virtual ~Hyphenator(); - - virtual bool canHyphenate(const WebKit::WebString& locale); - virtual size_t computeLastHyphenLocation( - const WebKit::WebString& word, - size_t before_index, - const WebKit::WebString& locale); - - private: - scoped_ptr<content::Hyphenator> hyphenator_; - - DISALLOW_COPY_AND_ASSIGN(Hyphenator); -}; - #if defined(OS_ANDROID) // WebKit doesn't use WebSandboxSupport on android so we don't need to // implement anything here. @@ -228,7 +208,6 @@ RendererWebKitPlatformSupportImpl::RendererWebKitPlatformSupportImpl() : clipboard_client_(new RendererClipboardClient), clipboard_(new WebClipboardImpl(clipboard_client_.get())), mime_registry_(new RendererWebKitPlatformSupportImpl::MimeRegistry), - hyphenator_(new RendererWebKitPlatformSupportImpl::Hyphenator), sudden_termination_disables_(0), plugin_refresh_allowed_(true), shared_worker_repository_(new WebSharedWorkerRepositoryImpl), @@ -551,40 +530,6 @@ SendSyncMessageFromAnyThread(IPC::SyncMessage* msg) const { //------------------------------------------------------------------------------ -RendererWebKitPlatformSupportImpl::Hyphenator::Hyphenator() {} - -RendererWebKitPlatformSupportImpl::Hyphenator::~Hyphenator() {} - -bool RendererWebKitPlatformSupportImpl::Hyphenator::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_) { - hyphenator_.reset(new content::Hyphenator(base::kInvalidPlatformFileValue)); - if (!hyphenator_) - return false; - return hyphenator_->Attach(RenderThreadImpl::current(), locale); - } - return hyphenator_->CanHyphenate(locale); -} - -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) bool RendererWebKitPlatformSupportImpl::SandboxSupport::ensureFontLoaded( @@ -1014,16 +959,6 @@ void RendererWebKitPlatformSupportImpl::SetMockGamepadsForTesting( //------------------------------------------------------------------------------ -WebKit::WebHyphenator* RendererWebKitPlatformSupportImpl::hyphenator() { - WebKit::WebHyphenator* hyphenator = - GetContentClient()->renderer()->OverrideWebHyphenator(); - if (hyphenator) - return hyphenator; - return hyphenator_.get(); -} - -//------------------------------------------------------------------------------ - WebKit::WebSpeechSynthesizer* RendererWebKitPlatformSupportImpl::createSpeechSynthesizer( WebKit::WebSpeechSynthesizerClient* client) { diff --git a/content/renderer/renderer_webkitplatformsupport_impl.h b/content/renderer/renderer_webkitplatformsupport_impl.h index 26c1686..e59df5c 100644 --- a/content/renderer/renderer_webkitplatformsupport_impl.h +++ b/content/renderer/renderer_webkitplatformsupport_impl.h @@ -58,7 +58,6 @@ class CONTENT_EXPORT RendererWebKitPlatformSupportImpl virtual WebKit::WebFileUtilities* fileUtilities(); virtual WebKit::WebSandboxSupport* sandboxSupport(); virtual WebKit::WebCookieJar* cookieJar(); - virtual WebKit::WebHyphenator* hyphenator(); virtual WebKit::WebThemeEngine* themeEngine(); virtual WebKit::WebSpeechSynthesizer* createSpeechSynthesizer( WebKit::WebSpeechSynthesizerClient* client); @@ -181,9 +180,6 @@ class CONTENT_EXPORT RendererWebKitPlatformSupportImpl class SandboxSupport; scoped_ptr<SandboxSupport> sandbox_support_; - class Hyphenator; - scoped_ptr<Hyphenator> hyphenator_; - // This counter keeps track of the number of times sudden termination is // enabled or disabled. It starts at 0 (enabled) and for every disable // increments by 1, for every enable decrements by 1. When it reaches 0, diff --git a/content/shell/common/shell_messages.h b/content/shell/common/shell_messages.h index 928a5cd..188421d 100644 --- a/content/shell/common/shell_messages.h +++ b/content/shell/common/shell_messages.h @@ -32,10 +32,6 @@ IPC_MESSAGE_ROUTED0(ShellViewMsg_Reset) IPC_MESSAGE_CONTROL1(ShellViewMsg_SetWebKitSourceDir, base::FilePath /* webkit source dir */) -// Loads the hyphen dictionary used for layout tests. -IPC_MESSAGE_CONTROL1(ShellViewMsg_LoadHyphenDictionary, - IPC::PlatformFileForTransit /* dict_file */) - // Sets the initial configuration to use for layout tests. IPC_MESSAGE_ROUTED1(ShellViewMsg_SetTestConfiguration, content::ShellTestConfiguration) diff --git a/content/shell/renderer/shell_content_renderer_client.cc b/content/shell/renderer/shell_content_renderer_client.cc index 657426f..4db6a52 100644 --- a/content/shell/renderer/shell_content_renderer_client.cc +++ b/content/shell/renderer/shell_content_renderer_client.cc @@ -22,13 +22,11 @@ #include "third_party/WebKit/public/web/WebPluginParams.h" #include "third_party/WebKit/public/web/WebView.h" #include "v8/include/v8.h" -#include "webkit/mocks/mock_webhyphenator.h" #include "webkit/support/mock_webclipboard_impl.h" using WebKit::WebAudioDevice; using WebKit::WebClipboard; using WebKit::WebFrame; -using WebKit::WebHyphenator; using WebKit::WebMIDIAccessor; using WebKit::WebMIDIAccessorClient; using WebKit::WebMediaStreamCenter; @@ -66,14 +64,6 @@ ShellContentRendererClient::~ShellContentRendererClient() { g_renderer_client = NULL; } -void ShellContentRendererClient::LoadHyphenDictionary( - base::PlatformFile dict_file) { - if (!hyphenator_) - hyphenator_.reset(new webkit_glue::MockWebHyphenator); - base::SeekPlatformFile(dict_file, base::PLATFORM_FILE_FROM_BEGIN, 0); - hyphenator_->LoadDictionary(dict_file); -} - void ShellContentRendererClient::RenderThreadStarted() { shell_observer_.reset(new ShellRenderProcessObserver()); #if defined(OS_MACOSX) @@ -178,15 +168,6 @@ WebKit::WebCrypto* ShellContentRendererClient::OverrideWebCrypto() { return interfaces->crypto(); } -WebHyphenator* ShellContentRendererClient::OverrideWebHyphenator() { - if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) - return NULL; - if (!hyphenator_) - hyphenator_.reset(new webkit_glue::MockWebHyphenator); - return hyphenator_.get(); - -} - WebThemeEngine* ShellContentRendererClient::OverrideThemeEngine() { if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) return NULL; diff --git a/content/shell/renderer/shell_content_renderer_client.h b/content/shell/renderer/shell_content_renderer_client.h index 768629c..10b2f43 100644 --- a/content/shell/renderer/shell_content_renderer_client.h +++ b/content/shell/renderer/shell_content_renderer_client.h @@ -20,10 +20,6 @@ namespace WebTestRunner { class WebTestProxyBase; } -namespace webkit_glue { -class MockWebHyphenator; -} - class MockWebClipboardImpl; namespace content { @@ -37,8 +33,6 @@ class ShellContentRendererClient : public ContentRendererClient { ShellContentRendererClient(); virtual ~ShellContentRendererClient(); - void LoadHyphenDictionary(base::PlatformFile dict_file); - // ContentRendererClient implementation. virtual void RenderThreadStarted() OVERRIDE; virtual void RenderViewCreated(RenderView* render_view) OVERRIDE; @@ -58,7 +52,6 @@ class ShellContentRendererClient : public ContentRendererClient { double sample_rate) OVERRIDE; virtual WebKit::WebClipboard* OverrideWebClipboard() OVERRIDE; virtual WebKit::WebCrypto* OverrideWebCrypto() OVERRIDE; - virtual WebKit::WebHyphenator* OverrideWebHyphenator() OVERRIDE; virtual WebKit::WebThemeEngine* OverrideThemeEngine() OVERRIDE; virtual bool AllowBrowserPlugin( WebKit::WebPluginContainer* container) const OVERRIDE; @@ -69,7 +62,6 @@ class ShellContentRendererClient : public ContentRendererClient { scoped_ptr<ShellRenderProcessObserver> shell_observer_; scoped_ptr<MockWebClipboardImpl> clipboard_; - scoped_ptr<webkit_glue::MockWebHyphenator> hyphenator_; }; } // namespace content diff --git a/content/shell/renderer/shell_render_process_observer.cc b/content/shell/renderer/shell_render_process_observer.cc index d4a69a1..960f4a1 100644 --- a/content/shell/renderer/shell_render_process_observer.cc +++ b/content/shell/renderer/shell_render_process_observer.cc @@ -77,8 +77,6 @@ bool ShellRenderProcessObserver::OnControlMessageReceived( bool handled = true; IPC_BEGIN_MESSAGE_MAP(ShellRenderProcessObserver, message) IPC_MESSAGE_HANDLER(ShellViewMsg_SetWebKitSourceDir, OnSetWebKitSourceDir) - IPC_MESSAGE_HANDLER(ShellViewMsg_LoadHyphenDictionary, - OnLoadHyphenDictionary) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() @@ -90,10 +88,4 @@ void ShellRenderProcessObserver::OnSetWebKitSourceDir( webkit_source_dir_ = webkit_source_dir; } -void ShellRenderProcessObserver::OnLoadHyphenDictionary( - const IPC::PlatformFileForTransit& dict_file) { - ShellContentRendererClient::Get()->LoadHyphenDictionary( - IPC::PlatformFileForTransitToPlatformFile(dict_file)); -} - } // namespace content diff --git a/content/shell/renderer/shell_render_process_observer.h b/content/shell/renderer/shell_render_process_observer.h index bae0347..5762523 100644 --- a/content/shell/renderer/shell_render_process_observer.h +++ b/content/shell/renderer/shell_render_process_observer.h @@ -53,7 +53,6 @@ class ShellRenderProcessObserver : public RenderProcessObserver { // Message handlers. void OnResetAll(); void OnSetWebKitSourceDir(const base::FilePath& webkit_source_dir); - void OnLoadHyphenDictionary(const IPC::PlatformFileForTransit& dict_file); WebKitTestRunner* main_test_runner_; WebTestRunner::WebTestDelegate* test_delegate_; diff --git a/content/shell/shell_content_browser_client.cc b/content/shell/shell_content_browser_client.cc index a08dac2..04207d3 100644 --- a/content/shell/shell_content_browser_client.cc +++ b/content/shell/shell_content_browser_client.cc @@ -52,23 +52,12 @@ ShellContentBrowserClient* ShellContentBrowserClient::Get() { } ShellContentBrowserClient::ShellContentBrowserClient() - : hyphen_dictionary_file_(base::kInvalidPlatformFileValue), - shell_browser_main_parts_(NULL) { + : shell_browser_main_parts_(NULL) { DCHECK(!g_browser_client); g_browser_client = this; if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) return; webkit_source_dir_ = GetWebKitRootDirFilePath(); - base::FilePath source_root_path; - PathService::Get(base::DIR_SOURCE_ROOT, &source_root_path); - base::FilePath dictionary_file_path = - base::MakeAbsoluteFilePath(source_root_path.Append( - FILE_PATH_LITERAL("third_party/hyphen/hyph_en_US.dic"))); - hyphen_dictionary_file_ = base::CreatePlatformFile(dictionary_file_path, - base::PLATFORM_FILE_READ | - base::PLATFORM_FILE_OPEN, - NULL, - NULL); } ShellContentBrowserClient::~ShellContentBrowserClient() { @@ -231,12 +220,6 @@ void ShellContentBrowserClient::Observe(int type, registrar_.Remove(this, NOTIFICATION_RENDERER_PROCESS_TERMINATED, source); - if (hyphen_dictionary_file_ != base::kInvalidPlatformFileValue) { - RenderProcessHost* host = Source<RenderProcessHost>(source).ptr(); - IPC::PlatformFileForTransit file = IPC::GetFileHandleForProcess( - hyphen_dictionary_file_, host->GetHandle(), false); - host->Send(new ShellViewMsg_LoadHyphenDictionary(file)); - } break; } diff --git a/content/shell/shell_content_browser_client.h b/content/shell/shell_content_browser_client.h index d88ca8a..13bc4fe 100644 --- a/content/shell/shell_content_browser_client.h +++ b/content/shell/shell_content_browser_client.h @@ -88,8 +88,6 @@ class ShellContentBrowserClient : public ContentBrowserClient, base::FilePath webkit_source_dir_; - base::PlatformFile hyphen_dictionary_file_; - ShellBrowserMainParts* shell_browser_main_parts_; NotificationRegistrar registrar_; |