Commit bf2997f6 authored by mukai@chromium.org's avatar mukai@chromium.org

Moves CandidateWindow model to ui/base/ime.

BUG=325813
R=komatsu@chromium.org
TEST=build passes

Review URL: https://codereview.chromium.org/126363002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@243777 0039d316-1c4b-4281-b951-d872f2087c98
parent 31c353b7
......@@ -6,7 +6,7 @@
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/chromeos/input_method/candidate_window_constants.h"
#include "chromeos/ime/candidate_window.h"
#include "ui/base/ime/candidate_window.h"
#include "ui/gfx/color_utils.h"
#include "ui/native_theme/native_theme.h"
#include "ui/views/background.h"
......@@ -43,14 +43,14 @@ class VerticalCandidateLabel : public views::Label {
// Creates the shortcut label, and returns it (never returns NULL).
// The label text is not set in this function.
views::Label* CreateShortcutLabel(
CandidateWindow::Orientation orientation,
ui::CandidateWindow::Orientation orientation,
const ui::NativeTheme& theme) {
// Create the shortcut label. The label will be owned by
// |wrapped_shortcut_label|, hence it's deleted when
// |wrapped_shortcut_label| is deleted.
views::Label* shortcut_label = new views::Label;
if (orientation == CandidateWindow::VERTICAL) {
if (orientation == ui::CandidateWindow::VERTICAL) {
shortcut_label->SetFontList(
shortcut_label->font_list().DeriveFontListWithSizeDeltaAndStyle(
kFontSizeDelta, gfx::Font::BOLD));
......@@ -70,14 +70,14 @@ views::Label* CreateShortcutLabel(
const gfx::Insets kVerticalShortcutLabelInsets(1, 6, 1, 6);
const gfx::Insets kHorizontalShortcutLabelInsets(1, 3, 1, 0);
const gfx::Insets insets =
(orientation == CandidateWindow::VERTICAL ?
(orientation == ui::CandidateWindow::VERTICAL ?
kVerticalShortcutLabelInsets :
kHorizontalShortcutLabelInsets);
shortcut_label->set_border(views::Border::CreateEmptyBorder(
insets.top(), insets.left(), insets.bottom(), insets.right()));
// Add decoration based on the orientation.
if (orientation == CandidateWindow::VERTICAL) {
if (orientation == ui::CandidateWindow::VERTICAL) {
// Set the background color.
SkColor blackish = color_utils::AlphaBlend(
SK_ColorBLACK,
......@@ -95,12 +95,12 @@ views::Label* CreateShortcutLabel(
// Creates the candidate label, and returns it (never returns NULL).
// The label text is not set in this function.
views::Label* CreateCandidateLabel(
CandidateWindow::Orientation orientation) {
ui::CandidateWindow::Orientation orientation) {
views::Label* candidate_label = NULL;
// Create the candidate label. The label will be added to |this| as a
// child view, hence it's deleted when |this| is deleted.
if (orientation == CandidateWindow::VERTICAL) {
if (orientation == ui::CandidateWindow::VERTICAL) {
candidate_label = new VerticalCandidateLabel;
} else {
candidate_label = new views::Label;
......@@ -117,7 +117,8 @@ views::Label* CreateCandidateLabel(
// Creates the annotation label, and return it (never returns NULL).
// The label text is not set in this function.
views::Label* CreateAnnotationLabel(
CandidateWindow::Orientation orientation, const ui::NativeTheme& theme) {
ui::CandidateWindow::Orientation orientation,
const ui::NativeTheme& theme) {
// Create the annotation label.
views::Label* annotation_label = new views::Label;
......@@ -136,7 +137,7 @@ views::Label* CreateAnnotationLabel(
CandidateView::CandidateView(
views::ButtonListener* listener,
CandidateWindow::Orientation orientation)
ui::CandidateWindow::Orientation orientation)
: views::CustomButton(listener),
orientation_(orientation),
shortcut_label_(NULL),
......@@ -154,7 +155,7 @@ CandidateView::CandidateView(
AddChildView(candidate_label_);
AddChildView(annotation_label_);
if (orientation == CandidateWindow::VERTICAL) {
if (orientation == ui::CandidateWindow::VERTICAL) {
infolist_icon_ = new views::View;
infolist_icon_->set_background(
views::Background::CreateSolidBackground(theme.GetSystemColor(
......@@ -175,9 +176,9 @@ void CandidateView::SetWidths(int shortcut_width, int candidate_width) {
candidate_width_ = candidate_width;
}
void CandidateView::SetEntry(const CandidateWindow::Entry& entry) {
void CandidateView::SetEntry(const ui::CandidateWindow::Entry& entry) {
std::string label = entry.label;
if (!label.empty() && orientation_ != CandidateWindow::VERTICAL)
if (!label.empty() && orientation_ != ui::CandidateWindow::VERTICAL)
label += '.';
shortcut_label_->SetText(base::UTF8ToUTF16(label));
candidate_label_->SetText(base::UTF8ToUTF16(entry.value));
......@@ -239,7 +240,7 @@ bool CandidateView::OnMouseDragged(const ui::MouseEvent& event) {
void CandidateView::Layout() {
const int padding_width =
orientation_ == CandidateWindow::VERTICAL ? 4 : 6;
orientation_ == ui::CandidateWindow::VERTICAL ? 4 : 6;
int x = 0;
shortcut_label_->SetBounds(x, 0, shortcut_width_, height());
if (shortcut_width_ > 0)
......@@ -261,7 +262,7 @@ void CandidateView::Layout() {
gfx::Size CandidateView::GetPreferredSize() {
const int padding_width =
orientation_ == CandidateWindow::VERTICAL ? 4 : 6;
orientation_ == ui::CandidateWindow::VERTICAL ? 4 : 6;
gfx::Size size;
if (shortcut_label_->visible()) {
size = shortcut_label_->GetPreferredSize();
......
......@@ -6,7 +6,7 @@
#define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_CANDIDATE_VIEW_H_
#include "base/gtest_prod_util.h"
#include "chromeos/ime/candidate_window.h"
#include "ui/base/ime/candidate_window.h"
#include "ui/views/controls/button/custom_button.h"
#include "ui/views/controls/label.h"
#include "ui/views/view.h"
......@@ -18,7 +18,7 @@ namespace input_method {
class CandidateView : public views::CustomButton {
public:
CandidateView(views::ButtonListener* listener,
CandidateWindow::Orientation orientation);
ui::CandidateWindow::Orientation orientation);
virtual ~CandidateView() {}
void GetPreferredWidths(int* shortcut_width,
......@@ -27,7 +27,7 @@ class CandidateView : public views::CustomButton {
void SetWidths(int shortcut_width,
int candidate_width);
void SetEntry(const CandidateWindow::Entry& entry);
void SetEntry(const ui::CandidateWindow::Entry& entry);
// Sets infolist icon.
void SetInfolistIcon(bool enable);
......@@ -45,7 +45,7 @@ class CandidateView : public views::CustomButton {
virtual gfx::Size GetPreferredSize() OVERRIDE;
// The orientation of the candidate view.
CandidateWindow::Orientation orientation_;
ui::CandidateWindow::Orientation orientation_;
// Views created in the class will be part of tree of |this|, so these
// child views will be deleted when |this| is deleted.
......
......@@ -19,7 +19,6 @@
#include "ui/gfx/screen.h"
#include "ui/views/widget/widget.h"
namespace chromeos {
namespace input_method {
......@@ -101,7 +100,7 @@ void CandidateWindowControllerImpl::FocusStateChanged(bool is_focused) {
// static
void CandidateWindowControllerImpl::ConvertLookupTableToInfolistEntry(
const CandidateWindow& candidate_window,
const ui::CandidateWindow& candidate_window,
std::vector<InfolistEntry>* infolist_entries,
bool* has_highlighted) {
DCHECK(infolist_entries);
......@@ -113,7 +112,7 @@ void CandidateWindowControllerImpl::ConvertLookupTableToInfolistEntry(
candidate_window.cursor_position() % candidate_window.page_size();
for (size_t i = 0; i < candidate_window.candidates().size(); ++i) {
const CandidateWindow::Entry& ibus_entry =
const ui::CandidateWindow::Entry& ibus_entry =
candidate_window.candidates()[i];
if (ibus_entry.description_title.empty() &&
ibus_entry.description_body.empty())
......@@ -129,7 +128,7 @@ void CandidateWindowControllerImpl::ConvertLookupTableToInfolistEntry(
}
void CandidateWindowControllerImpl::UpdateLookupTable(
const CandidateWindow& candidate_window,
const ui::CandidateWindow& candidate_window,
bool visible) {
// If it's not visible, hide the lookup table and return.
if (!visible) {
......
......@@ -18,10 +18,13 @@ namespace views {
class Widget;
} // namespace views
namespace ui {
class CandidateWindow;
} // namespace ui
namespace chromeos {
namespace input_method {
class CandidateWindow;
class DelayableWidget;
class ModeIndicatorController;
......@@ -48,7 +51,7 @@ class CandidateWindowControllerImpl
// |has_highlighted| to true if infolist_entries contains highlighted entry.
// TODO(mukai): move this method (and tests) to the new InfolistEntry model.
static void ConvertLookupTableToInfolistEntry(
const CandidateWindow& candidate_window,
const ui::CandidateWindow& candidate_window,
std::vector<InfolistEntry>* infolist_entries,
bool* has_highlighted);
......@@ -62,7 +65,8 @@ class CandidateWindowControllerImpl
// IBusPanelCandidateWindowHandlerInterface implementation.
virtual void SetCursorBounds(const gfx::Rect& cursor_bounds,
const gfx::Rect& composition_head) OVERRIDE;
virtual void UpdateLookupTable(const CandidateWindow& candidate_window,
virtual void UpdateLookupTable(
const ui::CandidateWindow& candidate_window,
bool visible) OVERRIDE;
virtual void UpdatePreeditText(const std::string& utf8_text,
unsigned int cursor, bool visible) OVERRIDE;
......
......@@ -58,10 +58,10 @@ class CandidateWindowControllerImplTest : public testing::Test {
TEST_F(CandidateWindowControllerImplTest,
ConvertLookupTableToInfolistEntryTest_DenseCase) {
CandidateWindow candidate_window;
ui::CandidateWindow candidate_window;
candidate_window.set_page_size(10);
for (size_t i = 0; i < kSampleCandidateSize; ++i) {
CandidateWindow::Entry entry;
ui::CandidateWindow::Entry entry;
entry.value = kSampleCandidate[i];
entry.description_title = kSampleDescriptionTitle[i];
entry.description_body = kSampleDescriptionBody[i];
......@@ -84,15 +84,15 @@ TEST_F(CandidateWindowControllerImplTest,
TEST_F(CandidateWindowControllerImplTest,
ConvertLookupTableToInfolistEntryTest_SparseCase) {
CandidateWindow candidate_window;
ui::CandidateWindow candidate_window;
candidate_window.set_page_size(10);
for (size_t i = 0; i < kSampleCandidateSize; ++i) {
CandidateWindow::Entry entry;
ui::CandidateWindow::Entry entry;
entry.value = kSampleCandidate[i];
candidate_window.mutable_candidates()->push_back(entry);
}
std::vector<CandidateWindow::Entry>* candidates =
std::vector<ui::CandidateWindow::Entry>* candidates =
candidate_window.mutable_candidates();
(*candidates)[2].description_title = kSampleDescriptionTitle[2];
(*candidates)[2].description_body = kSampleDescriptionBody[2];
......@@ -115,16 +115,16 @@ TEST_F(CandidateWindowControllerImplTest,
TEST_F(CandidateWindowControllerImplTest,
ConvertLookupTableToInfolistEntryTest_SparseNoSelectionCase) {
CandidateWindow candidate_window;
ui::CandidateWindow candidate_window;
candidate_window.set_page_size(10);
for (size_t i = 0; i < kSampleCandidateSize; ++i) {
CandidateWindow::Entry entry;
ui::CandidateWindow::Entry entry;
entry.value = kSampleCandidate[i];
candidate_window.mutable_candidates()->push_back(entry);
}
std::vector<CandidateWindow::Entry>* candidates =
std::vector<ui::CandidateWindow::Entry>* candidates =
candidate_window.mutable_candidates();
(*candidates)[2].description_title = kSampleDescriptionTitle[2];
(*candidates)[2].description_body = kSampleDescriptionBody[2];
......@@ -148,11 +148,11 @@ TEST_F(CandidateWindowControllerImplTest,
TEST_F(CandidateWindowControllerImplTest,
ConvertLookupTableToInfolistEntryTest_NoInfolistCase) {
CandidateWindow candidate_window;
ui::CandidateWindow candidate_window;
candidate_window.set_page_size(10);
for (size_t i = 0; i < kSampleCandidateSize; ++i) {
CandidateWindow::Entry entry;
ui::CandidateWindow::Entry entry;
entry.value = kSampleCandidate[i];
candidate_window.mutable_candidates()->push_back(entry);
}
......
......@@ -8,7 +8,6 @@
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/chromeos/input_method/candidate_view.h"
#include "chrome/browser/chromeos/input_method/candidate_window_constants.h"
#include "chromeos/ime/candidate_window.h"
#include "ui/gfx/color_utils.h"
#include "ui/gfx/screen.h"
#include "ui/native_theme/native_theme.h"
......@@ -75,7 +74,7 @@ class CandidateWindowBorder : public views::BubbleBorder {
// Computes the page index. For instance, if the page size is 9, and the
// cursor is pointing to 13th candidate, the page index will be 1 (2nd
// page, as the index is zero-origin). Returns -1 on error.
int ComputePageIndex(const CandidateWindow& candidate_window) {
int ComputePageIndex(const ui::CandidateWindow& candidate_window) {
if (candidate_window.page_size() > 0)
return candidate_window.cursor_position() / candidate_window.page_size();
return -1;
......@@ -164,7 +163,7 @@ CandidateWindowView::CandidateWindowView(gfx::NativeView parent)
preedit_->SetVisible(false);
candidate_area_->SetVisible(false);
preedit_->SetBorder(InformationTextArea::BOTTOM);
if (candidate_window_.orientation() == CandidateWindow::VERTICAL) {
if (candidate_window_.orientation() == ui::CandidateWindow::VERTICAL) {
AddChildView(preedit_);
AddChildView(candidate_area_);
AddChildView(auxiliary_text_);
......@@ -232,13 +231,13 @@ void CandidateWindowView::ShowLookupTable() {
}
void CandidateWindowView::UpdateCandidates(
const CandidateWindow& new_candidate_window) {
const ui::CandidateWindow& new_candidate_window) {
// Updating the candidate views is expensive. We'll skip this if possible.
if (!candidate_window_.IsEqual(new_candidate_window)) {
if (candidate_window_.orientation() != new_candidate_window.orientation()) {
// If the new layout is vertical, the aux text should appear at the
// bottom. If horizontal, it should appear between preedit and candidates.
if (new_candidate_window.orientation() == CandidateWindow::VERTICAL) {
if (new_candidate_window.orientation() == ui::CandidateWindow::VERTICAL) {
ReorderChildView(auxiliary_text_, -1);
auxiliary_text_->SetAlignment(gfx::ALIGN_RIGHT);
auxiliary_text_->SetBorder(InformationTextArea::TOP);
......@@ -275,18 +274,18 @@ void CandidateWindowView::UpdateCandidates(
CandidateView* candidate_view = candidate_views_[index_in_page];
// Set the candidate text.
if (candidate_index < new_candidate_window.candidates().size()) {
const CandidateWindow::Entry& entry =
const ui::CandidateWindow::Entry& entry =
new_candidate_window.candidates()[candidate_index];
candidate_view->SetEntry(entry);
candidate_view->SetState(views::Button::STATE_NORMAL);
candidate_view->SetInfolistIcon(!entry.description_title.empty());
} else {
// Disable the empty row.
candidate_view->SetEntry(CandidateWindow::Entry());
candidate_view->SetEntry(ui::CandidateWindow::Entry());
candidate_view->SetState(views::Button::STATE_DISABLED);
candidate_view->SetInfolistIcon(false);
}
if (new_candidate_window.orientation() == CandidateWindow::VERTICAL) {
if (new_candidate_window.orientation() == ui::CandidateWindow::VERTICAL) {
int shortcut_width = 0;
int candidate_width = 0;
candidate_views_[i]->GetPreferredWidths(
......@@ -295,14 +294,14 @@ void CandidateWindowView::UpdateCandidates(
max_candidate_width = std::max(max_candidate_width, candidate_width);
}
}
if (new_candidate_window.orientation() == CandidateWindow::VERTICAL) {
if (new_candidate_window.orientation() == ui::CandidateWindow::VERTICAL) {
for (size_t i = 0; i < candidate_views_.size(); ++i)
candidate_views_[i]->SetWidths(max_shortcut_width, max_candidate_width);
}
CandidateWindowBorder* border = static_cast<CandidateWindowBorder*>(
GetBubbleFrameView()->bubble_border());
if (new_candidate_window.orientation() == CandidateWindow::VERTICAL)
if (new_candidate_window.orientation() == ui::CandidateWindow::VERTICAL)
border->set_offset(max_shortcut_width);
else
border->set_offset(0);
......@@ -343,8 +342,8 @@ void CandidateWindowView::SetCursorBounds(const gfx::Rect& cursor_bounds,
}
void CandidateWindowView::MaybeInitializeCandidateViews(
const CandidateWindow& candidate_window) {
const CandidateWindow::Orientation orientation =
const ui::CandidateWindow& candidate_window) {
const ui::CandidateWindow::Orientation orientation =
candidate_window.orientation();
const size_t page_size = candidate_window.page_size();
......
......@@ -5,7 +5,7 @@
#ifndef CHROME_BROWSER_CHROMEOS_INPUT_METHOD_CANDIDATE_WINDOW_VIEW_H_
#define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_CANDIDATE_WINDOW_VIEW_H_
#include "chromeos/ime/candidate_window.h"
#include "ui/base/ime/candidate_window.h"
#include "ui/views/bubble/bubble_delegate.h"
#include "ui/views/controls/button/button.h"
......@@ -64,7 +64,7 @@ class CandidateWindowView : public views::BubbleDelegateView,
// Updates candidates of the candidate window from |candidate_window|.
// Candidates are arranged per |orientation|.
void UpdateCandidates(const CandidateWindow& candidate_window);
void UpdateCandidates(const ui::CandidateWindow& candidate_window);
void SetCursorBounds(const gfx::Rect& cursor_bounds,
const gfx::Rect& composition_head);
......@@ -80,10 +80,11 @@ class CandidateWindowView : public views::BubbleDelegateView,
void UpdateVisibility();
// Initializes the candidate views if needed.
void MaybeInitializeCandidateViews(const CandidateWindow& candidate_window);
void MaybeInitializeCandidateViews(
const ui::CandidateWindow& candidate_window);
// The candidate window data model.
CandidateWindow candidate_window_;
ui::CandidateWindow candidate_window_;
// The index in the current page of the candidate currently being selected.
int selected_candidate_index_in_page_;
......
......@@ -39,19 +39,19 @@ const char* kSampleDescriptionBody[] = {
};
void InitCandidateWindow(size_t page_size,
CandidateWindow* candidate_window) {
ui::CandidateWindow* candidate_window) {
candidate_window->set_cursor_position(0);
candidate_window->set_page_size(page_size);
candidate_window->mutable_candidates()->clear();
candidate_window->set_orientation(CandidateWindow::VERTICAL);
candidate_window->set_orientation(ui::CandidateWindow::VERTICAL);
}
void InitCandidateWindowWithCandidatesFilled(
size_t page_size,
CandidateWindow* candidate_window) {
ui::CandidateWindow* candidate_window) {
InitCandidateWindow(page_size, candidate_window);
for (size_t i = 0; i < page_size; ++i) {
CandidateWindow::Entry entry;
ui::CandidateWindow::Entry entry;
entry.value = base::StringPrintf("value %lld",
static_cast<unsigned long long>(i));
entry.label = base::StringPrintf("%lld",
......@@ -94,7 +94,8 @@ class CandidateWindowViewTest : public views::ViewsTestBase {
candidate_window_view_->SelectCandidateAt(index_in_page);
}
void MaybeInitializeCandidateViews(const CandidateWindow& candidate_window) {
void MaybeInitializeCandidateViews(
const ui::CandidateWindow& candidate_window) {
candidate_window_view_->MaybeInitializeCandidateViews(candidate_window);
}
......@@ -116,7 +117,7 @@ class CandidateWindowViewTest : public views::ViewsTestBase {
TEST_F(CandidateWindowViewTest, UpdateCandidatesTest_CursorVisibility) {
// Visible (by default) cursor.
CandidateWindow candidate_window;
ui::CandidateWindow candidate_window;
const int candidate_window_size = 9;
InitCandidateWindowWithCandidatesFilled(candidate_window_size,
&candidate_window);
......@@ -141,7 +142,7 @@ TEST_F(CandidateWindowViewTest, UpdateCandidatesTest_CursorVisibility) {
TEST_F(CandidateWindowViewTest, SelectCandidateAtTest) {
// Set 9 candidates.
CandidateWindow candidate_window_large;
ui::CandidateWindow candidate_window_large;
const int candidate_window_large_size = 9;
InitCandidateWindowWithCandidatesFilled(candidate_window_large_size,
&candidate_window_large);
......@@ -152,7 +153,7 @@ TEST_F(CandidateWindowViewTest, SelectCandidateAtTest) {
SelectCandidateAt(candidate_window_large_size - 1);
// Reduce the number of candidates to 3.
CandidateWindow candidate_window_small;
ui::CandidateWindow candidate_window_small;
const int candidate_window_small_size = 3;
InitCandidateWindowWithCandidatesFilled(candidate_window_small_size,
&candidate_window_small);
......@@ -172,7 +173,7 @@ TEST_F(CandidateWindowViewTest, ShortcutSettingTest) {
SCOPED_TRACE("candidate_views allocation test");
const size_t kMaxPageSize = 16;
for (size_t i = 1; i < kMaxPageSize; ++i) {
CandidateWindow candidate_window;
ui::CandidateWindow candidate_window;
InitCandidateWindow(i, &candidate_window);
candidate_window_view()->UpdateCandidates(candidate_window);
EXPECT_EQ(i, GetCandidatesSize());
......@@ -181,12 +182,12 @@ TEST_F(CandidateWindowViewTest, ShortcutSettingTest) {
{
SCOPED_TRACE("Empty string for each labels expects empty labels(vertical)");
const size_t kPageSize = 3;
CandidateWindow candidate_window;
ui::CandidateWindow candidate_window;
InitCandidateWindow(kPageSize, &candidate_window);
candidate_window.set_orientation(CandidateWindow::VERTICAL);
candidate_window.set_orientation(ui::CandidateWindow::VERTICAL);
for (size_t i = 0; i < kPageSize; ++i) {
CandidateWindow::Entry entry;
ui::CandidateWindow::Entry entry;
entry.value = kSampleCandidate[i];
entry.annotation = kSampleAnnotation[i];
entry.description_title = kSampleDescriptionTitle[i];
......@@ -207,12 +208,12 @@ TEST_F(CandidateWindowViewTest, ShortcutSettingTest) {
SCOPED_TRACE(
"Empty string for each labels expect empty labels(horizontal)");
const size_t kPageSize = 3;
CandidateWindow candidate_window;
ui::CandidateWindow candidate_window;
InitCandidateWindow(kPageSize, &candidate_window);
candidate_window.set_orientation(CandidateWindow::HORIZONTAL);
candidate_window.set_orientation(ui::CandidateWindow::HORIZONTAL);
for (size_t i = 0; i < kPageSize; ++i) {
CandidateWindow::Entry entry;
ui::CandidateWindow::Entry entry;
entry.value = kSampleCandidate[i];
entry.annotation = kSampleAnnotation[i];
entry.description_title = kSampleDescriptionTitle[i];
......@@ -233,12 +234,12 @@ TEST_F(CandidateWindowViewTest, ShortcutSettingTest) {
{
SCOPED_TRACE("Vertical customized label case");
const size_t kPageSize = 3;
CandidateWindow candidate_window;
ui::CandidateWindow candidate_window;
InitCandidateWindow(kPageSize, &candidate_window);
candidate_window.set_orientation(CandidateWindow::VERTICAL);
candidate_window.set_orientation(ui::CandidateWindow::VERTICAL);
for (size_t i = 0; i < kPageSize; ++i) {
CandidateWindow::Entry entry;
ui::CandidateWindow::Entry entry;
entry.value = kSampleCandidate[i];
entry.annotation = kSampleAnnotation[i];
entry.description_title = kSampleDescriptionTitle[i];
......@@ -261,12 +262,12 @@ TEST_F(CandidateWindowViewTest, ShortcutSettingTest) {
{
SCOPED_TRACE("Horizontal customized label case");
const size_t kPageSize = 3;
CandidateWindow candidate_window;
ui::CandidateWindow candidate_window;
InitCandidateWindow(kPageSize, &candidate_window);
candidate_window.set_orientation(CandidateWindow::HORIZONTAL);
candidate_window.set_orientation(ui::CandidateWindow::HORIZONTAL);
for (size_t i = 0; i < kPageSize; ++i) {
CandidateWindow::Entry entry;
ui::CandidateWindow::Entry entry;
entry.value = kSampleCandidate[i];
entry.annotation = kSampleAnnotation[i];
entry.description_title = kSampleDescriptionTitle[i];
......@@ -290,8 +291,8 @@ TEST_F(CandidateWindowViewTest, ShortcutSettingTest) {
TEST_F(CandidateWindowViewTest, DoNotChangeRowHeightWithLabelSwitchTest) {
const size_t kPageSize = 10;
CandidateWindow candidate_window;
CandidateWindow no_shortcut_candidate_window;
ui::CandidateWindow candidate_window;
ui::CandidateWindow no_shortcut_candidate_window;
const char kSampleCandidate1[] = "Sample String 1";
const char kSampleCandidate2[] = "\xE3\x81\x82"; // multi byte string.
......@@ -311,10 +312,10 @@ TEST_F(CandidateWindowViewTest, DoNotChangeRowHeightWithLabelSwitchTest) {
candidate_window.set_cursor_position(0);
candidate_window.set_page_size(3);
candidate_window.mutable_candidates()->clear();
candidate_window.set_orientation(CandidateWindow::VERTICAL);
candidate_window.set_orientation(ui::CandidateWindow::VERTICAL);
no_shortcut_candidate_window.CopyFrom(candidate_window);
CandidateWindow::Entry entry;
ui::CandidateWindow::Entry entry;
entry.value = kSampleCandidate1;
entry.annotation = kSampleAnnotation1;
candidate_window.mutable_candidates()->push_back(entry);
......
......@@ -20,7 +20,6 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "chromeos/ime/candidate_window.h"
#include "chromeos/ime/component_extension_ime_manager.h"
#include "chromeos/ime/extension_ime_util.h"
#include "chromeos/ime/ibus_keymap.h"
......@@ -28,6 +27,7 @@
#include "chromeos/ime/input_method_manager.h"
#include "ui/aura/root_window.h"
#include "ui/aura/window.h"
#include "ui/base/ime/candidate_window.h"
#include "ui/events/event.h"
#include "ui/events/keycodes/dom4/keycode_converter.h"
#include "ui/events/keycodes/keyboard_code_conversion_x.h"
......@@ -61,7 +61,7 @@ InputMethodEngine::InputMethodEngine()
observer_(NULL),
preedit_text_(new IBusText()),
preedit_cursor_(0),
candidate_window_(new input_method::CandidateWindow()),
candidate_window_(new ui::CandidateWindow()),
window_visible_(false) {}
InputMethodEngine::~InputMethodEngine() {
......@@ -254,7 +254,7 @@ void InputMethodEngine::SetCandidateWindowProperty(
const CandidateWindowProperty& property) {
// Type conversion from InputMethodEngineInterface::CandidateWindowProperty to
// CandidateWindow::CandidateWindowProperty defined in chromeos/ime/.
input_method::CandidateWindow::CandidateWindowProperty dest_property;
ui::CandidateWindow::CandidateWindowProperty dest_property;
dest_property.page_size = property.page_size;
dest_property.is_cursor_visible = property.is_cursor_visible;
dest_property.is_vertical = property.is_vertical;
......@@ -310,7 +310,7 @@ bool InputMethodEngine::SetCandidates(
candidate_window_->mutable_candidates()->clear();
for (std::vector<Candidate>::const_iterator ix = candidates.begin();
ix != candidates.end(); ++ix) {
input_method::CandidateWindow::Entry entry;
ui::CandidateWindow::Entry entry;
entry.value = ix->value;
entry.label = ix->label;
entry.annotation = ix->annotation;
......
......@@ -13,6 +13,7 @@
#include "url/gurl.h"
namespace ui {
class CandidateWindow;
class KeyEvent;
} // namespace ui
......@@ -21,7 +22,6 @@ namespace chromeos {
class IBusText;
namespace input_method {
class CandidateWindow;
struct InputMethodProperty;
struct KeyEventHandle;
} // namespace input_method
......@@ -128,7 +128,7 @@ class InputMethodEngine : public InputMethodEngineInterface {
int preedit_cursor_;
// The current candidate window.
scoped_ptr<input_method::CandidateWindow> candidate_window_;
scoped_ptr<ui::CandidateWindow> candidate_window_;
// The current candidate window property.
CandidateWindowProperty candidate_window_property_;
......
......@@ -537,7 +537,7 @@ IN_PROC_BROWSER_TEST_P(InputMethodEngineIBusBrowserTest,
EXPECT_TRUE(
mock_candidate_window->last_update_lookup_table_arg().is_visible);
const CandidateWindow& table =
const ui::CandidateWindow& table =
mock_candidate_window->last_update_lookup_table_arg().lookup_table;
EXPECT_TRUE(table.is_cursor_visible());
}
......@@ -562,13 +562,13 @@ IN_PROC_BROWSER_TEST_P(InputMethodEngineIBusBrowserTest,
EXPECT_TRUE(
mock_candidate_window->last_update_lookup_table_arg().is_visible);
const CandidateWindow& table =
const ui::CandidateWindow& table =
mock_candidate_window->last_update_lookup_table_arg().lookup_table;
// cursor visibility is kept as before.
EXPECT_TRUE(table.is_cursor_visible());
EXPECT_EQ(CandidateWindow::VERTICAL, table.orientation());
EXPECT_EQ(ui::CandidateWindow::VERTICAL, table.orientation());
}
{
SCOPED_TRACE("setCandidateWindowProperties:pageSize test");
......@@ -591,14 +591,14 @@ IN_PROC_BROWSER_TEST_P(InputMethodEngineIBusBrowserTest,
EXPECT_TRUE(
mock_candidate_window->last_update_lookup_table_arg().is_visible);
const CandidateWindow& table =
const ui::CandidateWindow& table =
mock_candidate_window->last_update_lookup_table_arg().lookup_table;
// cursor visibility is kept as before.
EXPECT_TRUE(table.is_cursor_visible());
// oritantation is kept as before.
EXPECT_EQ(CandidateWindow::VERTICAL, table.orientation());
EXPECT_EQ(ui::CandidateWindow::VERTICAL, table.orientation());
EXPECT_EQ(7U, table.page_size());
}
......@@ -619,7 +619,7 @@ IN_PROC_BROWSER_TEST_P(InputMethodEngineIBusBrowserTest,
set_candidate_window_properties_test_script));
EXPECT_EQ(1, mock_candidate_window->update_lookup_table_call_count());
const input_method::CandidateWindow& table =
const ui::CandidateWindow& table =
mock_candidate_window->last_update_lookup_table_arg().lookup_table;
EXPECT_TRUE(table.is_auxiliary_text_visible());
}
......@@ -641,7 +641,7 @@ IN_PROC_BROWSER_TEST_P(InputMethodEngineIBusBrowserTest,
EXPECT_EQ(1, mock_candidate_window->update_lookup_table_call_count());
// aux text visibility is kept as before.
const input_method::CandidateWindow& table =
const ui::CandidateWindow& table =
mock_candidate_window->last_update_lookup_table_arg().lookup_table;
EXPECT_TRUE(table.is_auxiliary_text_visible());
EXPECT_EQ("AUXILIARY_TEXT", table.auxiliary_text());
......@@ -684,14 +684,14 @@ IN_PROC_BROWSER_TEST_P(InputMethodEngineIBusBrowserTest,
EXPECT_TRUE(
mock_candidate_window->last_update_lookup_table_arg().is_visible);
const CandidateWindow& table =
const ui::CandidateWindow& table =
mock_candidate_window->last_update_lookup_table_arg().lookup_table;
// cursor visibility is kept as before.
EXPECT_TRUE(table.is_cursor_visible());
// oritantation is kept as before.
EXPECT_EQ(CandidateWindow::VERTICAL, table.orientation());
EXPECT_EQ(ui::CandidateWindow::VERTICAL, table.orientation());
// page size is kept as before.
EXPECT_EQ(7U, table.page_size());
......@@ -731,14 +731,14 @@ IN_PROC_BROWSER_TEST_P(InputMethodEngineIBusBrowserTest,
EXPECT_TRUE(
mock_candidate_window->last_update_lookup_table_arg().is_visible);
const CandidateWindow& table =
const ui::CandidateWindow& table =
mock_candidate_window->last_update_lookup_table_arg().lookup_table;
// cursor visibility is kept as before.
EXPECT_TRUE(table.is_cursor_visible());
// oritantation is kept as before.
EXPECT_EQ(CandidateWindow::VERTICAL, table.orientation());
EXPECT_EQ(ui::CandidateWindow::VERTICAL, table.orientation());
// page size is kept as before.
EXPECT_EQ(7U, table.page_size());
......
......@@ -210,8 +210,6 @@
'display/output_util.h',
'display/real_output_configurator_delegate.cc',
'display/real_output_configurator_delegate.h',
'ime/candidate_window.cc',
'ime/candidate_window.h',
'ime/component_extension_ime_manager.cc',
'ime/component_extension_ime_manager.h',
'ime/extension_ime_util.cc',
......@@ -489,7 +487,6 @@
'disks/disk_mount_manager_unittest.cc',
'display/output_configurator_unittest.cc',
'display/output_util_unittest.cc',
'ime/candidate_window_unittest.cc',
'ime/component_extension_ime_manager_unittest.cc',
'ime/extension_ime_util_unittest.cc',
'ime/ibus_text_unittest.cc',
......
// Copyright 2013 The Chromium Authors. All rights reserved.
// Copyright 2014 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 "chromeos/ime/candidate_window.h"
#include "ui/base/ime/candidate_window.h"
#include <string>
#include "base/logging.h"
#include "base/values.h"
namespace chromeos {
namespace input_method {
namespace ui {
namespace {
// The default entry number of a page in CandidateWindow.
......@@ -74,5 +73,4 @@ CandidateWindow::Entry::Entry() {
CandidateWindow::Entry::~Entry() {
}
} // namespace input_method
} // namespace chromeos
} // namespace ui
// Copyright 2013 The Chromium Authors. All rights reserved.
// Copyright 2014 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 CHROMEOS_IME_CANDIDATE_WINDOW_H_
#define CHROMEOS_IME_CANDIDATE_WINDOW_H_
#ifndef UI_BASE_IME_CANDIDATE_WINDOW_H_
#define UI_BASE_IME_CANDIDATE_WINDOW_H_
#include <string>
#include <vector>
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
#include "chromeos/chromeos_export.h"
#include "ui/base/ui_base_export.h"
namespace chromeos {
namespace input_method {
namespace ui {
// CandidateWindow represents the structure of candidates generated from IME.
class CHROMEOS_EXPORT CandidateWindow {
class UI_BASE_EXPORT CandidateWindow {
public:
enum Orientation {
HORIZONTAL = 0,
VERTICAL = 1,
};
struct CandidateWindowProperty {
struct UI_BASE_EXPORT CandidateWindowProperty {
CandidateWindowProperty();
virtual ~CandidateWindowProperty();
int page_size;
......@@ -38,7 +37,7 @@ class CHROMEOS_EXPORT CandidateWindow {
};
// Represents a candidate entry.
struct Entry {
struct UI_BASE_EXPORT Entry {
Entry();
virtual ~Entry();
std::string value;
......@@ -121,7 +120,6 @@ class CHROMEOS_EXPORT CandidateWindow {
DISALLOW_COPY_AND_ASSIGN(CandidateWindow);
};
} // namespace input_method
} // namespace chromeos
} // namespace ui
#endif // CHROMEOS_IME_CANDIDATE_WINDOW_H_
#endif // UI_BASE_IME_CANDIDATE_WINDOW_H_
// Copyright 2013 The Chromium Authors. All rights reserved.
// Copyright 2014 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.
// TODO(nona): Add more tests.
#include "chromeos/ime/candidate_window.h"
#include "ui/base/ime/candidate_window.h"
#include <string>
......@@ -12,8 +12,7 @@
#include "base/memory/scoped_ptr.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace chromeos {
namespace input_method {
namespace ui {
TEST(CandidateWindow, IsEqualTest) {
CandidateWindow cw1;
......@@ -136,5 +135,4 @@ TEST(CandidateWindow, CopyFromTest) {
EXPECT_TRUE(cw1.IsEqual(cw2));
}
} // namespace input_method
} // namespace chromeos
} // namespace ui
......@@ -18,13 +18,11 @@ class Rect;
} // namespace gfx
namespace ui {
class CandidateWindow;
class KeyEvent;
} // namespace ui
namespace chromeos {
namespace input_method {
class CandidateWindow;
} // namespace input_method
class IBusText;
......@@ -111,8 +109,7 @@ class UI_BASE_EXPORT IBusPanelCandidateWindowHandlerInterface {
virtual ~IBusPanelCandidateWindowHandlerInterface() {}
// Called when the IME updates the lookup table.
virtual void UpdateLookupTable(
const input_method::CandidateWindow& candidate_window,
virtual void UpdateLookupTable(const ui::CandidateWindow& candidate_window,
bool visible) = 0;
// Called when the IME updates the preedit text. The |text| is given in
......
......@@ -16,7 +16,7 @@ MockIMECandidateWindowHandler::~MockIMECandidateWindowHandler() {
}
void MockIMECandidateWindowHandler::UpdateLookupTable(
const input_method::CandidateWindow& table,
const ui::CandidateWindow& table,
bool visible) {
++update_lookup_table_call_count_;
last_update_lookup_table_arg_.lookup_table.CopyFrom(table);
......
......@@ -5,7 +5,7 @@
#ifndef UI_BASE_IME_CHROMEOS_MOCK_IME_CANDIDATE_WINDOW_HANDLER_H_
#define UI_BASE_IME_CHROMEOS_MOCK_IME_CANDIDATE_WINDOW_HANDLER_H_
#include "chromeos/ime/candidate_window.h"
#include "ui/base/ime/candidate_window.h"
#include "ui/base/ime/chromeos/ibus_bridge.h"
#include "ui/base/ui_base_export.h"
......@@ -15,7 +15,7 @@ class UI_BASE_EXPORT MockIMECandidateWindowHandler
: public IBusPanelCandidateWindowHandlerInterface {
public:
struct UpdateLookupTableArg {
input_method::CandidateWindow lookup_table;
ui::CandidateWindow lookup_table;
bool is_visible;
};
......@@ -29,7 +29,7 @@ class UI_BASE_EXPORT MockIMECandidateWindowHandler
// IBusPanelCandidateWindowHandlerInterface override.
virtual void UpdateLookupTable(
const input_method::CandidateWindow& candidate_window,
const ui::CandidateWindow& candidate_window,
bool visible) OVERRIDE;
virtual void UpdatePreeditText(const std::string& text, uint32 cursor_pos,
bool visible) OVERRIDE;
......
......@@ -7,6 +7,8 @@
'<(DEPTH)/ui/events/events.gyp:events',
],
'sources': [
'candidate_window.cc',
'candidate_window.h',
'chromeos/character_composer.cc',
'chromeos/character_composer.h',
'chromeos/ibus_bridge.cc',
......
......@@ -4,6 +4,7 @@
{
'sources': [
'candidate_window_unittest.cc',
'chromeos/character_composer_unittest.cc',
'composition_text_util_pango_unittest.cc',
'input_method_base_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