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 | |
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')
-rw-r--r-- | views/focus/view_storage.cc | 101 | ||||
-rw-r--r-- | views/focus/view_storage.h | 19 | ||||
-rw-r--r-- | views/view.cc | 300 | ||||
-rw-r--r-- | views/view.h | 146 | ||||
-rw-r--r-- | views/widget/root_view.cc | 104 | ||||
-rw-r--r-- | views/window/non_client_view.cc | 7 | ||||
-rw-r--r-- | views/window/non_client_view.h | 2 |
7 files changed, 44 insertions, 635 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_ diff --git a/views/view.cc b/views/view.cc index cb13cb9..9740fc0 100644 --- a/views/view.cc +++ b/views/view.cc @@ -36,34 +36,6 @@ ViewsDelegate* ViewsDelegate::views_delegate = NULL; // static char View::kViewClassName[] = "views/View"; -//////////////////////////////////////////////////////////////////////////////// -// -// A task used to automatically restore focus on the last focused floating view -// -//////////////////////////////////////////////////////////////////////////////// - -class RestoreFocusTask : public Task { - public: - explicit RestoreFocusTask(View* target) : view_(target) { - } - - ~RestoreFocusTask() {} - - void Cancel() { - view_ = NULL; - } - - void Run() { - if (view_) - view_->RestoreFloatingViewFocus(); - } - private: - // The target view. - View* view_; - - DISALLOW_COPY_AND_ASSIGN(RestoreFocusTask); -}; - ///////////////////////////////////////////////////////////////////////////// // // View - constructors, destructors, initialization @@ -77,14 +49,12 @@ View::View() focusable_(false), bounds_(0, 0, 0, 0), parent_(NULL), - should_restore_focus_(false), is_visible_(true), is_parent_owned_(true), notify_when_visible_bounds_in_root_changes_(false), registered_for_visible_bounds_notification_(false), next_focusable_view_(NULL), previous_focusable_view_(NULL), - restore_focus_view_task_(NULL), context_menu_controller_(NULL), #if defined(OS_WIN) accessibility_(NULL), @@ -95,9 +65,6 @@ View::View() } View::~View() { - if (restore_focus_view_task_) - restore_focus_view_task_->Cancel(); - int c = static_cast<int>(child_views_.size()); while (--c >= 0) { if (child_views_[c]->IsParentOwned()) @@ -423,23 +390,6 @@ void View::PaintNow() { view->PaintNow(); } -void View::PaintFloatingView(ChromeCanvas* canvas, View* view, - int x, int y, int w, int h) { - if (should_restore_focus_ && ShouldRestoreFloatingViewFocus()) { - // We are painting again a floating view, this is a good time to restore the - // focus to the last focused floating view if any. - should_restore_focus_ = false; - restore_focus_view_task_ = new RestoreFocusTask(this); - MessageLoop::current()->PostTask(FROM_HERE, restore_focus_view_task_); - } - View* saved_parent = view->GetParent(); - view->SetParent(this); - view->SetBounds(x, y, w, h); - view->Layout(); - view->ProcessPaint(canvas); - view->SetParent(saved_parent); -} - gfx::Insets View::GetInsets() const { gfx::Insets insets; if (border_.get()) @@ -521,22 +471,16 @@ void View::ProcessMouseReleased(const MouseEvent& e, bool canceled) { } void View::AddChildView(View* v) { - AddChildView(static_cast<int>(child_views_.size()), v, false); + AddChildView(static_cast<int>(child_views_.size()), v); } void View::AddChildView(int index, View* v) { - AddChildView(index, v, false); -} - -void View::AddChildView(int index, View* v, bool floating_view) { // Remove the view from its current parent if any. if (v->GetParent()) v->GetParent()->RemoveChildView(v); - if (!floating_view) { - // Sets the prev/next focus views. - InitFocusSiblings(v, index); - } + // Sets the prev/next focus views. + InitFocusSiblings(v, index); // Let's insert the view. child_views_.insert(child_views_.begin() + index, v); @@ -589,7 +533,7 @@ void View::DoRemoveChildView(View* a_view, child_views_.end(), a_view); if (i != child_views_.end()) { - if (update_focus_cycle && !a_view->IsFloatingView()) { + if (update_focus_cycle) { // Let's remove the view from the focus traversal. View* next_focusable = a_view->next_focusable_view_; View* prev_focusable = a_view->previous_focusable_view_; @@ -700,10 +644,6 @@ void View::PropagateVisibilityNotifications(View* start, bool is_visible) { void View::VisibilityChanged(View* starting_from, bool is_visible) { } -View* View::GetViewForPoint(const gfx::Point& point) { - return GetViewForPoint(point, true); -} - void View::SetNotifyWhenVisibleBoundsInRootChanges(bool value) { if (notify_when_visible_bounds_in_root_changes_ == value) return; @@ -721,8 +661,7 @@ bool View::GetNotifyWhenVisibleBoundsInRootChanges() { return notify_when_visible_bounds_in_root_changes_; } -View* View::GetViewForPoint(const gfx::Point& point, - bool can_create_floating) { +View* View::GetViewForPoint(const gfx::Point& point) { // Walk the child Views recursively looking for the View that most // tightly encloses the specified point. for (int i = GetChildViewCount() - 1 ; i >= 0 ; --i) { @@ -733,19 +672,7 @@ View* View::GetViewForPoint(const gfx::Point& point, gfx::Point point_in_child_coords(point); View::ConvertPointToView(this, child, &point_in_child_coords); if (child->HitTest(point_in_child_coords)) - return child->GetViewForPoint(point_in_child_coords, true); - } - - // We haven't found a view for the point. Try to create floating views - // and try again if one was created. - // can_create_floating makes sure we don't try forever even if - // GetFloatingViewIDForPoint lies or if RetrieveFloatingViewForID creates a - // view which doesn't contain the provided point - int id; - if (can_create_floating && - GetFloatingViewIDForPoint(point.x(), point.y(), &id)) { - RetrieveFloatingViewForID(id); // This creates the floating view. - return GetViewForPoint(point, false); + return child->GetViewForPoint(point_in_child_coords); } return this; } @@ -1056,44 +983,6 @@ void View::UnregisterAccelerators() { } } -///////////////////////////////////////////////////////////////////////////// -// -// View - floating views -// -///////////////////////////////////////////////////////////////////////////// - -bool View::IsFloatingView() { - if (!parent_) - return false; - - return parent_->floating_views_ids_.find(this) != - parent_->floating_views_ids_.end(); -} - -// default implementation does nothing -bool View::GetFloatingViewIDForPoint(int x, int y, int* id) { - return false; -} - -int View::GetFloatingViewCount() const { - return static_cast<int>(floating_views_.size()); -} - -View* View::RetrieveFloatingViewParent() { - View* v = this; - while (v) { - if (v->IsFloatingView()) - return v; - v = v->GetParent(); - } - return NULL; -} - -bool View::EnumerateFloatingViews(FloatingViewPosition position, - int starting_id, int* id) { - return false; -} - int View::GetDragOperations(int press_x, int press_y) { if (!drag_controller_) return DragDropTypes::DRAG_NONE; @@ -1113,158 +1002,6 @@ bool View::InDrag() { return root_view ? (root_view->GetDragView() == this) : false; } -View* View::ValidateFloatingViewForID(int id) { - return NULL; -} - -bool View::ShouldRestoreFloatingViewFocus() { - return true; -} - -void View::AttachFloatingView(View* v, int id) { - floating_views_.push_back(v); - floating_views_ids_[v] = id; - AddChildView(static_cast<int>(child_views_.size()), v, true); -} - -bool View::HasFloatingViewForPoint(int x, int y) { - int i, c; - View* v; - gfx::Rect r; - - for (i = 0, c = static_cast<int>(floating_views_.size()); i < c; ++i) { - v = floating_views_[i]; - r.SetRect(v->GetX(APPLY_MIRRORING_TRANSFORMATION), v->y(), - v->width(), v->height()); - if (r.Contains(x, y)) - return true; - } - return false; -} - -void View::DetachAllFloatingViews() { - RootView* root_view = GetRootView(); - View* focused_view = NULL; - FocusManager* focus_manager = NULL; - if (root_view) { - // We may be called when we are not attached to a root view in which case - // there is nothing to do for focus. - focus_manager = GetFocusManager(); - if (focus_manager) { - // We may not have a focus manager (if we are detached from a top window). - focused_view = focus_manager->GetFocusedView(); - } - } - - int c = static_cast<int>(floating_views_.size()); - while (--c >= 0) { - // If the focused view is a floating view or a floating view's children, - // use the focus manager to store it. - int tmp_id; - if (focused_view && - ((focused_view == floating_views_[c]) || - floating_views_[c]->IsParentOf(focused_view))) { - // We call EnumerateFloatingView to make sure the floating view is still - // valid: the model may have changed and could not know anything about - // that floating view anymore. - if (EnumerateFloatingViews(CURRENT, - floating_views_[c]->GetFloatingViewID(), - &tmp_id)) { - // TODO(port): Fix this once we have a FocusManger for Linux. -#if defined(OS_WIN) - focus_manager->StoreFocusedView(); -#endif - should_restore_focus_ = true; - } - focused_view = NULL; - } - - RemoveChildView(floating_views_[c]); - delete floating_views_[c]; - } - floating_views_.clear(); - floating_views_ids_.clear(); -} - -int View::GetFloatingViewID() { - DCHECK(IsFloatingView()); - std::map<View*, int>::iterator iter = parent_->floating_views_ids_.find(this); - DCHECK(iter != parent_->floating_views_ids_.end()); - return iter->second; -} - -View* View::RetrieveFloatingViewForID(int id) { - for (ViewList::const_iterator iter = floating_views_.begin(); - iter != floating_views_.end(); ++iter) { - if ((*iter)->GetFloatingViewID() == id) - return *iter; - } - return ValidateFloatingViewForID(id); -} - -void View::RestoreFloatingViewFocus() { - // Clear the reference to the task as if we have been triggered by it, it will - // soon be invalid. - restore_focus_view_task_ = NULL; - should_restore_focus_ = false; - - // TODO(port): Fix this once we have a FocusManger for Linux. -#if defined(OS_WIN) - FocusManager* focus_manager = GetFocusManager(); - DCHECK(focus_manager); - if (focus_manager) - focus_manager->RestoreFocusedView(); -#endif -} - -// static -bool View::EnumerateFloatingViewsForInterval(int low_bound, int high_bound, - bool ascending_order, - FloatingViewPosition position, - int starting_id, - int* id) { - DCHECK(low_bound <= high_bound); - if (low_bound >= high_bound) - return false; - - switch (position) { - case CURRENT: - if ((starting_id >= low_bound) && (starting_id < high_bound)) { - *id = starting_id; - return true; - } - return false; - case FIRST: - *id = ascending_order ? low_bound : high_bound - 1; - return true; - case LAST: - *id = ascending_order ? high_bound - 1 : low_bound; - return true; - case NEXT: - case PREVIOUS: - if (((position == NEXT) && ascending_order) || - ((position == PREVIOUS) && !ascending_order)) { - starting_id++; - if (starting_id < high_bound) { - *id = starting_id; - return true; - } - return false; - } - DCHECK(((position == NEXT) && !ascending_order) || - ((position == PREVIOUS) && ascending_order)); - starting_id--; - if (starting_id >= low_bound) { - *id = starting_id; - return true; - } - return false; - default: - NOTREACHED(); - } - return false; -} - // static void View::ConvertPointToView(const View* src, const View* dst, @@ -1616,31 +1353,6 @@ void View::RemoveDescendantToNotify(View* view) { descendants_to_notify_.reset(); } -// static -bool View::GetViewPath(View* start, View* end, std::vector<int>* path) { - while (end && (end != start)) { - View* parent = end->GetParent(); - if (!parent) - return false; - path->insert(path->begin(), parent->GetChildIndex(end)); - end = parent; - } - return end == start; -} - -// static -View* View::GetViewForPath(View* start, const std::vector<int>& path) { - View* v = start; - for (std::vector<int>::const_iterator iter = path.begin(); - iter != path.end(); ++iter) { - int index = *iter; - if (index >= v->GetChildViewCount()) - return NULL; - v = v->GetChildViewAt(index); - } - return v; -} - // DropInfo -------------------------------------------------------------------- void View::DragInfo::Reset() { diff --git a/views/view.h b/views/view.h index 561632d..ed4d4a0 100644 --- a/views/view.h +++ b/views/view.h @@ -116,17 +116,6 @@ class DragController { ///////////////////////////////////////////////////////////////////////////// class View : public AcceleratorTarget { public: - - // Used in EnumerateFloatingViews() to specify which floating view to - // retrieve. - enum FloatingViewPosition { - FIRST = 0, - NEXT, - PREVIOUS, - LAST, - CURRENT - }; - // Used in the versions of GetBounds() and x() that take a transformation // parameter in order to determine whether or not to take into account the // mirroring setting of the View when returning bounds positions. @@ -400,14 +389,6 @@ class View : public AcceleratorTarget { // Paint this View immediately. virtual void PaintNow(); - // Paint a view without attaching it to this view hierarchy. - // Any view can be painted that way. - // This method set bounds, calls layout and handles clipping properly. The - // provided view can be attached to a parent. The parent will be saved and - // restored. (x, y, width, height) define the floating view bounds - void PaintFloatingView(ChromeCanvas* canvas, View* view, - int x, int y, int w, int h); - // Tree functions // Add a child View. @@ -599,77 +580,6 @@ class View : public AcceleratorTarget { // accessibility focus. virtual View* GetAccFocusedChildView() { return NULL; } - // Floating views - // - // A floating view is a view that is used to paint a cell within a parent view - // Floating Views are painted using PaintFloatingView() above. - // - // Floating views can also be lazily created and attached to the view - // hierarchy to process events. To make this possible, each view is given an - // opportunity to create and attach a floating view right before an mouse - // event is processed. - - // Retrieves the id for the floating view at the specified coordinates if any. - // Derived classes that use floating views should implement this method and - // return true if a view has been found and its id set in |id|. - virtual bool GetFloatingViewIDForPoint(int x, int y, int* id); - - // Retrieves the ID of the floating view at the specified |position| and sets - // it in |id|. - // For positions NEXT and PREVIOUS, the specified |starting_id| is used as - // the origin, it is ignored for FIRST and LAST. - // Returns true if an ID was found, false otherwise. - // For CURRENT, the |starting_id| should be set in |id| and true returned if - // the |starting_id| is a valid floating view id. - // Derived classes that use floating views should implement this method and - // return a unique ID for each floating view. - // The default implementation always returns false. - virtual bool EnumerateFloatingViews(FloatingViewPosition position, - int starting_id, - int* id); - - // Creates and attaches the floating view with the specified |id| to this view - // hierarchy and returns it. - // Derived classes that use floating views should implement this method. - // - // NOTE: subclasses implementing this should return NULL if passed an invalid - // id. An invalid ID may be passed in by the focus manager when attempting - // to restore focus. - virtual View* ValidateFloatingViewForID(int id); - - // Whether the focus should automatically be restored to the last focused - // view. Default implementation returns true. - // Derived classes that want to restore focus themselves should override this - // method and return false. - virtual bool ShouldRestoreFloatingViewFocus(); - - // Attach a floating view to the receiving view. The view is inserted - // in the child view list and will behave like a normal view. |id| is the - // floating view id for that view. - void AttachFloatingView(View* v, int id); - - // Return whether a view already has a floating view which bounds intersects - // the provided point. - // - // If the View uses right-to-left UI layout, then the given point is checked - // against the mirrored position of each floating View. - bool HasFloatingViewForPoint(int x, int y); - - // Detach and delete all floating views. Call this method when your model - // or layout changes. - void DetachAllFloatingViews(); - - // Returns the view with the specified |id|, by calling - // ValidateFloatingViewForID if that view has not yet been attached. - virtual View* RetrieveFloatingViewForID(int id); - - // Restores the focus to the previously selected floating view. - virtual void RestoreFloatingViewFocus(); - - // Goes up the parent hierarchy of this view and returns the first floating - // view found. Returns NULL if none were found. - View* RetrieveFloatingViewParent(); - // Utility functions // Note that the utility coordinate conversions functions always operate on @@ -1070,10 +980,6 @@ class View : public AcceleratorTarget { // Views must invoke this when the tooltip text they are to display changes. void TooltipTextChanged(); - // Actual implementation of GetViewForPoint. - virtual View* GetViewForPoint(const gfx::Point& point, - bool can_create_floating); - // Sets whether this view wants notification when its visible bounds relative // to the root view changes. If true, this view is notified any time the // origin of one its ancestors changes, or the portion of the bounds not @@ -1103,18 +1009,6 @@ class View : public AcceleratorTarget { // event. virtual bool ShouldLookupAccelerators(const KeyEvent& e) { return true; } - // A convenience method for derived classes which have floating views with IDs - // that are consecutive numbers in an interval [|low_bound|, |high_bound|[. - // They can call this method in their EnumerateFloatingViews implementation. - // If |ascending_order| is true, the first id is |low_bound|, the next after - // id n is n + 1, and so on. If |ascending_order| is false, the order is - // reversed, first id is |high_bound|, the next id after id n is n -1... - static bool EnumerateFloatingViewsForInterval(int low_bound, int high_bound, - bool ascending_order, - FloatingViewPosition position, - int starting_id, - int* id); - // These are cover methods that invoke the method of the same name on // the DragController. Subclasses may wish to override rather than install // a DragController. @@ -1178,10 +1072,6 @@ class View : public AcceleratorTarget { // supported drag operations. When done, OnDragDone is invoked. void DoDrag(const MouseEvent& e, int press_x, int press_y); - // Adds a child View at the specified position. |floating_view| should be true - // if the |v| is a floating view. - void AddChildView(int index, View* v, bool floating_view); - // Removes |view| from the hierarchy tree. If |update_focus_cycle| is true, // the next and previous focusable views of views pointing to this view are // updated. If |update_tool_tip| is true, the tooltip is updated. If @@ -1253,26 +1143,6 @@ class View : public AcceleratorTarget { void RegisterAccelerators(); void UnregisterAccelerators(); - // Returns the number of children that are actually attached floating views. - int GetFloatingViewCount() const; - - // Returns the id for this floating view. - int GetFloatingViewID(); - - // Returns whether this view is a floating view. - bool IsFloatingView(); - - // Sets in |path| the path in the view hierarchy from |start| to |end| (the - // path is the list of indexes in each view's children to get from |start| - // to |end|). - // Returns true if |start| and |view| are connected and the |path| has been - // retrieved succesfully, false otherwise. - static bool GetViewPath(View* start, View* end, std::vector<int>* path); - - // Returns the view at the end of the specified |path|, starting at the - // |start| view. - static View* GetViewForPath(View* start, const std::vector<int>& path); - // This View's bounds in the parent coordinate system. gfx::Rect bounds_; @@ -1283,18 +1153,6 @@ class View : public AcceleratorTarget { typedef std::vector<View*> ViewList; ViewList child_views_; - // List of floating children. A floating view is always referenced by - // child_views_ and will be deleted on destruction just like any other - // child view. - ViewList floating_views_; - - // Maps a floating view to its floating view id. - std::map<View*, int> floating_views_ids_; - - // Whether we want the focus to be restored. This is used to store/restore - // focus for floating views. - bool should_restore_focus_; - // The View's LayoutManager defines the sizing heuristics applied to child // Views. The default is absolute positioning according to bounds_. scoped_ptr<LayoutManager> layout_manager_; @@ -1330,10 +1188,6 @@ class View : public AcceleratorTarget { // The list of accelerators. scoped_ptr<std::vector<Accelerator> > accelerators_; - // The task used to restore automatically the focus to the last focused - // floating view. - RestoreFocusTask* restore_focus_view_task_; - // The menu controller. ContextMenuController* context_menu_controller_; diff --git a/views/widget/root_view.cc b/views/widget/root_view.cc index fd9f1c0..bc012c8 100644 --- a/views/widget/root_view.cc +++ b/views/widget/root_view.cc @@ -657,56 +657,19 @@ View* RootView::FindNextFocusableViewImpl(View* starting_view, // First let's try the left child. if (can_go_down) { - View* v = NULL; if (starting_view->GetChildViewCount() > 0) { - // We are only interested in non floating-views, as attached floating - // views order is variable (depending on mouse moves). - for (int i = 0; i < starting_view->GetChildViewCount(); i++) { - View* child = starting_view->GetChildViewAt(i); - if (!child->IsFloatingView()) { - v = FindNextFocusableViewImpl(child, false, false, true, - skip_group_id); - break; - } - } - } - if (v == NULL) { - // Try the floating views. - int id = 0; - if (starting_view->EnumerateFloatingViews(View::FIRST, 0, &id)) { - View* child = starting_view->RetrieveFloatingViewForID(id); - DCHECK(child); - v = FindNextFocusableViewImpl(child, false, false, true, skip_group_id); - } + View* v = FindNextFocusableViewImpl(starting_view->GetChildViewAt(0), + false, false, true, skip_group_id); + if (v) + return v; } - if (v) - return v; } // Then try the right sibling. - View* sibling = NULL; - if (starting_view->IsFloatingView()) { - int id = 0; - if (starting_view->GetParent()->EnumerateFloatingViews( - View::NEXT, starting_view->GetFloatingViewID(), &id)) { - sibling = starting_view->GetParent()->RetrieveFloatingViewForID(id); - DCHECK(sibling); - } - } else { - sibling = starting_view->GetNextFocusableView(); - if (!sibling) { - // Let's try floating views. - int id = 0; - if (starting_view->GetParent()->EnumerateFloatingViews(View::FIRST, - 0, &id)) { - sibling = starting_view->GetParent()->RetrieveFloatingViewForID(id); - DCHECK(sibling); - } - } - } + View* sibling = starting_view->GetNextFocusableView(); if (sibling) { - View* v = - FindNextFocusableViewImpl(sibling, false, false, true, skip_group_id); + View* v = FindNextFocusableViewImpl(sibling, + false, false, true, skip_group_id); if (v) return v; } @@ -715,15 +678,7 @@ View* RootView::FindNextFocusableViewImpl(View* starting_view, if (can_go_up) { View* parent = starting_view->GetParent(); while (parent) { - int id = 0; - if (parent->IsFloatingView() && - parent->GetParent()->EnumerateFloatingViews( - View::NEXT, parent->GetFloatingViewID(), &id)) { - sibling = parent->GetParent()->RetrieveFloatingViewForID(id); - DCHECK(sibling); - } else { - sibling = parent->GetNextFocusableView(); - } + sibling = parent->GetNextFocusableView(); if (sibling) { return FindNextFocusableViewImpl(sibling, false, true, true, @@ -750,24 +705,14 @@ View* RootView::FindPreviousFocusableViewImpl(View* starting_view, int skip_group_id) { // Let's go down and right as much as we can. if (can_go_down) { - View* v = NULL; - if (starting_view->GetChildViewCount() - - starting_view->GetFloatingViewCount() > 0) { + if (starting_view->GetChildViewCount() > 0) { View* view = starting_view->GetChildViewAt(starting_view->GetChildViewCount() - 1); - v = FindPreviousFocusableViewImpl(view, false, false, true, - skip_group_id); - } else { - // Let's try floating views. - int id = 0; - if (starting_view->EnumerateFloatingViews(View::LAST, 0, &id)) { - View* child = starting_view->RetrieveFloatingViewForID(id); - DCHECK(child); - v = FindNextFocusableViewImpl(child, false, false, true, skip_group_id); - } + View* v = FindPreviousFocusableViewImpl(view, false, false, true, + skip_group_id); + if (v) + return v; } - if (v) - return v; } if (!skip_starting_view) { @@ -778,28 +723,7 @@ View* RootView::FindPreviousFocusableViewImpl(View* starting_view, } // Then try the left sibling. - View* sibling = NULL; - if (starting_view->IsFloatingView()) { - int id = 0; - if (starting_view->GetParent()->EnumerateFloatingViews( - View::PREVIOUS, starting_view->GetFloatingViewID(), &id)) { - sibling = starting_view->GetParent()->RetrieveFloatingViewForID(id); - DCHECK(sibling); - } - if (!sibling) { - // No more floating views, try regular views, starting at the last one. - View* parent = starting_view->GetParent(); - for (int i = parent->GetChildViewCount() - 1; i >= 0; i--) { - View* v = parent->GetChildViewAt(i); - if (!v->IsFloatingView()) { - sibling = v; - break; - } - } - } - } else { - sibling = starting_view->GetPreviousFocusableView(); - } + View* sibling = starting_view->GetPreviousFocusableView(); if (sibling) { return FindPreviousFocusableViewImpl(sibling, false, true, true, diff --git a/views/window/non_client_view.cc b/views/window/non_client_view.cc index 7028733..923f85e 100644 --- a/views/window/non_client_view.cc +++ b/views/window/non_client_view.cc @@ -176,11 +176,6 @@ void NonClientView::ViewHierarchyChanged(bool is_add, View* parent, } views::View* NonClientView::GetViewForPoint(const gfx::Point& point) { - return GetViewForPoint(point, false); -} - -views::View* NonClientView::GetViewForPoint(const gfx::Point& point, - bool can_create_floating) { // Because of the z-ordering of our child views (the client view is positioned // over the non-client frame view, if the client view ever overlaps the frame // view visually (as it does for the browser window), then it will eat mouse @@ -193,7 +188,7 @@ views::View* NonClientView::GetViewForPoint(const gfx::Point& point, if (frame_view_->HitTest(point_in_child_coords)) return frame_view_->GetViewForPoint(point); - return View::GetViewForPoint(point, can_create_floating); + return View::GetViewForPoint(point); } //////////////////////////////////////////////////////////////////////////////// diff --git a/views/window/non_client_view.h b/views/window/non_client_view.h index d93f423..847f604 100644 --- a/views/window/non_client_view.h +++ b/views/window/non_client_view.h @@ -199,8 +199,6 @@ class NonClientView : public View { // NonClientView, View overrides: virtual void ViewHierarchyChanged(bool is_add, View* parent, View* child); virtual views::View* GetViewForPoint(const gfx::Point& point); - virtual views::View* GetViewForPoint(const gfx::Point& point, - bool can_create_floating); private: // The frame that hosts this NonClientView. |