Commit 95eb2861 authored by yusukes@google.com's avatar yusukes@google.com

Partial fix for crbug.com/120597. Send the current cursor location when one of...

Partial fix for crbug.com/120597. Send the current cursor location when one of the Japanese IMEs is enabled.

Without the fix, for example, the suggestion window could be shown in a wrong place in step #6 below:

1. switch to mozc, the Japanese IME.
2. press a, press Enter.
3. repeat step #2 several times so that 'あ' is suggested when a is pressed.
4. focus text area.
5. switch to US-Qwerty, type aaaaa
6. switch to mozc, type a. The suggestion window could be shown in a wrong position because cursor location information is not sent to the IME in step #5.

BUG=120597
TEST=manual

Review URL: https://chromiumcodereview.appspot.com/10066008

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@132389 0039d316-1c4b-4281-b951-d872f2087c98
parent bfdf009a
...@@ -10,29 +10,34 @@ ...@@ -10,29 +10,34 @@
#include <sstream> #include <sstream>
#include "ash/shell.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "base/string_util.h" #include "base/string_util.h"
#include "third_party/mozc/session/candidates_lite.pb.h" #include "chrome/browser/chromeos/input_method/input_method_descriptor.h"
#if defined(HAVE_IBUS)
#include "ash/shell.h"
#include "chrome/browser/chromeos/input_method/input_method_manager.h" #include "chrome/browser/chromeos/input_method/input_method_manager.h"
#include "chrome/browser/chromeos/input_method/input_method_util.h" #include "chrome/browser/chromeos/input_method/input_method_util.h"
#include "third_party/mozc/session/candidates_lite.pb.h"
#include "ui/aura/client/aura_constants.h" #include "ui/aura/client/aura_constants.h"
#include "ui/aura/root_window.h" #include "ui/aura/root_window.h"
#include "ui/base/ime/ibus_client_impl.h" #include "ui/base/ime/ibus_client_impl.h"
#include "ui/base/ime/input_method_ibus.h" #include "ui/base/ime/input_method_ibus.h"
namespace chromeos {
namespace input_method {
namespace { namespace {
// The list of input method IDs for Mozc Japanese IMEs. bool IsActive(const std::string& input_method_id,
const char* kMozcJaInputMethodIds[] = { "mozc", "mozc-jp", "mozc-dv" }; const InputMethodDescriptors* descriptors) {
for (size_t i = 0; i < descriptors->size(); ++i) {
if (descriptors->at(i).id() == input_method_id) {
return true;
}
}
return false;
}
} // namespace } // namespace
#endif
namespace chromeos {
namespace input_method {
InputMethodLookupTable::InputMethodLookupTable() InputMethodLookupTable::InputMethodLookupTable()
: visible(false), : visible(false),
...@@ -294,12 +299,16 @@ class IBusUiControllerImpl : public IBusUiController { ...@@ -294,12 +299,16 @@ class IBusUiControllerImpl : public IBusUiController {
int32 y, int32 y,
int32 w, int32 w,
int32 h) OVERRIDE { int32 h) OVERRIDE {
// The list of input method IDs for Mozc Japanese IMEs.
const char* kMozcJaInputMethodIds[] = { "mozc", "mozc-jp", "mozc-dv" };
if (!ui_) if (!ui_)
return; return;
const std::string current_input_method_id = GetCurrentInputMethodId(); scoped_ptr<InputMethodDescriptors> input_methods(
InputMethodManager::GetInstance()->GetSupportedInputMethods());
for (size_t i = 0; i < arraysize(kMozcJaInputMethodIds); ++i) { for (size_t i = 0; i < arraysize(kMozcJaInputMethodIds); ++i) {
if (kMozcJaInputMethodIds[i] == current_input_method_id) { if (IsActive(kMozcJaInputMethodIds[i], input_methods.get())) {
// Mozc Japanese IMEs require cursor location information to show the // Mozc Japanese IMEs require cursor location information to show the
// suggestion window in a correct position. // suggestion window in a correct position.
ui::internal::IBusClientImpl::SetCursorLocation(context, x, y, w, h); ui::internal::IBusClientImpl::SetCursorLocation(context, x, y, w, h);
...@@ -738,5 +747,10 @@ IBusUiController* IBusUiController::Create() { ...@@ -738,5 +747,10 @@ IBusUiController* IBusUiController::Create() {
IBusUiController::~IBusUiController() { IBusUiController::~IBusUiController() {
} }
bool IsActiveForTesting(const std::string& input_method_id,
const InputMethodDescriptors* descriptors) {
return IsActive(input_method_id, descriptors);
}
} // namespace input_method } // namespace input_method
} // namespace chromeos } // namespace chromeos
// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// //
...@@ -23,6 +23,9 @@ namespace input_method { ...@@ -23,6 +23,9 @@ namespace input_method {
// A key for attaching the |ibus_service_panel_| object to |ibus_|. // A key for attaching the |ibus_service_panel_| object to |ibus_|.
const char kPanelObjectKey[] = "panel-object"; const char kPanelObjectKey[] = "panel-object";
class InputMethodDescriptor;
typedef std::vector<InputMethodDescriptor> InputMethodDescriptors;
// The struct represents the input method lookup table (list of candidates). // The struct represents the input method lookup table (list of candidates).
// Used for InputMethodUpdateLookupTableMonitorFunction. // Used for InputMethodUpdateLookupTableMonitorFunction.
struct InputMethodLookupTable { struct InputMethodLookupTable {
...@@ -141,6 +144,9 @@ class IBusUiController { ...@@ -141,6 +144,9 @@ class IBusUiController {
virtual void NotifyPageDown() = 0; virtual void NotifyPageDown() = 0;
}; };
bool IsActiveForTesting(const std::string& input_method_id,
const InputMethodDescriptors* descriptors);
} // namespace input_method } // namespace input_method
} // namespace chromeos } // namespace chromeos
......
// 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/logging.h"
#include "chrome/browser/chromeos/input_method/ibus_ui_controller.h"
#include "chrome/browser/chromeos/input_method/input_method_descriptor.h"
#include "chrome/browser/chromeos/input_method/input_method_whitelist.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace chromeos {
namespace input_method {
// TODO(nona): Add more tests (crosbug.com/26334).
TEST(IBusUiControllerTest, TestIsActive) {
InputMethodWhitelist w;
InputMethodDescriptors descriptors;
EXPECT_FALSE(IsActiveForTesting("mozc", &descriptors));
descriptors.push_back(
InputMethodDescriptor(w, "mozc", "name", "us", "en-US"));
EXPECT_TRUE(IsActiveForTesting("mozc", &descriptors));
EXPECT_FALSE(IsActiveForTesting("mozc-jp", &descriptors));
descriptors.push_back(
InputMethodDescriptor(w, "xkb:us::eng", "name", "us", "en-US"));
EXPECT_TRUE(IsActiveForTesting("xkb:us::eng", &descriptors));
EXPECT_TRUE(IsActiveForTesting("mozc", &descriptors));
EXPECT_FALSE(IsActiveForTesting("mozc-jp", &descriptors));
}
} // namespace input_method
} // namespace chromeos
...@@ -1292,6 +1292,7 @@ ...@@ -1292,6 +1292,7 @@
'browser/chromeos/gview_request_interceptor_unittest.cc', 'browser/chromeos/gview_request_interceptor_unittest.cc',
'browser/chromeos/imageburner/burn_manager_unittest.cc', 'browser/chromeos/imageburner/burn_manager_unittest.cc',
'browser/chromeos/input_method/candidate_window_view_unittest.cc', 'browser/chromeos/input_method/candidate_window_view_unittest.cc',
'browser/chromeos/input_method/ibus_ui_controller_unittest.cc',
'browser/chromeos/input_method/input_method_descriptor_unittest.cc', 'browser/chromeos/input_method/input_method_descriptor_unittest.cc',
'browser/chromeos/input_method/input_method_property_unittest.cc', 'browser/chromeos/input_method/input_method_property_unittest.cc',
'browser/chromeos/input_method/input_method_util_unittest.cc', 'browser/chromeos/input_method/input_method_util_unittest.cc',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment