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

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

Issue 1868363002: Replace scoped_ptr with std::unique_ptr in //ui (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@scopedptrcc
Patch Set: scopedptrui: rebase-make_scoped_ptr Created 4 years, 8 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
« no previous file with comments | « ui/views/view.h ('k') | ui/views/view_targeter_unittest.cc » ('j') | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #define _USE_MATH_DEFINES // For VC++ to get M_PI. This has to be first. 5 #define _USE_MATH_DEFINES // For VC++ to get M_PI. This has to be first.
6 6
7 #include "ui/views/view.h" 7 #include "ui/views/view.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
11 #include <memory>
11 #include <utility> 12 #include <utility>
12 13
13 #include "base/logging.h" 14 #include "base/logging.h"
14 #include "base/macros.h" 15 #include "base/macros.h"
15 #include "base/memory/scoped_ptr.h" 16 #include "base/memory/ptr_util.h"
16 #include "base/message_loop/message_loop.h" 17 #include "base/message_loop/message_loop.h"
17 #include "base/stl_util.h" 18 #include "base/stl_util.h"
18 #include "base/strings/stringprintf.h" 19 #include "base/strings/stringprintf.h"
19 #include "base/strings/utf_string_conversions.h" 20 #include "base/strings/utf_string_conversions.h"
20 #include "base/trace_event/trace_event.h" 21 #include "base/trace_event/trace_event.h"
21 #include "build/build_config.h" 22 #include "build/build_config.h"
22 #include "third_party/skia/include/core/SkRect.h" 23 #include "third_party/skia/include/core/SkRect.h"
23 #include "ui/accessibility/ax_enums.h" 24 #include "ui/accessibility/ax_enums.h"
24 #include "ui/base/cursor/cursor.h" 25 #include "ui/base/cursor/cursor.h"
25 #include "ui/base/dragdrop/drag_drop_types.h" 26 #include "ui/base/dragdrop/drag_drop_types.h"
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 return; 473 return;
473 474
474 paint_to_layer_ = paint_to_layer; 475 paint_to_layer_ = paint_to_layer;
475 if (paint_to_layer_ && !layer()) { 476 if (paint_to_layer_ && !layer()) {
476 CreateLayer(); 477 CreateLayer();
477 } else if (!paint_to_layer_ && layer()) { 478 } else if (!paint_to_layer_ && layer()) {
478 DestroyLayer(); 479 DestroyLayer();
479 } 480 }
480 } 481 }
481 482
482 scoped_ptr<ui::Layer> View::RecreateLayer() { 483 std::unique_ptr<ui::Layer> View::RecreateLayer() {
483 scoped_ptr<ui::Layer> old_layer = LayerOwner::RecreateLayer(); 484 std::unique_ptr<ui::Layer> old_layer = LayerOwner::RecreateLayer();
484 Widget* widget = GetWidget(); 485 Widget* widget = GetWidget();
485 if (widget) 486 if (widget)
486 widget->UpdateRootLayers(); 487 widget->UpdateRootLayers();
487 return old_layer; 488 return old_layer;
488 } 489 }
489 490
490 // RTL positioning ------------------------------------------------------------- 491 // RTL positioning -------------------------------------------------------------
491 492
492 gfx::Rect View::GetMirroredBounds() const { 493 gfx::Rect View::GetMirroredBounds() const {
493 gfx::Rect bounds(bounds_); 494 gfx::Rect bounds(bounds_);
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
851 } 852 }
852 853
853 // View::Paint() recursion over the subtree. 854 // View::Paint() recursion over the subtree.
854 PaintChildren(context); 855 PaintChildren(context);
855 } 856 }
856 857
857 void View::set_background(Background* b) { 858 void View::set_background(Background* b) {
858 background_.reset(b); 859 background_.reset(b);
859 } 860 }
860 861
861 void View::SetBorder(scoped_ptr<Border> b) { 862 void View::SetBorder(std::unique_ptr<Border> b) {
862 border_ = std::move(b); 863 border_ = std::move(b);
863 } 864 }
864 865
865 const ui::ThemeProvider* View::GetThemeProvider() const { 866 const ui::ThemeProvider* View::GetThemeProvider() const {
866 const Widget* widget = GetWidget(); 867 const Widget* widget = GetWidget();
867 return widget ? widget->GetThemeProvider() : nullptr; 868 return widget ? widget->GetThemeProvider() : nullptr;
868 } 869 }
869 870
870 const ui::NativeTheme* View::GetNativeTheme() const { 871 const ui::NativeTheme* View::GetNativeTheme() const {
871 const Widget* widget = GetWidget(); 872 const Widget* widget = GetWidget();
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
1059 1060
1060 void View::OnGestureEvent(ui::GestureEvent* event) { 1061 void View::OnGestureEvent(ui::GestureEvent* event) {
1061 } 1062 }
1062 1063
1063 const ui::InputMethod* View::GetInputMethod() const { 1064 const ui::InputMethod* View::GetInputMethod() const {
1064 Widget* widget = const_cast<Widget*>(GetWidget()); 1065 Widget* widget = const_cast<Widget*>(GetWidget());
1065 return widget ? const_cast<const ui::InputMethod*>(widget->GetInputMethod()) 1066 return widget ? const_cast<const ui::InputMethod*>(widget->GetInputMethod())
1066 : nullptr; 1067 : nullptr;
1067 } 1068 }
1068 1069
1069 scoped_ptr<ViewTargeter> 1070 std::unique_ptr<ViewTargeter> View::SetEventTargeter(
1070 View::SetEventTargeter(scoped_ptr<ViewTargeter> targeter) { 1071 std::unique_ptr<ViewTargeter> targeter) {
1071 scoped_ptr<ViewTargeter> old_targeter = std::move(targeter_); 1072 std::unique_ptr<ViewTargeter> old_targeter = std::move(targeter_);
1072 targeter_ = std::move(targeter); 1073 targeter_ = std::move(targeter);
1073 return old_targeter; 1074 return old_targeter;
1074 } 1075 }
1075 1076
1076 ViewTargeter* View::GetEffectiveViewTargeter() const { 1077 ViewTargeter* View::GetEffectiveViewTargeter() const {
1077 DCHECK(GetWidget()); 1078 DCHECK(GetWidget());
1078 ViewTargeter* view_targeter = targeter(); 1079 ViewTargeter* view_targeter = targeter();
1079 if (!view_targeter) 1080 if (!view_targeter)
1080 view_targeter = GetWidget()->GetRootView()->targeter(); 1081 view_targeter = GetWidget()->GetRootView()->targeter();
1081 CHECK(view_targeter); 1082 CHECK(view_targeter);
1082 return view_targeter; 1083 return view_targeter;
1083 } 1084 }
1084 1085
1085 bool View::CanAcceptEvent(const ui::Event& event) { 1086 bool View::CanAcceptEvent(const ui::Event& event) {
1086 return IsDrawn(); 1087 return IsDrawn();
1087 } 1088 }
1088 1089
1089 ui::EventTarget* View::GetParentTarget() { 1090 ui::EventTarget* View::GetParentTarget() {
1090 return parent_; 1091 return parent_;
1091 } 1092 }
1092 1093
1093 scoped_ptr<ui::EventTargetIterator> View::GetChildIterator() const { 1094 std::unique_ptr<ui::EventTargetIterator> View::GetChildIterator() const {
1094 return make_scoped_ptr(new ui::EventTargetIteratorImpl<View>(children_)); 1095 return base::WrapUnique(new ui::EventTargetIteratorImpl<View>(children_));
1095 } 1096 }
1096 1097
1097 ui::EventTargeter* View::GetEventTargeter() { 1098 ui::EventTargeter* View::GetEventTargeter() {
1098 return targeter_.get(); 1099 return targeter_.get();
1099 } 1100 }
1100 1101
1101 void View::ConvertEventToTarget(ui::EventTarget* target, 1102 void View::ConvertEventToTarget(ui::EventTarget* target,
1102 ui::LocatedEvent* event) { 1103 ui::LocatedEvent* event) {
1103 event->ConvertLocationToTarget(this, static_cast<View*>(target)); 1104 event->ConvertLocationToTarget(this, static_cast<View*>(target));
1104 } 1105 }
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after
1801 bool update_focus_cycle, 1802 bool update_focus_cycle,
1802 bool update_tool_tip, 1803 bool update_tool_tip,
1803 bool delete_removed_view, 1804 bool delete_removed_view,
1804 View* new_parent) { 1805 View* new_parent) {
1805 DCHECK(view); 1806 DCHECK(view);
1806 1807
1807 const Views::iterator i(std::find(children_.begin(), children_.end(), view)); 1808 const Views::iterator i(std::find(children_.begin(), children_.end(), view));
1808 if (i == children_.end()) 1809 if (i == children_.end())
1809 return; 1810 return;
1810 1811
1811 scoped_ptr<View> view_to_be_deleted; 1812 std::unique_ptr<View> view_to_be_deleted;
1812 if (update_focus_cycle) { 1813 if (update_focus_cycle) {
1813 View* next_focusable = view->next_focusable_view_; 1814 View* next_focusable = view->next_focusable_view_;
1814 View* prev_focusable = view->previous_focusable_view_; 1815 View* prev_focusable = view->previous_focusable_view_;
1815 if (prev_focusable) 1816 if (prev_focusable)
1816 prev_focusable->next_focusable_view_ = next_focusable; 1817 prev_focusable->next_focusable_view_ = next_focusable;
1817 if (next_focusable) 1818 if (next_focusable)
1818 next_focusable->previous_focusable_view_ = prev_focusable; 1819 next_focusable->previous_focusable_view_ = prev_focusable;
1819 } 1820 }
1820 1821
1821 Widget* widget = GetWidget(); 1822 Widget* widget = GetWidget();
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after
2425 // Message the RootView to do the drag and drop. That way if we're removed 2426 // Message the RootView to do the drag and drop. That way if we're removed
2426 // the RootView can detect it and avoid calling us back. 2427 // the RootView can detect it and avoid calling us back.
2427 gfx::Point widget_location(event.location()); 2428 gfx::Point widget_location(event.location());
2428 ConvertPointToWidget(this, &widget_location); 2429 ConvertPointToWidget(this, &widget_location);
2429 widget->RunShellDrag(this, data, widget_location, drag_operations, source); 2430 widget->RunShellDrag(this, data, widget_location, drag_operations, source);
2430 // WARNING: we may have been deleted. 2431 // WARNING: we may have been deleted.
2431 return true; 2432 return true;
2432 } 2433 }
2433 2434
2434 } // namespace views 2435 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/view.h ('k') | ui/views/view_targeter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698