| 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> |
| (...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 672 | 672 |
| 673 dest->ConvertPointFromAncestor(NULL, p); | 673 dest->ConvertPointFromAncestor(NULL, p); |
| 674 } | 674 } |
| 675 | 675 |
| 676 // static | 676 // static |
| 677 void View::ConvertPointToScreen(const View* src, gfx::Point* p) { | 677 void View::ConvertPointToScreen(const View* src, gfx::Point* p) { |
| 678 DCHECK(src); | 678 DCHECK(src); |
| 679 DCHECK(p); | 679 DCHECK(p); |
| 680 | 680 |
| 681 // If the view is not connected to a tree, there's nothing we can do. | 681 // If the view is not connected to a tree, there's nothing we can do. |
| 682 ConvertPointToWidget(src, p); |
| 682 const Widget* widget = src->GetWidget(); | 683 const Widget* widget = src->GetWidget(); |
| 683 if (widget) { | 684 if (widget) |
| 684 ConvertPointToWidget(src, p); | |
| 685 *p += widget->GetClientAreaBoundsInScreen().OffsetFromOrigin(); | 685 *p += widget->GetClientAreaBoundsInScreen().OffsetFromOrigin(); |
| 686 } | |
| 687 } | 686 } |
| 688 | 687 |
| 689 // static | 688 // static |
| 690 void View::ConvertPointFromScreen(const View* dst, gfx::Point* p) { | 689 void View::ConvertPointFromScreen(const View* dst, gfx::Point* p) { |
| 691 DCHECK(dst); | 690 DCHECK(dst); |
| 692 DCHECK(p); | 691 DCHECK(p); |
| 693 | 692 |
| 694 const views::Widget* widget = dst->GetWidget(); | 693 const views::Widget* widget = dst->GetWidget(); |
| 695 if (!widget) | 694 if (widget) |
| 696 return; | 695 *p -= widget->GetClientAreaBoundsInScreen().OffsetFromOrigin(); |
| 697 *p -= widget->GetClientAreaBoundsInScreen().OffsetFromOrigin(); | |
| 698 views::View::ConvertPointFromWidget(dst, p); | 696 views::View::ConvertPointFromWidget(dst, p); |
| 699 } | 697 } |
| 700 | 698 |
| 701 gfx::Rect View::ConvertRectToParent(const gfx::Rect& rect) const { | 699 gfx::Rect View::ConvertRectToParent(const gfx::Rect& rect) const { |
| 702 gfx::RectF x_rect = rect; | 700 gfx::RectF x_rect = rect; |
| 703 GetTransform().TransformRect(&x_rect); | 701 GetTransform().TransformRect(&x_rect); |
| 704 x_rect.Offset(GetMirroredPosition().OffsetFromOrigin()); | 702 x_rect.Offset(GetMirroredPosition().OffsetFromOrigin()); |
| 705 // Pixels we partially occupy in the parent should be included. | 703 // Pixels we partially occupy in the parent should be included. |
| 706 return gfx::ToEnclosingRect(x_rect); | 704 return gfx::ToEnclosingRect(x_rect); |
| 707 } | 705 } |
| (...skipping 1641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2349 // Message the RootView to do the drag and drop. That way if we're removed | 2347 // Message the RootView to do the drag and drop. That way if we're removed |
| 2350 // the RootView can detect it and avoid calling us back. | 2348 // the RootView can detect it and avoid calling us back. |
| 2351 gfx::Point widget_location(event.location()); | 2349 gfx::Point widget_location(event.location()); |
| 2352 ConvertPointToWidget(this, &widget_location); | 2350 ConvertPointToWidget(this, &widget_location); |
| 2353 widget->RunShellDrag(this, data, widget_location, drag_operations, source); | 2351 widget->RunShellDrag(this, data, widget_location, drag_operations, source); |
| 2354 // WARNING: we may have been deleted. | 2352 // WARNING: we may have been deleted. |
| 2355 return true; | 2353 return true; |
| 2356 } | 2354 } |
| 2357 | 2355 |
| 2358 } // namespace views | 2356 } // namespace views |
| OLD | NEW |