summaryrefslogtreecommitdiffstats
path: root/ui/base
diff options
context:
space:
mode:
authorsuzhe@google.com <suzhe@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-19 01:27:47 +0000
committersuzhe@google.com <suzhe@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-19 01:27:47 +0000
commit7aeaeec73aad288157a2ca883fe7a180762fcb3b (patch)
tree812df122a64a9759d0584f11238050804a02a02c /ui/base
parent474b343920007333ae952dc7e654b9ad190653d6 (diff)
downloadchromium_src-7aeaeec73aad288157a2ca883fe7a180762fcb3b.zip
chromium_src-7aeaeec73aad288157a2ca883fe7a180762fcb3b.tar.gz
chromium_src-7aeaeec73aad288157a2ca883fe7a180762fcb3b.tar.bz2
Add common data types for input method support.
This CL adds following common data types for input method support: 1. struct CompositionUnderline 2. struct Composition 3. enum TextInputType BUG=75003 TEST=none Review URL: http://codereview.chromium.org/6711008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@78793 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/base')
-rw-r--r--ui/base/ime/composition.cc15
-rw-r--r--ui/base/ime/composition.h36
-rw-r--r--ui/base/ime/composition_underline.h42
-rw-r--r--ui/base/ime/text_input_type.h30
4 files changed, 123 insertions, 0 deletions
diff --git a/ui/base/ime/composition.cc b/ui/base/ime/composition.cc
new file mode 100644
index 0000000..62e844f
--- /dev/null
+++ b/ui/base/ime/composition.cc
@@ -0,0 +1,15 @@
+// Copyright (c) 2011 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 "ui/base/ime/composition.h"
+
+namespace ui {
+
+void Composition::Clear() {
+ text.clear();
+ underlines.clear();
+ selection = Range();
+}
+
+} // namespace ui
diff --git a/ui/base/ime/composition.h b/ui/base/ime/composition.h
new file mode 100644
index 0000000..af04c2c
--- /dev/null
+++ b/ui/base/ime/composition.h
@@ -0,0 +1,36 @@
+// Copyright (c) 2011 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 UI_BASE_IME_COMPOSITION_H_
+#define UI_BASE_IME_COMPOSITION_H_
+#pragma once
+
+#include "base/string16.h"
+#include "ui/base/ime/composition_underline.h"
+#include "ui/base/range/range.h"
+
+namespace ui {
+
+// A struct represents the status of an ongoing composition.
+struct Composition {
+ void Clear();
+
+ // Content of the composition text.
+ string16 text;
+
+ // Underline information of the composition text.
+ // They must be sorted in ascending order by their start_offset and cannot be
+ // overlapped with each other.
+ CompositionUnderlines underlines;
+
+ // Selection range in the composition text. It represents the caret position
+ // if the range length is zero. Usually it's used for representing the target
+ // clause (on Windows). Gtk doesn't have such concept, so background color is
+ // usually used instead.
+ Range selection;
+};
+
+} // namespace ui
+
+#endif // UI_BASE_IME_COMPOSITION_H_
diff --git a/ui/base/ime/composition_underline.h b/ui/base/ime/composition_underline.h
new file mode 100644
index 0000000..fc1538d
--- /dev/null
+++ b/ui/base/ime/composition_underline.h
@@ -0,0 +1,42 @@
+// Copyright (c) 2011 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 UI_BASE_IME_COMPOSITION_UNDERLINE_H_
+#define UI_BASE_IME_COMPOSITION_UNDERLINE_H_
+#pragma once
+
+#include <vector>
+
+#include "third_party/skia/include/core/SkColor.h"
+
+namespace ui {
+
+// Intentionally keep sync with WebKit::WebCompositionUnderline defined in:
+// third_party/WebKit/Source/WebKit/chromium/public/WebCompositionUnderline.h
+struct CompositionUnderline {
+ CompositionUnderline()
+ : start_offset(0),
+ end_offset(0),
+ color(0),
+ thick(false) {}
+
+ CompositionUnderline(unsigned s, unsigned e, SkColor c, bool t)
+ : start_offset(s),
+ end_offset(e),
+ color(c),
+ thick(t) {}
+
+ // Though use of unsigned is discouraged, we use it here to make sure it's
+ // identical to WebKit::WebCompositionUnderline.
+ unsigned start_offset;
+ unsigned end_offset;
+ SkColor color;
+ bool thick;
+};
+
+typedef std::vector<CompositionUnderline> CompositionUnderlines;
+
+} // namespace ui
+
+#endif // UI_BASE_IME_COMPOSITION_UNDERLINE_H_
diff --git a/ui/base/ime/text_input_type.h b/ui/base/ime/text_input_type.h
new file mode 100644
index 0000000..19c1332
--- /dev/null
+++ b/ui/base/ime/text_input_type.h
@@ -0,0 +1,30 @@
+// Copyright (c) 2011 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 UI_BASE_IME_TEXT_INPUT_TYPE_H_
+#define UI_BASE_IME_TEXT_INPUT_TYPE_H_
+#pragma once
+
+namespace ui {
+
+// Intentionally keep sync with WebKit::WebTextInputType defined in:
+// third_party/WebKit/Source/WebKit/chromium/public/WebTextInputType.h
+enum TextInputType {
+ // Input caret is not in an editable node, no input method shall be used.
+ TEXT_INPUT_TYPE_NONE,
+
+ // Input caret is in a normal editable node, any input method can be used.
+ TEXT_INPUT_TYPE_TEXT,
+
+ // Input caret is in a password box, an input method may be used only if
+ // it's suitable for password input.
+ TEXT_INPUT_TYPE_PASSWORD,
+
+ // TODO(suzhe): Add more text input types when necessary, eg. Number, Date,
+ // Email, URL, etc.
+};
+
+} // namespace ui
+
+#endif // UI_BASE_IME_TEXT_INPUT_TYPE_H_