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

Side by Side Diff: views/view.cc

Issue 6622002: Do all OOLing in the views code. linux_views now builds clean with the clang plugin. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 9 months 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
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 "views/view.h" 5 #include "views/view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 30 matching lines...) Expand all
41 char View::kViewClassName[] = "views/View"; 41 char View::kViewClassName[] = "views/View";
42 42
43 //////////////////////////////////////////////////////////////////////////////// 43 ////////////////////////////////////////////////////////////////////////////////
44 // View, public: 44 // View, public:
45 45
46 // TO BE MOVED ----------------------------------------------------------------- 46 // TO BE MOVED -----------------------------------------------------------------
47 47
48 void View::SetHotTracked(bool flag) { 48 void View::SetHotTracked(bool flag) {
49 } 49 }
50 50
51 bool View::IsHotTracked() const {
52 return false;
53 }
54
55 // FATE TBD --------------------------------------------------------------------
56
57 Widget* View::child_widget() {
58 return NULL;
59 }
51 60
52 // Creation and lifetime ------------------------------------------------------- 61 // Creation and lifetime -------------------------------------------------------
53 62
54 View::View() 63 View::View()
55 : enabled_(true), 64 : enabled_(true),
56 id_(0), 65 id_(0),
57 group_(-1), 66 group_(-1),
58 focusable_(false), 67 focusable_(false),
59 accessibility_focusable_(false), 68 accessibility_focusable_(false),
60 is_parent_owned_(true), 69 is_parent_owned_(true),
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 342
334 // This notifies all sub-views recursively. 343 // This notifies all sub-views recursively.
335 PropagateVisibilityNotifications(this, flag); 344 PropagateVisibilityNotifications(this, flag);
336 345
337 // If we are newly visible, schedule paint. 346 // If we are newly visible, schedule paint.
338 if (IsVisible()) 347 if (IsVisible())
339 SchedulePaint(); 348 SchedulePaint();
340 } 349 }
341 } 350 }
342 351
352 bool View::IsVisible() const {
353 return is_visible_;
354 }
355
343 bool View::IsVisibleInRootView() const { 356 bool View::IsVisibleInRootView() const {
344 return IsVisible() && parent() ? parent()->IsVisibleInRootView() : false; 357 return IsVisible() && parent() ? parent()->IsVisibleInRootView() : false;
345 } 358 }
346 359
347 void View::SetEnabled(bool state) { 360 void View::SetEnabled(bool state) {
348 if (enabled_ != state) { 361 if (enabled_ != state) {
349 enabled_ = state; 362 enabled_ = state;
350 SchedulePaint(); 363 SchedulePaint();
351 } 364 }
352 } 365 }
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 void View::SetGroup(int gid) { 550 void View::SetGroup(int gid) {
538 // Don't change the group id once it's set. 551 // Don't change the group id once it's set.
539 DCHECK(group_ == -1 || group_ == gid); 552 DCHECK(group_ == -1 || group_ == gid);
540 group_ = gid; 553 group_ = gid;
541 } 554 }
542 555
543 int View::GetGroup() const { 556 int View::GetGroup() const {
544 return group_; 557 return group_;
545 } 558 }
546 559
560 bool View::IsGroupFocusTraversable() const {
561 return true;
562 }
563
547 void View::GetViewsWithGroup(int group_id, std::vector<View*>* out) { 564 void View::GetViewsWithGroup(int group_id, std::vector<View*>* out) {
548 if (group_ == group_id) 565 if (group_ == group_id)
549 out->push_back(this); 566 out->push_back(this);
550 567
551 for (int i = 0, count = child_count(); i < count; ++i) 568 for (int i = 0, count = child_count(); i < count; ++i)
552 GetChildViewAt(i)->GetViewsWithGroup(group_id, out); 569 GetChildViewAt(i)->GetViewsWithGroup(group_id, out);
553 } 570 }
554 571
555 View* View::GetSelectedViewForGroup(int group_id) { 572 View* View::GetSelectedViewForGroup(int group_id) {
556 std::vector<View*> views; 573 std::vector<View*> views;
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 // we should de-register from that focus manager now. 874 // we should de-register from that focus manager now.
858 if (GetWidget() && accelerator_focus_manager_) 875 if (GetWidget() && accelerator_focus_manager_)
859 accelerator_focus_manager_->UnregisterAccelerator(accelerator, this); 876 accelerator_focus_manager_->UnregisterAccelerator(accelerator, this);
860 } 877 }
861 878
862 void View::ResetAccelerators() { 879 void View::ResetAccelerators() {
863 if (accelerators_.get()) 880 if (accelerators_.get())
864 UnregisterAccelerators(false); 881 UnregisterAccelerators(false);
865 } 882 }
866 883
884 bool View::AcceleratorPressed(const Accelerator& accelerator) {
885 return false;
886 }
887
867 // Focus ----------------------------------------------------------------------- 888 // Focus -----------------------------------------------------------------------
868 889
869 bool View::HasFocus() { 890 bool View::HasFocus() {
870 FocusManager* focus_manager = GetFocusManager(); 891 FocusManager* focus_manager = GetFocusManager();
871 if (focus_manager) 892 if (focus_manager)
872 return focus_manager->GetFocusedView() == this; 893 return focus_manager->GetFocusedView() == this;
873 return false; 894 return false;
874 } 895 }
875 896
876 View* View::GetNextFocusableView() { 897 View* View::GetNextFocusableView() {
(...skipping 19 matching lines...) Expand all
896 917
897 bool View::IsFocusableInRootView() const { 918 bool View::IsFocusableInRootView() const {
898 return IsFocusable() && IsVisibleInRootView(); 919 return IsFocusable() && IsVisibleInRootView();
899 } 920 }
900 921
901 bool View::IsAccessibilityFocusableInRootView() const { 922 bool View::IsAccessibilityFocusableInRootView() const {
902 return (focusable_ || accessibility_focusable_) && IsEnabled() && 923 return (focusable_ || accessibility_focusable_) && IsEnabled() &&
903 IsVisibleInRootView(); 924 IsVisibleInRootView();
904 } 925 }
905 926
927 void View::set_accessibility_focusable(bool accessibility_focusable) {
928 accessibility_focusable_ = accessibility_focusable;
929 }
930
906 FocusManager* View::GetFocusManager() { 931 FocusManager* View::GetFocusManager() {
907 Widget* widget = GetWidget(); 932 Widget* widget = GetWidget();
908 return widget ? widget->GetFocusManager() : NULL; 933 return widget ? widget->GetFocusManager() : NULL;
909 } 934 }
910 935
911 void View::RequestFocus() { 936 void View::RequestFocus() {
912 FocusManager* focus_manager = GetFocusManager(); 937 FocusManager* focus_manager = GetFocusManager();
913 if (focus_manager && IsFocusableInRootView()) 938 if (focus_manager && IsFocusableInRootView())
914 focus_manager->SetFocusedView(this); 939 focus_manager->SetFocusedView(this);
915 } 940 }
916 941
942 bool View::SkipDefaultKeyEventProcessing(const KeyEvent& e) {
943 return false;
944 }
945
946 FocusTraversable* View::GetFocusTraversable() {
947 return NULL;
948 }
949
950 FocusTraversable* View::GetPaneFocusTraversable() {
951 return NULL;
952 }
953
917 // Tooltips -------------------------------------------------------------------- 954 // Tooltips --------------------------------------------------------------------
918 955
919 bool View::GetTooltipText(const gfx::Point& p, std::wstring* tooltip) { 956 bool View::GetTooltipText(const gfx::Point& p, std::wstring* tooltip) {
920 return false; 957 return false;
921 } 958 }
922 959
923 bool View::GetTooltipTextOrigin(const gfx::Point& p, gfx::Point* loc) { 960 bool View::GetTooltipTextOrigin(const gfx::Point& p, gfx::Point* loc) {
924 return false; 961 return false;
925 } 962 }
926 963
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
984 return (abs(delta_x) > GetHorizontalDragThreshold() || 1021 return (abs(delta_x) > GetHorizontalDragThreshold() ||
985 abs(delta_y) > GetVerticalDragThreshold()); 1022 abs(delta_y) > GetVerticalDragThreshold());
986 } 1023 }
987 1024
988 // Accessibility --------------------------------------------------------------- 1025 // Accessibility ---------------------------------------------------------------
989 1026
990 void View::NotifyAccessibilityEvent(AccessibilityTypes::Event event_type) { 1027 void View::NotifyAccessibilityEvent(AccessibilityTypes::Event event_type) {
991 NotifyAccessibilityEvent(event_type, true); 1028 NotifyAccessibilityEvent(event_type, true);
992 } 1029 }
993 1030
1031 string16 View::GetAccessibleDefaultAction() {
1032 return string16();
1033 }
1034
1035 string16 View::GetAccessibleKeyboardShortcut() {
1036 return string16();
1037 }
1038
994 bool View::GetAccessibleName(string16* name) { 1039 bool View::GetAccessibleName(string16* name) {
995 DCHECK(name); 1040 DCHECK(name);
996 1041
997 if (accessible_name_.empty()) 1042 if (accessible_name_.empty())
998 return false; 1043 return false;
999 *name = accessible_name_; 1044 *name = accessible_name_;
1000 return true; 1045 return true;
1001 } 1046 }
1002 1047
1003 AccessibilityTypes::Role View::GetAccessibleRole() { 1048 AccessibilityTypes::Role View::GetAccessibleRole() {
1004 return AccessibilityTypes::ROLE_CLIENT; 1049 return AccessibilityTypes::ROLE_CLIENT;
1005 } 1050 }
1006 1051
1052 AccessibilityTypes::State View::GetAccessibleState() {
1053 return 0;
1054 }
1055
1056 string16 View::GetAccessibleValue() {
1057 return string16();
1058 }
1059
1007 void View::SetAccessibleName(const string16& name) { 1060 void View::SetAccessibleName(const string16& name) {
1008 accessible_name_ = name; 1061 accessible_name_ = name;
1009 } 1062 }
1010 1063
1011 // Scrolling ------------------------------------------------------------------- 1064 // Scrolling -------------------------------------------------------------------
1012 1065
1013 void View::ScrollRectToVisible(const gfx::Rect& rect) { 1066 void View::ScrollRectToVisible(const gfx::Rect& rect) {
1014 // We must take RTL UI mirroring into account when adjusting the position of 1067 // We must take RTL UI mirroring into account when adjusting the position of
1015 // the region. 1068 // the region.
1016 if (parent()) { 1069 if (parent()) {
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after
1621 1674
1622 OSExchangeData data; 1675 OSExchangeData data;
1623 WriteDragData(press_pt, &data); 1676 WriteDragData(press_pt, &data);
1624 1677
1625 // Message the RootView to do the drag and drop. That way if we're removed 1678 // Message the RootView to do the drag and drop. That way if we're removed
1626 // the RootView can detect it and avoid calling us back. 1679 // the RootView can detect it and avoid calling us back.
1627 GetWidget()->RunShellDrag(this, data, drag_operations); 1680 GetWidget()->RunShellDrag(this, data, drag_operations);
1628 } 1681 }
1629 1682
1630 } // namespace views 1683 } // namespace views
OLDNEW
« views/controls/menu/menu_host_gtk.h ('K') | « views/view.h ('k') | views/views.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698