diff options
author | nona@chromium.org <nona@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-30 18:46:19 +0000 |
---|---|---|
committer | nona@chromium.org <nona@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-30 18:46:19 +0000 |
commit | e45a014f99224d1cc7a0e501c39693c6981c0355 (patch) | |
tree | 2324858421df114b6b5745f3ab545837d01919d1 /chrome | |
parent | 27bb74a35b63c1e722e656b7c9783d98187dd9bd (diff) | |
download | chromium_src-e45a014f99224d1cc7a0e501c39693c6981c0355.zip chromium_src-e45a014f99224d1cc7a0e501c39693c6981c0355.tar.gz chromium_src-e45a014f99224d1cc7a0e501c39693c6981c0355.tar.bz2 |
Clean Up: remove unused variable selection_item_id
There is no usage of selection_item_id and radio grouping logic is in engine.
So it is safe to remove selection_item_id from Chrome.
I checked property behaviors and there is no regression on Japanese/Simplified Chinese/Traditional Chinese/Hangul.
(including radio handling, property order, activation handling etc...)
I also checked any properties in all m17n engines, but there is no property.
BUG=None
TEST=Manually done on lumpy
Review URL: https://chromiumcodereview.appspot.com/11416261
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@170496 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
6 files changed, 45 insertions, 80 deletions
diff --git a/chrome/browser/chromeos/input_method/ibus_controller_impl.cc b/chrome/browser/chromeos/input_method/ibus_controller_impl.cc index d537b21..99e755b 100644 --- a/chrome/browser/chromeos/input_method/ibus_controller_impl.cc +++ b/chrome/browser/chromeos/input_method/ibus_controller_impl.cc @@ -48,11 +48,7 @@ bool FindAndUpdateProperty( for (size_t i = 0; i < prop_list->size(); ++i) { chromeos::input_method::InputMethodProperty& prop = prop_list->at(i); if (prop.key == new_prop.key) { - const int saved_id = prop.selection_item_id; - // Update the list except the radio id. As written in - // chromeos_input_method.h, |prop.selection_item_id| is dummy. prop = new_prop; - prop.selection_item_id = saved_id; return true; } } @@ -98,7 +94,6 @@ bool PropertyHasChildren(IBusProperty* prop) { // result to |out_prop_list|. This function returns true on success, and // returns false if sanity checks for |ibus_prop| fail. bool ConvertProperty(IBusProperty* ibus_prop, - int selection_item_id, InputMethodPropertyList* out_prop_list) { DCHECK(ibus_prop); DCHECK(out_prop_list); @@ -128,8 +123,6 @@ bool ConvertProperty(IBusProperty* ibus_prop, } const bool is_selection_item = (type == PROP_TYPE_RADIO); - selection_item_id = is_selection_item ? - selection_item_id : InputMethodProperty::kInvalidSelectionItemId; bool is_selection_item_checked = false; if (state == PROP_STATE_INCONSISTENT) { @@ -168,8 +161,7 @@ bool ConvertProperty(IBusProperty* ibus_prop, out_prop_list->push_back(InputMethodProperty(key, label_to_use, is_selection_item, - is_selection_item_checked, - selection_item_id)); + is_selection_item_checked)); return true; } @@ -181,40 +173,28 @@ bool FlattenProperty(IBusProperty* ibus_prop, DCHECK(ibus_prop); DCHECK(out_prop_list); - int selection_item_id = -1; - std::stack<std::pair<IBusProperty*, int> > prop_stack; - prop_stack.push(std::make_pair(ibus_prop, selection_item_id)); - - while (!prop_stack.empty()) { - IBusProperty* prop = prop_stack.top().first; - const gchar* key = ibus_property_get_key(prop); - const int current_selection_item_id = prop_stack.top().second; - prop_stack.pop(); - - // Filter out unnecessary properties. - if (PropertyKeyIsBlacklisted(key)) - continue; - - // Convert |prop| to InputMethodProperty and push it to |out_prop_list|. - if (!ConvertProperty(prop, current_selection_item_id, out_prop_list)) - return false; - - // Process childrens iteratively (if any). Push all sub properties to the - // stack. - if (PropertyHasChildren(prop)) { - ++selection_item_id; - for (int i = 0;; ++i) { - IBusProperty* sub_prop = - ibus_prop_list_get(ibus_property_get_sub_props(prop), i); - if (!sub_prop) - break; - prop_stack.push(std::make_pair(sub_prop, selection_item_id)); - } - ++selection_item_id; + const gchar* key = ibus_property_get_key(ibus_prop); + + // Filter out unnecessary properties. + if (PropertyKeyIsBlacklisted(key)) + return true; + + // Convert |prop| to InputMethodProperty and push it to |out_prop_list|. + if (!ConvertProperty(ibus_prop, out_prop_list)) + return false; + + // Process childrens iteratively (if any). Push all sub properties to the + // stack. + if (PropertyHasChildren(ibus_prop)) { + for (int i = 0;; ++i) { + IBusProperty* sub_prop = + ibus_prop_list_get(ibus_property_get_sub_props(ibus_prop), i); + if (!sub_prop) + break; + if (!FlattenProperty(sub_prop, out_prop_list)) + return false; } } - std::reverse(out_prop_list->begin(), out_prop_list->end()); - return true; } diff --git a/chrome/browser/chromeos/input_method/ibus_controller_impl_unittest.cc b/chrome/browser/chromeos/input_method/ibus_controller_impl_unittest.cc index dc03170..e3b1640 100644 --- a/chrome/browser/chromeos/input_method/ibus_controller_impl_unittest.cc +++ b/chrome/browser/chromeos/input_method/ibus_controller_impl_unittest.cc @@ -25,27 +25,27 @@ TEST(IBusControllerImplTest, TestFindAndUpdateProperty) { EXPECT_FALSE(FindAndUpdateProperty(InputMethodProperty(), &properties)); properties.push_back( - InputMethodProperty("key1", "label1", false, false, 0)); + InputMethodProperty("key1", "label1", false, false)); EXPECT_FALSE(FindAndUpdateProperty(InputMethodProperty(), &properties)); EXPECT_FALSE(FindAndUpdateProperty( - InputMethodProperty("keyX", "labelX", false, false, 0), &properties)); - EXPECT_EQ(InputMethodProperty("key1", "label1", false, false, 0), + InputMethodProperty("keyX", "labelX", false, false), &properties)); + EXPECT_EQ(InputMethodProperty("key1", "label1", false, false), properties[0]); EXPECT_TRUE(FindAndUpdateProperty( - InputMethodProperty("key1", "labelY", false, false, 0), &properties)); - EXPECT_EQ(InputMethodProperty("key1", "labelY", false, false, 0), + InputMethodProperty("key1", "labelY", false, false), &properties)); + EXPECT_EQ(InputMethodProperty("key1", "labelY", false, false), properties[0]); properties.push_back( - InputMethodProperty("key2", "label2", false, false, 0)); + InputMethodProperty("key2", "label2", false, false)); EXPECT_FALSE(FindAndUpdateProperty(InputMethodProperty(), &properties)); EXPECT_FALSE(FindAndUpdateProperty( - InputMethodProperty("keyX", "labelX", false, false, 0), &properties)); - EXPECT_EQ(InputMethodProperty("key2", "label2", false, false, 0), + InputMethodProperty("keyX", "labelX", false, false), &properties)); + EXPECT_EQ(InputMethodProperty("key2", "label2", false, false), properties[1]); EXPECT_TRUE(FindAndUpdateProperty( - InputMethodProperty("key2", "labelZ", false, false, 0), &properties)); - EXPECT_EQ(InputMethodProperty("key2", "labelZ", false, false, 0), + InputMethodProperty("key2", "labelZ", false, false), &properties)); + EXPECT_EQ(InputMethodProperty("key2", "labelZ", false, false), properties[1]); } diff --git a/chrome/browser/chromeos/input_method/input_method_manager_impl_unittest.cc b/chrome/browser/chromeos/input_method/input_method_manager_impl_unittest.cc index b355bf6..d3de2e0 100644 --- a/chrome/browser/chromeos/input_method/input_method_manager_impl_unittest.cc +++ b/chrome/browser/chromeos/input_method/input_method_manager_impl_unittest.cc @@ -559,8 +559,7 @@ TEST_F(InputMethodManagerImplTest, TestGetCurrentInputMethodProperties) { current_property_list.push_back(InputMethodProperty("key", "label", false, - false, - -1)); + false)); controller_->SetCurrentPropertiesForTesting(current_property_list); controller_->NotifyPropertyChangedForTesting(); @@ -592,8 +591,7 @@ TEST_F(InputMethodManagerImplTest, TestGetCurrentInputMethodPropertiesTwoImes) { current_property_list.push_back(InputMethodProperty("key-mozc", "label", false, - false, - -1)); + false)); controller_->SetCurrentPropertiesForTesting(current_property_list); controller_->NotifyPropertyChangedForTesting(); @@ -609,8 +607,7 @@ TEST_F(InputMethodManagerImplTest, TestGetCurrentInputMethodPropertiesTwoImes) { current_property_list.push_back(InputMethodProperty("key-chewing", "label", false, - false, - -1)); + false)); controller_->SetCurrentPropertiesForTesting(current_property_list); controller_->NotifyPropertyChangedForTesting(); ASSERT_EQ(1U, manager_->GetCurrentInputMethodProperties().size()); diff --git a/chrome/browser/chromeos/input_method/input_method_property.cc b/chrome/browser/chromeos/input_method/input_method_property.cc index caab50e..46f4d7c 100644 --- a/chrome/browser/chromeos/input_method/input_method_property.cc +++ b/chrome/browser/chromeos/input_method/input_method_property.cc @@ -14,20 +14,17 @@ namespace input_method { InputMethodProperty::InputMethodProperty(const std::string& in_key, const std::string& in_label, bool in_is_selection_item, - bool in_is_selection_item_checked, - int in_selection_item_id) + bool in_is_selection_item_checked) : key(in_key), label(in_label), is_selection_item(in_is_selection_item), - is_selection_item_checked(in_is_selection_item_checked), - selection_item_id(in_selection_item_id) { + is_selection_item_checked(in_is_selection_item_checked) { DCHECK(!key.empty()); } InputMethodProperty::InputMethodProperty() : is_selection_item(false), - is_selection_item_checked(false), - selection_item_id(kInvalidSelectionItemId) { + is_selection_item_checked(false) { } InputMethodProperty::~InputMethodProperty() { @@ -37,8 +34,7 @@ bool InputMethodProperty::operator==(const InputMethodProperty& other) const { return key == other.key && label == other.label && is_selection_item == other.is_selection_item && - is_selection_item_checked == other.is_selection_item_checked && - selection_item_id == other.selection_item_id; + is_selection_item_checked == other.is_selection_item_checked; } bool InputMethodProperty::operator!=(const InputMethodProperty& other) const { @@ -50,8 +46,7 @@ std::string InputMethodProperty::ToString() const { stream << "key=" << key << ", label=" << label << ", is_selection_item=" << is_selection_item - << ", is_selection_item_checked=" << is_selection_item_checked - << ", selection_item_id=" << selection_item_id; + << ", is_selection_item_checked=" << is_selection_item_checked; return stream.str(); } diff --git a/chrome/browser/chromeos/input_method/input_method_property.h b/chrome/browser/chromeos/input_method/input_method_property.h index 4016111..8745221 100644 --- a/chrome/browser/chromeos/input_method/input_method_property.h +++ b/chrome/browser/chromeos/input_method/input_method_property.h @@ -16,8 +16,7 @@ struct InputMethodProperty { InputMethodProperty(const std::string& in_key, const std::string& in_label, bool in_is_selection_item, - bool in_is_selection_item_checked, - int in_selection_item_id); + bool in_is_selection_item_checked); InputMethodProperty(); ~InputMethodProperty(); @@ -35,10 +34,6 @@ struct InputMethodProperty { bool is_selection_item; // true if the property is a selection item. bool is_selection_item_checked; // true if |is_selection_item| is true and // the selection_item is selected. - int selection_item_id; // A group ID (>= 0) of the selection item. - // kInvalidSelectionItemId if |is_selection_item| is - // false. - static const int kInvalidSelectionItemId = -1; }; typedef std::vector<InputMethodProperty> InputMethodPropertyList; diff --git a/chrome/browser/chromeos/input_method/input_method_property_unittest.cc b/chrome/browser/chromeos/input_method/input_method_property_unittest.cc index 5ff653a..3c7f7ad 100644 --- a/chrome/browser/chromeos/input_method/input_method_property_unittest.cc +++ b/chrome/browser/chromeos/input_method/input_method_property_unittest.cc @@ -11,13 +11,12 @@ namespace input_method { TEST(InputMethodPropertyTest, TestOperatorEqual) { InputMethodProperty empty; - InputMethodProperty reference("key", "label", true, true, 1); + InputMethodProperty reference("key", "label", true, true); - InputMethodProperty p1("X", "label", true, true, 1); - InputMethodProperty p2("key", "X", true, true, 1); - InputMethodProperty p3("key", "label", false, true, 1); - InputMethodProperty p4("key", "label", true, false, 1); - InputMethodProperty p5("key", "label", true, true, 0); + InputMethodProperty p1("X", "label", true, true); + InputMethodProperty p2("key", "X", true, true); + InputMethodProperty p3("key", "label", false, true); + InputMethodProperty p4("key", "label", true, false); EXPECT_EQ(empty, empty); EXPECT_EQ(reference, reference); @@ -26,7 +25,6 @@ TEST(InputMethodPropertyTest, TestOperatorEqual) { EXPECT_NE(reference, p2); EXPECT_NE(reference, p3); EXPECT_NE(reference, p4); - EXPECT_NE(reference, p5); } } // namespace input_method |