| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "views/controls/menu/menu_controller.h" | 5 #include "views/controls/menu/menu_controller.h" |
| 6 | 6 |
| 7 #include "base/i18n/case_conversion.h" | 7 #include "base/i18n/case_conversion.h" |
| 8 #include "base/i18n/rtl.h" | 8 #include "base/i18n/rtl.h" |
| 9 #include "base/time.h" | 9 #include "base/time.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 | 75 |
| 76 // Returns the first descendant of |view| that is hot tracked. | 76 // Returns the first descendant of |view| that is hot tracked. |
| 77 static View* GetFirstHotTrackedView(View* view) { | 77 static View* GetFirstHotTrackedView(View* view) { |
| 78 if (!view) | 78 if (!view) |
| 79 return NULL; | 79 return NULL; |
| 80 | 80 |
| 81 if (view->IsHotTracked()) | 81 if (view->IsHotTracked()) |
| 82 return view; | 82 return view; |
| 83 | 83 |
| 84 for (int i = 0; i < view->child_count(); ++i) { | 84 for (int i = 0; i < view->child_count(); ++i) { |
| 85 View* hot_view = GetFirstHotTrackedView(view->GetChildViewAt(i)); | 85 View* hot_view = GetFirstHotTrackedView(view->child_at(i)); |
| 86 if (hot_view) | 86 if (hot_view) |
| 87 return hot_view; | 87 return hot_view; |
| 88 } | 88 } |
| 89 return NULL; | 89 return NULL; |
| 90 } | 90 } |
| 91 | 91 |
| 92 // Recurses through the child views of |view| returning the first view starting | 92 // Recurses through the child views of |view| returning the first view starting |
| 93 // at |start| that is focusable. A value of -1 for |start| indicates to start at | 93 // at |start| that is focusable. A value of -1 for |start| indicates to start at |
| 94 // the first view (if |forward| is false, iterating starts at the last view). If | 94 // the first view (if |forward| is false, iterating starts at the last view). If |
| 95 // |forward| is true the children are considered first to last, otherwise last | 95 // |forward| is true the children are considered first to last, otherwise last |
| 96 // to first. | 96 // to first. |
| 97 static View* GetFirstFocusableView(View* view, int start, bool forward) { | 97 static View* GetFirstFocusableView(View* view, int start, bool forward) { |
| 98 if (forward) { | 98 if (forward) { |
| 99 for (int i = start == -1 ? 0 : start; i < view->child_count(); ++i) { | 99 for (int i = start == -1 ? 0 : start; i < view->child_count(); ++i) { |
| 100 View* deepest = GetFirstFocusableView(view->GetChildViewAt(i), -1, | 100 View* deepest = GetFirstFocusableView(view->child_at(i), -1, forward); |
| 101 forward); | |
| 102 if (deepest) | 101 if (deepest) |
| 103 return deepest; | 102 return deepest; |
| 104 } | 103 } |
| 105 } else { | 104 } else { |
| 106 for (int i = start == -1 ? view->child_count() - 1 : start; i >= 0; --i) { | 105 for (int i = start == -1 ? view->child_count() - 1 : start; i >= 0; --i) { |
| 107 View* deepest = GetFirstFocusableView(view->GetChildViewAt(i), -1, | 106 View* deepest = GetFirstFocusableView(view->child_at(i), -1, forward); |
| 108 forward); | |
| 109 if (deepest) | 107 if (deepest) |
| 110 return deepest; | 108 return deepest; |
| 111 } | 109 } |
| 112 } | 110 } |
| 113 return view->IsFocusableInRootView() ? view : NULL; | 111 return view->IsFocusableInRootView() ? view : NULL; |
| 114 } | 112 } |
| 115 | 113 |
| 116 // Returns the first child of |start| that is focusable. | 114 // Returns the first child of |start| that is focusable. |
| 117 static View* GetInitialFocusableView(View* start, bool forward) { | 115 static View* GetInitialFocusableView(View* start, bool forward) { |
| 118 return GetFirstFocusableView(start, -1, forward); | 116 return GetFirstFocusableView(start, -1, forward); |
| (...skipping 1776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1895 return; | 1893 return; |
| 1896 | 1894 |
| 1897 // Reset the active_mouse_view_ before sending mouse capture lost. That way if | 1895 // Reset the active_mouse_view_ before sending mouse capture lost. That way if |
| 1898 // it calls back to us, we aren't in a weird state. | 1896 // it calls back to us, we aren't in a weird state. |
| 1899 View* active_view = active_mouse_view_; | 1897 View* active_view = active_mouse_view_; |
| 1900 active_mouse_view_ = NULL; | 1898 active_mouse_view_ = NULL; |
| 1901 active_view->OnMouseCaptureLost(); | 1899 active_view->OnMouseCaptureLost(); |
| 1902 } | 1900 } |
| 1903 | 1901 |
| 1904 } // namespace views | 1902 } // namespace views |
| OLD | NEW |