OLD | NEW |
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 <utility> |
11 | 12 |
12 #include "base/logging.h" | 13 #include "base/logging.h" |
13 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
14 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
15 #include "base/stl_util.h" | 16 #include "base/stl_util.h" |
16 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
17 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
18 #include "base/trace_event/trace_event.h" | 19 #include "base/trace_event/trace_event.h" |
19 #include "third_party/skia/include/core/SkRect.h" | 20 #include "third_party/skia/include/core/SkRect.h" |
20 #include "ui/accessibility/ax_enums.h" | 21 #include "ui/accessibility/ax_enums.h" |
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 } else if (!paint_to_layer_ && layer()) { | 469 } else if (!paint_to_layer_ && layer()) { |
469 DestroyLayer(); | 470 DestroyLayer(); |
470 } | 471 } |
471 } | 472 } |
472 | 473 |
473 scoped_ptr<ui::Layer> View::RecreateLayer() { | 474 scoped_ptr<ui::Layer> View::RecreateLayer() { |
474 scoped_ptr<ui::Layer> old_layer = LayerOwner::RecreateLayer(); | 475 scoped_ptr<ui::Layer> old_layer = LayerOwner::RecreateLayer(); |
475 Widget* widget = GetWidget(); | 476 Widget* widget = GetWidget(); |
476 if (widget) | 477 if (widget) |
477 widget->UpdateRootLayers(); | 478 widget->UpdateRootLayers(); |
478 return old_layer.Pass(); | 479 return old_layer; |
479 } | 480 } |
480 | 481 |
481 // RTL positioning ------------------------------------------------------------- | 482 // RTL positioning ------------------------------------------------------------- |
482 | 483 |
483 gfx::Rect View::GetMirroredBounds() const { | 484 gfx::Rect View::GetMirroredBounds() const { |
484 gfx::Rect bounds(bounds_); | 485 gfx::Rect bounds(bounds_); |
485 bounds.set_x(GetMirroredX()); | 486 bounds.set_x(GetMirroredX()); |
486 return bounds; | 487 return bounds; |
487 } | 488 } |
488 | 489 |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
841 } | 842 } |
842 | 843 |
843 // View::Paint() recursion over the subtree. | 844 // View::Paint() recursion over the subtree. |
844 PaintChildren(context); | 845 PaintChildren(context); |
845 } | 846 } |
846 | 847 |
847 void View::set_background(Background* b) { | 848 void View::set_background(Background* b) { |
848 background_.reset(b); | 849 background_.reset(b); |
849 } | 850 } |
850 | 851 |
851 void View::SetBorder(scoped_ptr<Border> b) { border_ = b.Pass(); } | 852 void View::SetBorder(scoped_ptr<Border> b) { |
| 853 border_ = std::move(b); |
| 854 } |
852 | 855 |
853 const ui::ThemeProvider* View::GetThemeProvider() const { | 856 const ui::ThemeProvider* View::GetThemeProvider() const { |
854 const Widget* widget = GetWidget(); | 857 const Widget* widget = GetWidget(); |
855 return widget ? widget->GetThemeProvider() : nullptr; | 858 return widget ? widget->GetThemeProvider() : nullptr; |
856 } | 859 } |
857 | 860 |
858 const ui::NativeTheme* View::GetNativeTheme() const { | 861 const ui::NativeTheme* View::GetNativeTheme() const { |
859 const Widget* widget = GetWidget(); | 862 const Widget* widget = GetWidget(); |
860 if (widget) | 863 if (widget) |
861 return widget->GetNativeTheme(); | 864 return widget->GetNativeTheme(); |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1050 } | 1053 } |
1051 | 1054 |
1052 const ui::InputMethod* View::GetInputMethod() const { | 1055 const ui::InputMethod* View::GetInputMethod() const { |
1053 Widget* widget = const_cast<Widget*>(GetWidget()); | 1056 Widget* widget = const_cast<Widget*>(GetWidget()); |
1054 return widget ? const_cast<const ui::InputMethod*>(widget->GetInputMethod()) | 1057 return widget ? const_cast<const ui::InputMethod*>(widget->GetInputMethod()) |
1055 : nullptr; | 1058 : nullptr; |
1056 } | 1059 } |
1057 | 1060 |
1058 scoped_ptr<ViewTargeter> | 1061 scoped_ptr<ViewTargeter> |
1059 View::SetEventTargeter(scoped_ptr<ViewTargeter> targeter) { | 1062 View::SetEventTargeter(scoped_ptr<ViewTargeter> targeter) { |
1060 scoped_ptr<ViewTargeter> old_targeter = targeter_.Pass(); | 1063 scoped_ptr<ViewTargeter> old_targeter = std::move(targeter_); |
1061 targeter_ = targeter.Pass(); | 1064 targeter_ = std::move(targeter); |
1062 return old_targeter.Pass(); | 1065 return old_targeter; |
1063 } | 1066 } |
1064 | 1067 |
1065 ViewTargeter* View::GetEffectiveViewTargeter() const { | 1068 ViewTargeter* View::GetEffectiveViewTargeter() const { |
1066 DCHECK(GetWidget()); | 1069 DCHECK(GetWidget()); |
1067 ViewTargeter* view_targeter = targeter(); | 1070 ViewTargeter* view_targeter = targeter(); |
1068 if (!view_targeter) | 1071 if (!view_targeter) |
1069 view_targeter = GetWidget()->GetRootView()->targeter(); | 1072 view_targeter = GetWidget()->GetRootView()->targeter(); |
1070 CHECK(view_targeter); | 1073 CHECK(view_targeter); |
1071 return view_targeter; | 1074 return view_targeter; |
1072 } | 1075 } |
(...skipping 1312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2385 // Message the RootView to do the drag and drop. That way if we're removed | 2388 // Message the RootView to do the drag and drop. That way if we're removed |
2386 // the RootView can detect it and avoid calling us back. | 2389 // the RootView can detect it and avoid calling us back. |
2387 gfx::Point widget_location(event.location()); | 2390 gfx::Point widget_location(event.location()); |
2388 ConvertPointToWidget(this, &widget_location); | 2391 ConvertPointToWidget(this, &widget_location); |
2389 widget->RunShellDrag(this, data, widget_location, drag_operations, source); | 2392 widget->RunShellDrag(this, data, widget_location, drag_operations, source); |
2390 // WARNING: we may have been deleted. | 2393 // WARNING: we may have been deleted. |
2391 return true; | 2394 return true; |
2392 } | 2395 } |
2393 | 2396 |
2394 } // namespace views | 2397 } // namespace views |
OLD | NEW |