Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(133)

Side by Side Diff: ui/views/view.cc

Issue 8964001: views: Convert IsFocusable() to just focusable() since it's just a simple accessor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: don't need to override IsFocusableInRootView in omnibox_view_views Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/views/view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "ui/views/view.h" 5 #include "ui/views/view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 877 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 View* View::GetPreviousFocusableView() { 888 View* View::GetPreviousFocusableView() {
889 return previous_focusable_view_; 889 return previous_focusable_view_;
890 } 890 }
891 891
892 void View::SetNextFocusableView(View* view) { 892 void View::SetNextFocusableView(View* view) {
893 view->previous_focusable_view_ = this; 893 view->previous_focusable_view_ = this;
894 next_focusable_view_ = view; 894 next_focusable_view_ = view;
895 } 895 }
896 896
897 bool View::IsFocusableInRootView() const { 897 bool View::IsFocusableInRootView() const {
898 return IsFocusable() && IsDrawn(); 898 return focusable_ && enabled_ && IsDrawn();
899 } 899 }
900 900
901 bool View::IsAccessibilityFocusableInRootView() const { 901 bool View::IsAccessibilityFocusableInRootView() const {
902 return (focusable_ || accessibility_focusable_) && enabled_ && IsDrawn(); 902 return (focusable_ || accessibility_focusable_) && enabled_ && IsDrawn();
903 } 903 }
904 904
905 FocusManager* View::GetFocusManager() { 905 FocusManager* View::GetFocusManager() {
906 Widget* widget = GetWidget(); 906 Widget* widget = GetWidget();
907 return widget ? widget->GetFocusManager() : NULL; 907 return widget ? widget->GetFocusManager() : NULL;
908 } 908 }
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
1086 void View::OnPaintBorder(gfx::Canvas* canvas) { 1086 void View::OnPaintBorder(gfx::Canvas* canvas) {
1087 if (border_.get()) { 1087 if (border_.get()) {
1088 TRACE_EVENT2("views", "View::OnPaintBorder", 1088 TRACE_EVENT2("views", "View::OnPaintBorder",
1089 "width", canvas->GetSkCanvas()->getDevice()->width(), 1089 "width", canvas->GetSkCanvas()->getDevice()->width(),
1090 "height", canvas->GetSkCanvas()->getDevice()->height()); 1090 "height", canvas->GetSkCanvas()->getDevice()->height());
1091 border_->Paint(*this, canvas); 1091 border_->Paint(*this, canvas);
1092 } 1092 }
1093 } 1093 }
1094 1094
1095 void View::OnPaintFocusBorder(gfx::Canvas* canvas) { 1095 void View::OnPaintFocusBorder(gfx::Canvas* canvas) {
1096 if ((IsFocusable() || IsAccessibilityFocusableInRootView()) && HasFocus()) { 1096 if ((focusable() || IsAccessibilityFocusableInRootView()) && HasFocus()) {
1097 TRACE_EVENT2("views", "views::OnPaintFocusBorder", 1097 TRACE_EVENT2("views", "views::OnPaintFocusBorder",
1098 "width", canvas->GetSkCanvas()->getDevice()->width(), 1098 "width", canvas->GetSkCanvas()->getDevice()->width(),
1099 "height", canvas->GetSkCanvas()->getDevice()->height()); 1099 "height", canvas->GetSkCanvas()->getDevice()->height());
1100 canvas->DrawFocusRect(GetLocalBounds()); 1100 canvas->DrawFocusRect(GetLocalBounds());
1101 } 1101 }
1102 } 1102 }
1103 1103
1104 // Accelerated Painting -------------------------------------------------------- 1104 // Accelerated Painting --------------------------------------------------------
1105 1105
1106 void View::SetFillsBoundsOpaquely(bool fills_bounds_opaquely) { 1106 void View::SetFillsBoundsOpaquely(bool fills_bounds_opaquely) {
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1222 bool View::HasHitTestMask() const { 1222 bool View::HasHitTestMask() const {
1223 return false; 1223 return false;
1224 } 1224 }
1225 1225
1226 void View::GetHitTestMask(gfx::Path* mask) const { 1226 void View::GetHitTestMask(gfx::Path* mask) const {
1227 DCHECK(mask); 1227 DCHECK(mask);
1228 } 1228 }
1229 1229
1230 // Focus ----------------------------------------------------------------------- 1230 // Focus -----------------------------------------------------------------------
1231 1231
1232 bool View::IsFocusable() const {
1233 return focusable_ && enabled_ && visible_;
1234 }
1235
1236 void View::OnFocus() { 1232 void View::OnFocus() {
1237 // TODO(beng): Investigate whether it's possible for us to move this to 1233 // TODO(beng): Investigate whether it's possible for us to move this to
1238 // Focus(). 1234 // Focus().
1239 // By default, we clear the native focus. This ensures that no visible native 1235 // By default, we clear the native focus. This ensures that no visible native
1240 // view as the focus and that we still receive keyboard inputs. 1236 // view as the focus and that we still receive keyboard inputs.
1241 FocusManager* focus_manager = GetFocusManager(); 1237 FocusManager* focus_manager = GetFocusManager();
1242 if (focus_manager) 1238 if (focus_manager)
1243 focus_manager->ClearNativeFocus(); 1239 focus_manager->ClearNativeFocus();
1244 1240
1245 // TODO(beng): Investigate whether it's possible for us to move this to 1241 // TODO(beng): Investigate whether it's possible for us to move this to
(...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after
2042 2038
2043 OSExchangeData data; 2039 OSExchangeData data;
2044 WriteDragData(press_pt, &data); 2040 WriteDragData(press_pt, &data);
2045 2041
2046 // Message the RootView to do the drag and drop. That way if we're removed 2042 // Message the RootView to do the drag and drop. That way if we're removed
2047 // the RootView can detect it and avoid calling us back. 2043 // the RootView can detect it and avoid calling us back.
2048 GetWidget()->RunShellDrag(this, data, drag_operations); 2044 GetWidget()->RunShellDrag(this, data, drag_operations);
2049 } 2045 }
2050 2046
2051 } // namespace views 2047 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698