summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzork@chromium.org <zork@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-29 07:38:06 +0000
committerzork@chromium.org <zork@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-29 07:38:06 +0000
commit794e1857d3b0dc0d1e1c962047979c498327da5a (patch)
tree349e0cf7f992c2ccd5c77d8c8b49f78d29a1e455
parentba1d37596d268085bc2cda97116bf6406f51f889 (diff)
downloadchromium_src-794e1857d3b0dc0d1e1c962047979c498327da5a.zip
chromium_src-794e1857d3b0dc0d1e1c962047979c498327da5a.tar.gz
chromium_src-794e1857d3b0dc0d1e1c962047979c498327da5a.tar.bz2
Add cursor field to SetComposition.
R=mpcomplete@chromium.org BUG=None TEST=None Review URL: http://codereview.chromium.org/8681008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111887 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/chromeos/input_method/input_method_engine.cc7
-rw-r--r--chrome/browser/chromeos/input_method/input_method_engine.h1
-rw-r--r--chrome/browser/extensions/extension_input_ime_api.cc9
-rw-r--r--chrome/browser/extensions/extension_input_module_constants.cc1
-rw-r--r--chrome/browser/extensions/extension_input_module_constants.h1
-rw-r--r--chrome/common/extensions/api/extension_api.json6
-rw-r--r--chrome/test/data/extensions/api_test/input_ime/background.html1
7 files changed, 19 insertions, 7 deletions
diff --git a/chrome/browser/chromeos/input_method/input_method_engine.cc b/chrome/browser/chromeos/input_method/input_method_engine.cc
index de50387..2fb6196 100644
--- a/chrome/browser/chromeos/input_method/input_method_engine.cc
+++ b/chrome/browser/chromeos/input_method/input_method_engine.cc
@@ -69,7 +69,7 @@ class InputMethodEngineImpl
virtual bool SetComposition(int context_id,
const char* text, int selection_start,
- int selection_end,
+ int selection_end, int cursor,
const std::vector<SegmentInfo>& segments,
std::string* error);
virtual bool ClearComposition(int context_id,
@@ -190,6 +190,7 @@ bool InputMethodEngineImpl::SetComposition(
const char* text,
int selection_start,
int selection_end,
+ int cursor,
const std::vector<SegmentInfo>& segments,
std::string* error) {
if (!active_) {
@@ -201,7 +202,7 @@ bool InputMethodEngineImpl::SetComposition(
return false;
}
- connection_->SetPreeditText(text, selection_end);
+ connection_->SetPreeditText(text, cursor);
// TODO: Add support for displaying selected text in the composition string.
for (std::vector<SegmentInfo>::const_iterator segment = segments.begin();
segment != segments.end(); ++segment) {
@@ -545,7 +546,7 @@ class InputMethodEngineStub : public InputMethodEngine {
virtual bool SetComposition(int context_id,
const char* text, int selection_start,
- int selection_end,
+ int selection_end, int cursor,
const std::vector<SegmentInfo>& segments,
std::string* error) {
VLOG(0) << "SetComposition";
diff --git a/chrome/browser/chromeos/input_method/input_method_engine.h b/chrome/browser/chromeos/input_method/input_method_engine.h
index 2e5fcb9..071191d 100644
--- a/chrome/browser/chromeos/input_method/input_method_engine.h
+++ b/chrome/browser/chromeos/input_method/input_method_engine.h
@@ -141,6 +141,7 @@ class InputMethodEngine {
const char* text,
int selection_start,
int selection_end,
+ int cursor,
const std::vector<SegmentInfo>& segments,
std::string* error) = 0;
diff --git a/chrome/browser/extensions/extension_input_ime_api.cc b/chrome/browser/extensions/extension_input_ime_api.cc
index febef50..67a75de 100644
--- a/chrome/browser/extensions/extension_input_ime_api.cc
+++ b/chrome/browser/extensions/extension_input_ime_api.cc
@@ -508,26 +508,27 @@ bool SetCompositionFunction::RunImpl() {
std::string text;
int selection_start;
int selection_end;
+ int cursor;
std::vector<chromeos::InputMethodEngine::SegmentInfo> segments;
EXTENSION_FUNCTION_VALIDATE(args->GetInteger(keys::kContextIdKey,
&context_id));
EXTENSION_FUNCTION_VALIDATE(args->GetString(keys::kTextKey, &text));
+ EXTENSION_FUNCTION_VALIDATE(args->GetInteger(keys::kCursorKey, &cursor));
if (args->HasKey(keys::kSelectionStartKey)) {
EXTENSION_FUNCTION_VALIDATE(args->GetInteger(keys::kSelectionStartKey,
&selection_start));
} else {
- selection_start = 0;
+ selection_start = cursor;
}
if (args->HasKey(keys::kSelectionEndKey)) {
EXTENSION_FUNCTION_VALIDATE(args->GetInteger(keys::kSelectionEndKey,
&selection_end));
} else {
- selection_end = 0;
+ selection_end = cursor;
}
if (args->HasKey(keys::kSegmentsKey)) {
- // TODO: Handle segments
ListValue* segment_list;
EXTENSION_FUNCTION_VALIDATE(args->GetList(keys::kSegmentsKey,
&segment_list));
@@ -553,7 +554,7 @@ bool SetCompositionFunction::RunImpl() {
}
if (engine->SetComposition(context_id, text.c_str(), selection_start,
- selection_end, segments, &error_)) {
+ selection_end, cursor, segments, &error_)) {
result_.reset(Value::CreateBooleanValue(true));
} else {
result_.reset(Value::CreateBooleanValue(false));
diff --git a/chrome/browser/extensions/extension_input_module_constants.cc b/chrome/browser/extensions/extension_input_module_constants.cc
index c6bbbf8..88dc206 100644
--- a/chrome/browser/extensions/extension_input_module_constants.cc
+++ b/chrome/browser/extensions/extension_input_module_constants.cc
@@ -16,6 +16,7 @@ const char kCandidatesKey[] = "candidates";
const char kCheckedKey[] = "checked";
const char kContextIdKey[] = "contextID";
const char kCtrlKeyKey[] = "ctrlKey";
+const char kCursorKey[] = "cursor";
const char kCursorVisibleKey[] = "cursorVisible";
const char kEnabledKey[] = "enabled";
const char kEndKey[] = "end";
diff --git a/chrome/browser/extensions/extension_input_module_constants.h b/chrome/browser/extensions/extension_input_module_constants.h
index 9cf8a1b..de2fae3 100644
--- a/chrome/browser/extensions/extension_input_module_constants.h
+++ b/chrome/browser/extensions/extension_input_module_constants.h
@@ -21,6 +21,7 @@ extern const char kCandidatesKey[];
extern const char kCheckedKey[];
extern const char kContextIdKey[];
extern const char kCtrlKeyKey[];
+extern const char kCursorKey[];
extern const char kCursorVisibleKey[];
extern const char kEnabledKey[];
extern const char kEndKey[];
diff --git a/chrome/common/extensions/api/extension_api.json b/chrome/common/extensions/api/extension_api.json
index 6ce75e9..53dd613 100644
--- a/chrome/common/extensions/api/extension_api.json
+++ b/chrome/common/extensions/api/extension_api.json
@@ -3407,10 +3407,16 @@
},
"selectionStart": {
"description": "Position in the text that the selection starts at.",
+ "optional": true,
"type": "integer"
},
"selectionEnd": {
"description": "Position in the text that the selection ends at.",
+ "optional": true,
+ "type": "integer"
+ },
+ "cursor": {
+ "description": "Position in the text of the cursor.",
"type": "integer"
},
"segments": {
diff --git a/chrome/test/data/extensions/api_test/input_ime/background.html b/chrome/test/data/extensions/api_test/input_ime/background.html
index 70e5f48..922af45 100644
--- a/chrome/test/data/extensions/api_test/input_ime/background.html
+++ b/chrome/test/data/extensions/api_test/input_ime/background.html
@@ -5,6 +5,7 @@
"text": "Pie",
"selectionStart": 1,
"selectionEnd": 2,
+ "cursor": 3,
"segments": [{
"start": 0,
"end": 1,