| 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 | 11 |
| 12 #include "base/debug/trace_event.h" | 12 #include "base/debug/trace_event.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
| 16 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
| 17 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 18 #include "third_party/skia/include/core/SkRect.h" | 18 #include "third_party/skia/include/core/SkRect.h" |
| 19 #include "ui/accessibility/ax_enums.h" | 19 #include "ui/accessibility/ax_enums.h" |
| 20 #include "ui/base/cursor/cursor.h" | 20 #include "ui/base/cursor/cursor.h" |
| 21 #include "ui/base/dragdrop/drag_drop_types.h" | 21 #include "ui/base/dragdrop/drag_drop_types.h" |
| 22 #include "ui/base/ui_base_switches_util.h" | 22 #include "ui/base/ui_base_switches_util.h" |
| 23 #include "ui/compositor/clone_layer.h" |
| 23 #include "ui/compositor/compositor.h" | 24 #include "ui/compositor/compositor.h" |
| 24 #include "ui/compositor/layer.h" | 25 #include "ui/compositor/layer.h" |
| 25 #include "ui/compositor/layer_animator.h" | 26 #include "ui/compositor/layer_animator.h" |
| 26 #include "ui/events/event_target_iterator.h" | 27 #include "ui/events/event_target_iterator.h" |
| 27 #include "ui/gfx/canvas.h" | 28 #include "ui/gfx/canvas.h" |
| 28 #include "ui/gfx/interpolated_transform.h" | 29 #include "ui/gfx/interpolated_transform.h" |
| 29 #include "ui/gfx/path.h" | 30 #include "ui/gfx/path.h" |
| 30 #include "ui/gfx/point3_f.h" | 31 #include "ui/gfx/point3_f.h" |
| 31 #include "ui/gfx/point_conversions.h" | 32 #include "ui/gfx/point_conversions.h" |
| 32 #include "ui/gfx/rect_conversions.h" | 33 #include "ui/gfx/rect_conversions.h" |
| (...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 void View::SetPaintToLayer(bool paint_to_layer) { | 500 void View::SetPaintToLayer(bool paint_to_layer) { |
| 500 paint_to_layer_ = paint_to_layer; | 501 paint_to_layer_ = paint_to_layer; |
| 501 if (paint_to_layer_ && !layer()) { | 502 if (paint_to_layer_ && !layer()) { |
| 502 CreateLayer(); | 503 CreateLayer(); |
| 503 } else if (!paint_to_layer_ && layer()) { | 504 } else if (!paint_to_layer_ && layer()) { |
| 504 DestroyLayer(); | 505 DestroyLayer(); |
| 505 } | 506 } |
| 506 } | 507 } |
| 507 | 508 |
| 508 scoped_ptr<ui::Layer> View::RecreateLayer() { | 509 scoped_ptr<ui::Layer> View::RecreateLayer() { |
| 509 scoped_ptr<ui::Layer> acquired(AcquireLayer()); | 510 return ui::CloneLayer(this); |
| 510 if (!acquired) | |
| 511 return acquired.Pass(); | |
| 512 | |
| 513 CreateLayer(); | |
| 514 layer()->set_scale_content(acquired->scale_content()); | |
| 515 return acquired.Pass(); | |
| 516 } | 511 } |
| 517 | 512 |
| 518 // RTL positioning ------------------------------------------------------------- | 513 // RTL positioning ------------------------------------------------------------- |
| 519 | 514 |
| 520 gfx::Rect View::GetMirroredBounds() const { | 515 gfx::Rect View::GetMirroredBounds() const { |
| 521 gfx::Rect bounds(bounds_); | 516 gfx::Rect bounds(bounds_); |
| 522 bounds.set_x(GetMirroredX()); | 517 bounds.set_x(GetMirroredX()); |
| 523 return bounds; | 518 return bounds; |
| 524 } | 519 } |
| 525 | 520 |
| (...skipping 1821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2347 // Message the RootView to do the drag and drop. That way if we're removed | 2342 // Message the RootView to do the drag and drop. That way if we're removed |
| 2348 // the RootView can detect it and avoid calling us back. | 2343 // the RootView can detect it and avoid calling us back. |
| 2349 gfx::Point widget_location(event.location()); | 2344 gfx::Point widget_location(event.location()); |
| 2350 ConvertPointToWidget(this, &widget_location); | 2345 ConvertPointToWidget(this, &widget_location); |
| 2351 widget->RunShellDrag(this, data, widget_location, drag_operations, source); | 2346 widget->RunShellDrag(this, data, widget_location, drag_operations, source); |
| 2352 // WARNING: we may have been deleted. | 2347 // WARNING: we may have been deleted. |
| 2353 return true; | 2348 return true; |
| 2354 } | 2349 } |
| 2355 | 2350 |
| 2356 } // namespace views | 2351 } // namespace views |
| OLD | NEW |