OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chromeos/dbus/ibus/ibus_lookup_table.h" | 5 #include "chromeos/ime/candidate_window.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 | 10 |
11 namespace chromeos { | 11 namespace chromeos { |
| 12 namespace input_method { |
12 | 13 |
13 namespace { | 14 namespace { |
14 // The default entry number of a page in IBusLookupTable. | 15 // The default entry number of a page in CandidateWindow. |
15 const int kDefaultPageSize = 9; | 16 const int kDefaultPageSize = 9; |
16 } // namespace | 17 } // namespace |
17 | 18 |
18 /////////////////////////////////////////////////////////////////////////////// | 19 CandidateWindow::CandidateWindow() |
19 // IBusLookupTable | |
20 IBusLookupTable::IBusLookupTable() | |
21 : property_(new CandidateWindowProperty) { | 20 : property_(new CandidateWindowProperty) { |
22 } | 21 } |
23 | 22 |
24 IBusLookupTable::~IBusLookupTable() { | 23 CandidateWindow::~CandidateWindow() { |
25 } | 24 } |
26 | 25 |
27 bool IBusLookupTable::IsEqual(const IBusLookupTable& table) const { | 26 bool CandidateWindow::IsEqual(const CandidateWindow& cw) const { |
28 if (page_size() != table.page_size() || | 27 if (page_size() != cw.page_size() || |
29 cursor_position() != table.cursor_position() || | 28 cursor_position() != cw.cursor_position() || |
30 is_cursor_visible() != table.is_cursor_visible() || | 29 is_cursor_visible() != cw.is_cursor_visible() || |
31 orientation() != table.orientation() || | 30 orientation() != cw.orientation() || |
32 show_window_at_composition() != table.show_window_at_composition() || | 31 show_window_at_composition() != cw.show_window_at_composition() || |
33 candidates_.size() != table.candidates_.size()) | 32 candidates_.size() != cw.candidates_.size()) |
34 return false; | 33 return false; |
35 | 34 |
36 for (size_t i = 0; i < candidates_.size(); ++i) { | 35 for (size_t i = 0; i < candidates_.size(); ++i) { |
37 const Entry& left = candidates_[i]; | 36 const Entry& left = candidates_[i]; |
38 const Entry& right = table.candidates_[i]; | 37 const Entry& right = cw.candidates_[i]; |
39 if (left.value != right.value || | 38 if (left.value != right.value || |
40 left.label != right.label || | 39 left.label != right.label || |
41 left.annotation != right.annotation || | 40 left.annotation != right.annotation || |
42 left.description_title != right.description_title || | 41 left.description_title != right.description_title || |
43 left.description_body != right.description_body) | 42 left.description_body != right.description_body) |
44 return false; | 43 return false; |
45 } | 44 } |
46 return true; | 45 return true; |
47 } | 46 } |
48 | 47 |
49 void IBusLookupTable::CopyFrom(const IBusLookupTable& table) { | 48 void CandidateWindow::CopyFrom(const CandidateWindow& cw) { |
50 SetProperty(table.GetProperty()); | 49 SetProperty(cw.GetProperty()); |
51 candidates_.clear(); | 50 candidates_.clear(); |
52 candidates_ = table.candidates_; | 51 candidates_ = cw.candidates_; |
53 } | 52 } |
54 | 53 |
55 | 54 |
56 // When the default values are changed, please modify | 55 // When the default values are changed, please modify |
57 // InputMethodEngine::CandidateWindowProperty too. | 56 // InputMethodEngine::CandidateWindowProperty too. |
58 IBusLookupTable::CandidateWindowProperty::CandidateWindowProperty() | 57 CandidateWindow::CandidateWindowProperty::CandidateWindowProperty() |
59 : page_size(kDefaultPageSize), | 58 : page_size(kDefaultPageSize), |
60 cursor_position(0), | 59 cursor_position(0), |
61 is_cursor_visible(true), | 60 is_cursor_visible(true), |
62 is_vertical(false), | 61 is_vertical(false), |
63 show_window_at_composition(false) { | 62 show_window_at_composition(false) { |
64 } | 63 } |
65 | 64 |
66 IBusLookupTable::CandidateWindowProperty::~CandidateWindowProperty() { | 65 CandidateWindow::CandidateWindowProperty::~CandidateWindowProperty() { |
67 } | 66 } |
68 | 67 |
69 IBusLookupTable::Entry::Entry() { | 68 CandidateWindow::Entry::Entry() { |
70 } | 69 } |
71 | 70 |
72 IBusLookupTable::Entry::~Entry() { | 71 CandidateWindow::Entry::~Entry() { |
73 } | 72 } |
74 | 73 |
| 74 } // namespace input_method |
75 } // namespace chromeos | 75 } // namespace chromeos |
OLD | NEW |