summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-11 01:38:50 +0000
committertfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-11 01:38:50 +0000
commit3ce9f01e0678bcdf044efeb871fef4179573a3bc (patch)
tree3fbc53f60a12953d163d32802cfa56fe5a062dd4
parent071f94e501d86db8dfa2a3c0806a2388216bb239 (diff)
downloadchromium_src-3ce9f01e0678bcdf044efeb871fef4179573a3bc.zip
chromium_src-3ce9f01e0678bcdf044efeb871fef4179573a3bc.tar.gz
chromium_src-3ce9f01e0678bcdf044efeb871fef4179573a3bc.tar.bz2
Cleanup: Get rid of TreeNodeChildrenReordered.
Reason: This function was never implemented by TreeNodeModel and is unlike it will be. Also it proved to not be necessary at all. BUG=None TEST=trybots Review URL: http://codereview.chromium.org/3091016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@55657 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--app/tree_model.h5
-rw-r--r--app/tree_node_model_unittest.cc17
-rw-r--r--chrome/browser/cocoa/cookies_window_controller.h12
-rw-r--r--chrome/browser/cocoa/cookies_window_controller.mm29
-rw-r--r--chrome/browser/cocoa/cookies_window_controller_unittest.mm50
-rw-r--r--chrome/browser/gtk/gtk_tree.cc5
-rw-r--r--chrome/browser/gtk/gtk_tree.h6
-rw-r--r--chrome/browser/views/options/cookies_view.h11
-rw-r--r--views/controls/tree/tree_view.cc38
-rw-r--r--views/controls/tree/tree_view.h6
10 files changed, 14 insertions, 165 deletions
diff --git a/app/tree_model.h b/app/tree_model.h
index 353b56b..e191745 100644
--- a/app/tree_model.h
+++ b/app/tree_model.h
@@ -42,11 +42,6 @@ class TreeModelObserver {
int start,
int count) = 0;
- // Notification the children of |parent| have been reordered. Note, only
- // the direct children of |parent| have been reordered, not descendants.
- virtual void TreeNodeChildrenReordered(TreeModel* model,
- TreeModelNode* parent) = 0;
-
// Notification that the contents of a node has changed.
virtual void TreeNodeChanged(TreeModel* model, TreeModelNode* node) = 0;
diff --git a/app/tree_node_model_unittest.cc b/app/tree_node_model_unittest.cc
index 3b32495..ce12b16 100644
--- a/app/tree_node_model_unittest.cc
+++ b/app/tree_node_model_unittest.cc
@@ -10,19 +10,17 @@ class TreeNodeModelTest : public testing::Test, public TreeModelObserver {
TreeNodeModelTest()
: added_count_(0),
removed_count_(0),
- reordered_count_(0),
changed_count_(0) {}
void AssertObserverCount(int added_count, int removed_count,
- int reordered_count, int changed_count) {
+ int changed_count) {
ASSERT_EQ(added_count, added_count_);
ASSERT_EQ(removed_count, removed_count_);
- ASSERT_EQ(reordered_count, reordered_count_);
ASSERT_EQ(changed_count, changed_count_);
}
void ClearCounts() {
- added_count_ = removed_count_ = reordered_count_ = changed_count_ = 0;
+ added_count_ = removed_count_ = changed_count_ = 0;
}
// Begin TreeModelObserver implementation.
@@ -34,10 +32,6 @@ class TreeNodeModelTest : public testing::Test, public TreeModelObserver {
int start, int count) {
removed_count_++;
}
- virtual void TreeNodeChildrenReordered(TreeModel* model,
- TreeModelNode* parent) {
- reordered_count_++;
- }
virtual void TreeNodeChanged(TreeModel* model, TreeModelNode* node) {
changed_count_++;
}
@@ -46,7 +40,6 @@ class TreeNodeModelTest : public testing::Test, public TreeModelObserver {
private:
int added_count_;
int removed_count_;
- int reordered_count_;
int changed_count_;
DISALLOW_COPY_AND_ASSIGN(TreeNodeModelTest);
@@ -72,7 +65,7 @@ TEST_F(TreeNodeModelTest, AddNode) {
new TreeNodeWithValue<int>(L"child 1", 1);
model.Add(root, 0, child1);
- AssertObserverCount(1, 0, 0, 0);
+ AssertObserverCount(1, 0, 0);
// Add two nodes under the |child1|.
TreeNodeWithValue<int>* foo1 =
@@ -118,7 +111,7 @@ TEST_F(TreeNodeModelTest, RemoveNode) {
// Now remove the |child1| from root and release the memory.
delete model.Remove(root, 0);
- AssertObserverCount(0, 1, 0, 0);
+ AssertObserverCount(0, 1, 0);
ASSERT_EQ(0, model.GetChildCount(root));
}
@@ -287,6 +280,6 @@ TEST_F(TreeNodeModelTest, SetTitle) {
const std::wstring title(L"root2");
model.SetTitle(root, title);
- AssertObserverCount(0, 0, 0, 1);
+ AssertObserverCount(0, 0, 1);
EXPECT_EQ(WideToUTF16(title), root->GetTitleAsString16());
}
diff --git a/chrome/browser/cocoa/cookies_window_controller.h b/chrome/browser/cocoa/cookies_window_controller.h
index ea3e0fd..0f6217f 100644
--- a/chrome/browser/cocoa/cookies_window_controller.h
+++ b/chrome/browser/cocoa/cookies_window_controller.h
@@ -27,25 +27,17 @@ class CookiesTreeModelObserverBridge : public CookiesTreeModel::Observer {
public:
explicit CookiesTreeModelObserverBridge(CookiesWindowController* controller);
- // Notification that nodes were added to the specified parent.
+ // Begin TreeModelObserver implementation.
virtual void TreeNodesAdded(TreeModel* model,
TreeModelNode* parent,
int start,
int count);
-
- // Notification that nodes were removed from the specified parent.
virtual void TreeNodesRemoved(TreeModel* model,
TreeModelNode* parent,
int start,
int count);
-
- // Notification the children of |parent| have been reordered. Note, only
- // the direct children of |parent| have been reordered, not descendants.
- virtual void TreeNodeChildrenReordered(TreeModel* model,
- TreeModelNode* parent);
-
- // Notification that the contents of a node has changed.
virtual void TreeNodeChanged(TreeModel* model, TreeModelNode* node);
+ // End TreeModelObserver implementation.
virtual void TreeModelBeginBatch(CookiesTreeModel* model);
virtual void TreeModelEndBatch(CookiesTreeModel* model);
diff --git a/chrome/browser/cocoa/cookies_window_controller.mm b/chrome/browser/cocoa/cookies_window_controller.mm
index 6085279..0984294 100644
--- a/chrome/browser/cocoa/cookies_window_controller.mm
+++ b/chrome/browser/cocoa/cookies_window_controller.mm
@@ -70,35 +70,6 @@ void CookiesTreeModelObserverBridge::TreeNodesRemoved(TreeModel* model,
[window_controller_ didChangeValueForKey:kCocoaTreeModel];
}
-// Notification the children of |parent| have been reordered. Note, only
-// the direct children of |parent| have been reordered, not descendants.
-void CookiesTreeModelObserverBridge::TreeNodeChildrenReordered(TreeModel* model,
- TreeModelNode* parent) {
- // We're in for a major rebuild. Ignore this request.
- if (batch_update_ || !HasCocoaModel())
- return;
-
- CocoaCookieTreeNode* cocoa_parent = FindCocoaNode(parent, nil);
- NSMutableArray* cocoa_children = [cocoa_parent mutableChildren];
-
- CookieTreeNode* cookie_parent = static_cast<CookieTreeNode*>(parent);
- const int child_count = cookie_parent->GetChildCount();
-
- [window_controller_ willChangeValueForKey:kCocoaTreeModel];
- for (int i = 0; i < child_count; ++i) {
- CookieTreeNode* swap_in = cookie_parent->GetChild(i);
- for (int j = i; j < child_count; ++j) {
- CocoaCookieTreeNode* child = [cocoa_children objectAtIndex:j];
- TreeModelNode* swap_out = [child treeNode];
- if (swap_in == swap_out) {
- [cocoa_children exchangeObjectAtIndex:j withObjectAtIndex:i];
- break;
- }
- }
- }
- [window_controller_ didChangeValueForKey:kCocoaTreeModel];
-}
-
// Notification that the contents of a node has changed.
void CookiesTreeModelObserverBridge::TreeNodeChanged(TreeModel* model,
TreeModelNode* node) {
diff --git a/chrome/browser/cocoa/cookies_window_controller_unittest.mm b/chrome/browser/cocoa/cookies_window_controller_unittest.mm
index 531d0c2..967d918 100644
--- a/chrome/browser/cocoa/cookies_window_controller_unittest.mm
+++ b/chrome/browser/cocoa/cookies_window_controller_unittest.mm
@@ -275,56 +275,6 @@ TEST_F(CookiesWindowControllerTest, TreeNodesRemoved) {
EXPECT_NSEQ(@"A", title);
}
-TEST_F(CookiesWindowControllerTest, TreeNodeChildrenReordered) {
- const GURL url = GURL("http://foo.com");
- TestingProfile* profile = browser_helper_.profile();
- net::CookieMonster* cm = profile->GetCookieMonster();
- cm->SetCookie(url, "A=B");
- cm->SetCookie(url, "C=D");
- cm->SetCookie(url, "E=F");
-
- controller_.reset(
- [[CookiesWindowController alloc] initWithProfile:profile
- databaseHelper:database_helper_
- storageHelper:local_storage_helper_
- appcacheHelper:appcache_helper_]);
-
- // Root --> foo.com --> Cookies.
- NSMutableArray* cocoa_children =
- [[[[[[controller_ cocoaTreeModel] children] objectAtIndex:0]
- children] objectAtIndex:0] mutableChildren];
- EXPECT_EQ(3U, [cocoa_children count]);
-
- // Check default ordering.
- CocoaCookieTreeNode* node = [cocoa_children objectAtIndex:0];
- EXPECT_NSEQ(@"A", [[node details] name]);
- node = [cocoa_children objectAtIndex:1];
- EXPECT_NSEQ(@"C", [[node details] name]);
- node = [cocoa_children objectAtIndex:2];
- EXPECT_NSEQ(@"E", [[node details] name]);
-
- CookiesTreeModel* model = [controller_ treeModel];
- // Root --> foo.com --> Cookies.
- CookieTreeNode* parent = model->GetRoot()->GetChild(0)->GetChild(0);
-
- // Reorder the nodes.
- CookieTreeNode* node_e = parent->Remove(2);
- CookieTreeNode* node_c = parent->Remove(1);
- parent->Add(0, node_e);
- parent->Add(2, node_c);
-
- // Notify the observer of the reordering.
- [controller_ modelObserver]->TreeNodeChildrenReordered(model, parent);
-
- // Check the new order.
- node = [cocoa_children objectAtIndex:0];
- EXPECT_NSEQ(@"E", [[node details] name]);
- node = [cocoa_children objectAtIndex:1];
- EXPECT_NSEQ(@"A", [[node details] name]);
- node = [cocoa_children objectAtIndex:2];
- EXPECT_NSEQ(@"C", [[node details] name]);
-}
-
TEST_F(CookiesWindowControllerTest, TreeNodeChanged) {
const GURL url = GURL("http://foo.com");
TestingProfile* profile = browser_helper_.profile();
diff --git a/chrome/browser/gtk/gtk_tree.cc b/chrome/browser/gtk/gtk_tree.cc
index 5594c58..eeb4511 100644
--- a/chrome/browser/gtk/gtk_tree.cc
+++ b/chrome/browser/gtk/gtk_tree.cc
@@ -278,11 +278,6 @@ void TreeAdapter::TreeNodesRemoved(TreeModel* model,
delegate_->OnAnyModelUpdate();
}
-void TreeAdapter::TreeNodeChildrenReordered(TreeModel* model,
- TreeModelNode* parent) {
- NOTIMPLEMENTED();
-}
-
void TreeAdapter::TreeNodeChanged(TreeModel* model, TreeModelNode* node) {
delegate_->OnAnyModelUpdateStart();
GtkTreeIter iter;
diff --git a/chrome/browser/gtk/gtk_tree.h b/chrome/browser/gtk/gtk_tree.h
index c9ae35e..a302bba 100644
--- a/chrome/browser/gtk/gtk_tree.h
+++ b/chrome/browser/gtk/gtk_tree.h
@@ -95,7 +95,6 @@ class TableAdapter : public TableModelObserver {
// A helper class for populating a GtkTreeStore from a TreeModel.
// TODO(mattm): support SetRootShown(true)
-// TODO(mattm): implement TreeNodeChildrenReordered
class TreeAdapter : public TreeModelObserver {
public:
// Column ids for |tree_store_|.
@@ -131,7 +130,7 @@ class TreeAdapter : public TreeModelObserver {
// Get the TreeModelNode corresponding to iter in the tree store.
TreeModelNode* GetNode(GtkTreeIter* iter);
- // TreeModelObserver implementation.
+ // Begin TreeModelObserver implementation.
virtual void TreeNodesAdded(TreeModel* model,
TreeModelNode* parent,
int start,
@@ -140,9 +139,8 @@ class TreeAdapter : public TreeModelObserver {
TreeModelNode* parent,
int start,
int count);
- virtual void TreeNodeChildrenReordered(TreeModel* model,
- TreeModelNode* parent);
virtual void TreeNodeChanged(TreeModel* model, TreeModelNode* node);
+ // End TreeModelObserver implementation.
private:
// Fill the tree store values for a given node.
diff --git a/chrome/browser/views/options/cookies_view.h b/chrome/browser/views/options/cookies_view.h
index 5ea3fe1..ce51933 100644
--- a/chrome/browser/views/options/cookies_view.h
+++ b/chrome/browser/views/options/cookies_view.h
@@ -52,24 +52,17 @@ class CookiesView : public CookiesTreeModel::Observer,
// Updates the display to show only the search results.
void UpdateSearchResults();
- // TreeModelObserver implementation.
+ // Begin TreeModelObserver implementation.
virtual void TreeNodesAdded(TreeModel* model,
TreeModelNode* parent,
int start,
int count);
-
- // TreeModelObserver implementation.
virtual void TreeNodesRemoved(TreeModel* model,
TreeModelNode* parent,
int start,
int count) {}
-
- // TreeModelObserver implementation.
- virtual void TreeNodeChildrenReordered(TreeModel* model,
- TreeModelNode* parent) {}
-
- // TreeModelObserver implementation.
virtual void TreeNodeChanged(TreeModel* model, TreeModelNode* node) {}
+ // End TreeModelObserver implementation.
// views::ButtonListener implementation.
virtual void ButtonPressed(views::Button* sender, const views::Event& event);
diff --git a/views/controls/tree/tree_view.cc b/views/controls/tree/tree_view.cc
index e47eda8..8657695 100644
--- a/views/controls/tree/tree_view.cc
+++ b/views/controls/tree/tree_view.cc
@@ -291,44 +291,6 @@ void TreeView::TreeNodesRemoved(TreeModel* model,
}
}
-namespace {
-
-// Callback function used to compare two items. The first two args are the
-// LPARAMs of the HTREEITEMs being compared. The last arg maps from LPARAM
-// to order. This is invoked from TreeNodeChildrenReordered.
-int CALLBACK CompareTreeItems(LPARAM item1_lparam,
- LPARAM item2_lparam,
- LPARAM map_as_lparam) {
- std::map<int, int>& mapping =
- *reinterpret_cast<std::map<int, int>*>(map_as_lparam);
- return mapping[static_cast<int>(item1_lparam)] -
- mapping[static_cast<int>(item2_lparam)];
-}
-
-} // namespace
-
-void TreeView::TreeNodeChildrenReordered(TreeModel* model,
- TreeModelNode* parent) {
- DCHECK(parent);
- if (model_->GetChildCount(parent) <= 1)
- return;
-
- TVSORTCB sort_details;
- sort_details.hParent = GetTreeItemForNodeDuringMutation(parent);
- if (!sort_details.hParent)
- return;
-
- std::map<int, int> lparam_to_order_map;
- for (int i = 0; i < model_->GetChildCount(parent); ++i) {
- TreeModelNode* node = model_->GetChild(parent, i);
- lparam_to_order_map[GetNodeDetails(node)->id] = i;
- }
-
- sort_details.lpfnCompare = &CompareTreeItems;
- sort_details.lParam = reinterpret_cast<LPARAM>(&lparam_to_order_map);
- TreeView_SortChildrenCB(tree_view_, &sort_details, 0);
-}
-
void TreeView::TreeNodeChanged(TreeModel* model, TreeModelNode* node) {
if (node_to_details_map_.find(node) == node_to_details_map_.end()) {
// User hasn't navigated to this entry yet. Ignore the change.
diff --git a/views/controls/tree/tree_view.h b/views/controls/tree/tree_view.h
index 6d1fdac..c97149b 100644
--- a/views/controls/tree/tree_view.h
+++ b/views/controls/tree/tree_view.h
@@ -121,7 +121,8 @@ class TreeView : public NativeControl, TreeModelObserver {
// true.
void SetRootShown(bool root_visible);
- // TreeModelObserver methods. Don't call these directly, instead your model
+ // Begin TreeModelObserver implementation.
+ // Don't call these directly, instead your model
// should notify the observer TreeView adds to it.
virtual void TreeNodesAdded(TreeModel* model,
TreeModelNode* parent,
@@ -131,9 +132,8 @@ class TreeView : public NativeControl, TreeModelObserver {
TreeModelNode* parent,
int start,
int count);
- virtual void TreeNodeChildrenReordered(TreeModel* model,
- TreeModelNode* parent);
virtual void TreeNodeChanged(TreeModel* model, TreeModelNode* node);
+ // End TreeModelObserver implementation.
// Sets the controller, which may be null. TreeView does not take ownership
// of the controller.