diff options
author | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-11 23:50:55 +0000 |
---|---|---|
committer | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-11 23:50:55 +0000 |
commit | 0d52b23006174f37ba0337c170506b9580ccaf29 (patch) | |
tree | 889e57066b28a69e288132c72d0dc560cf5e2051 /views/focus | |
parent | 1bdf29eb27c00bd1be0a6f3eb65d33ecddde274f (diff) | |
download | chromium_src-0d52b23006174f37ba0337c170506b9580ccaf29.zip chromium_src-0d52b23006174f37ba0337c170506b9580ccaf29.tar.gz chromium_src-0d52b23006174f37ba0337c170506b9580ccaf29.tar.bz2 |
Removing floating views, they are not used anymore.
BUG=None
TEST=Run unit_tests, ui_tests, interactive ui_tests.
Make sure focus traversal still works.
Review URL: http://codereview.chromium.org/113215
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15817 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/focus')
-rw-r--r-- | views/focus/view_storage.cc | 101 | ||||
-rw-r--r-- | views/focus/view_storage.h | 19 |
2 files changed, 23 insertions, 97 deletions
diff --git a/views/focus/view_storage.cc b/views/focus/view_storage.cc index a108530..9b8b9ee 100644 --- a/views/focus/view_storage.cc +++ b/views/focus/view_storage.cc @@ -11,27 +11,6 @@ namespace views { -// This struct contains the information to locate a specific view. -// Locating a view is not always straight-forward as a view can be a floating -// view, or the child of a floating view. Floating views are frequently deleted -// and recreated (typically when their container is laid out). -struct ViewLocationInfo { - // True if the view is floating or the child of a floating view. False - // otherwise. - bool is_floating_view; - - // If non floating, this is the stored view. If floating, the parent of the - // floating view. - View* view; - - // The id of the floating view. - int floating_view_id; - - // The path from the floating view to the stored view. The path is composed - // of the indexes of the views in the hierarchy. - std::vector<int> floating_view_to_view_path; -}; - // static ViewStorage* ViewStorage::GetSharedInstance() { return Singleton<ViewStorage>::get(); @@ -41,9 +20,6 @@ ViewStorage::ViewStorage() : view_storage_next_id_(0) { } ViewStorage::~ViewStorage() { - STLDeleteContainerPairSecondPointers(id_to_view_location_.begin(), - id_to_view_location_.end()); - STLDeleteContainerPairSecondPointers(view_to_ids_.begin(), view_to_ids_.end()); } @@ -54,38 +30,21 @@ int ViewStorage::CreateStorageID() { void ViewStorage::StoreView(int storage_id, View* view) { DCHECK(view); - std::map<int, ViewLocationInfo*>::iterator iter = - id_to_view_location_.find(storage_id); - DCHECK(iter == id_to_view_location_.end()); + std::map<int, View*>::iterator iter = id_to_view_.find(storage_id); - if (iter != id_to_view_location_.end()) + if (iter != id_to_view_.end()) { + NOTREACHED(); RemoveView(storage_id); - - ViewLocationInfo* view_location_info = new ViewLocationInfo(); - View* floating_view_parent = view->RetrieveFloatingViewParent(); - if (floating_view_parent) { - // The view is a floating view or is a child of a floating view. - view_location_info->is_floating_view = true; - view_location_info->view = floating_view_parent->GetParent(); - view_location_info->floating_view_id = - floating_view_parent->GetFloatingViewID(); - // Ley's store the path from the floating view to the actual view so we can - // locate it when restoring. - View::GetViewPath(floating_view_parent, view, - &(view_location_info->floating_view_to_view_path)); - } else { - // It is a non floating view, it can be stored as is. - view_location_info->is_floating_view = false; - view_location_info->view = view; } - id_to_view_location_[storage_id] = view_location_info; + + id_to_view_[storage_id] = view; std::vector<int>* ids = NULL; std::map<View*, std::vector<int>*>::iterator id_iter = - view_to_ids_.find(view_location_info->view); + view_to_ids_.find(view); if (id_iter == view_to_ids_.end()) { ids = new std::vector<int>(); - view_to_ids_[view_location_info->view] = ids; + view_to_ids_[view] = ids; } else { ids = id_iter->second; } @@ -93,31 +52,10 @@ void ViewStorage::StoreView(int storage_id, View* view) { } View* ViewStorage::RetrieveView(int storage_id) { - std::map<int, ViewLocationInfo*>::iterator iter = - id_to_view_location_.find(storage_id); - if (iter == id_to_view_location_.end()) + std::map<int, View*>::iterator iter = id_to_view_.find(storage_id); + if (iter == id_to_view_.end()) return NULL; - - ViewLocationInfo* view_location_info = iter->second; - if (view_location_info->is_floating_view) { - View* floating_view = view_location_info->view-> - RetrieveFloatingViewForID(view_location_info->floating_view_id); - View* v = NULL; - if (floating_view) { - v = View::GetViewForPath(floating_view, - view_location_info->floating_view_to_view_path); - } - if (!v) { - // If we have not found the view, it means either the floating view with - // the id we have is gone, or it has changed and the actual child view - // we have the path for is not accessible. In that case, let's make sure - // we don't leak the ViewLocationInfo. - RemoveView(storage_id); - } - return v; - } else { - return view_location_info->view; - } + return iter->second; } void ViewStorage::RemoveView(int storage_id) { @@ -141,15 +79,12 @@ void ViewStorage::ViewRemoved(View* parent, View* removed) { void ViewStorage::EraseView(int storage_id, bool remove_all_ids) { // Remove the view from id_to_view_location_. - std::map<int, ViewLocationInfo*>::iterator location_iter = - id_to_view_location_.find(storage_id); - if (location_iter == id_to_view_location_.end()) + std::map<int, View*>::iterator view_iter = id_to_view_.find(storage_id); + if (view_iter == id_to_view_.end()) return; - ViewLocationInfo* view_location = location_iter->second; - View* view = view_location->view; - delete view_location; - id_to_view_location_.erase(location_iter); + View* view = view_iter->second; + id_to_view_.erase(view_iter); // Also update view_to_ids_. std::map<View*, std::vector<int>*>::iterator ids_iter = @@ -159,11 +94,9 @@ void ViewStorage::EraseView(int storage_id, bool remove_all_ids) { if (remove_all_ids) { for (size_t i = 0; i < ids->size(); ++i) { - location_iter = id_to_view_location_.find((*ids)[i]); - if (location_iter != id_to_view_location_.end()) { - delete location_iter->second; - id_to_view_location_.erase(location_iter); - } + view_iter = id_to_view_.find((*ids)[i]); + if (view_iter != id_to_view_.end()) + id_to_view_.erase(view_iter); } ids->clear(); } else { diff --git a/views/focus/view_storage.h b/views/focus/view_storage.h index 9182429..e72386a 100644 --- a/views/focus/view_storage.h +++ b/views/focus/view_storage.h @@ -10,21 +10,15 @@ // This class is a simple storage place for storing/retrieving views. It is // used for example in the FocusManager to store/restore focused views when the -// main window becomes active/inactive. It supports floating views, meaning -// that when you store a view, it can be retrieved even if it is a floating -// view or the child of a floating view that has been detached since the view -// was stored (in which case the floating view is recreated and reattached). -// It also automatically removes a view from the storage if the view is removed -// from the tree hierarchy (or in the case of a floating view, if the view -// containing the floating view is removed). +// main window becomes active/inactive. +// It automatically removes a view from the storage if the view is removed from +// the tree hierarchy. // // To use it, you first need to create a view storage id that can then be used // to store/retrieve views. namespace views { -struct ViewLocationInfo; - class ViewStorage { public: // Returns the global ViewStorage instance. @@ -63,9 +57,8 @@ class ViewStorage { // Next id for the view storage. int view_storage_next_id_; - // The association id to View used for the view storage. The ViewStorage owns - // the ViewLocationInfo. - std::map<int, ViewLocationInfo*> id_to_view_location_; + // The association id to View used for the view storage. + std::map<int, View*> id_to_view_; // Association View to id, used to speed up view notification removal. std::map<View*, std::vector<int>*> view_to_ids_; @@ -75,4 +68,4 @@ class ViewStorage { } // namespace views -#endif // #ifndef VIEWS_FOCUS_VIEW_STORAGE_H_ +#endif // VIEWS_FOCUS_VIEW_STORAGE_H_ |