| 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 #include "ui/views/view.h" | 5 #include "ui/views/view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 } | 342 } |
| 343 view = ancestor; | 343 view = ancestor; |
| 344 } | 344 } |
| 345 if (vis_bounds.IsEmpty()) | 345 if (vis_bounds.IsEmpty()) |
| 346 return vis_bounds; | 346 return vis_bounds; |
| 347 // Convert back to this views coordinate system. | 347 // Convert back to this views coordinate system. |
| 348 transform.TransformRectReverse(&vis_bounds); | 348 transform.TransformRectReverse(&vis_bounds); |
| 349 return vis_bounds; | 349 return vis_bounds; |
| 350 } | 350 } |
| 351 | 351 |
| 352 gfx::Rect View::GetScreenBounds() const { | 352 gfx::Rect View::GetBoundsInScreen() const { |
| 353 gfx::Point origin; | 353 gfx::Point origin; |
| 354 View::ConvertPointToScreen(this, &origin); | 354 View::ConvertPointToScreen(this, &origin); |
| 355 return gfx::Rect(origin, size()); | 355 return gfx::Rect(origin, size()); |
| 356 } | 356 } |
| 357 | 357 |
| 358 gfx::Size View::GetPreferredSize() { | 358 gfx::Size View::GetPreferredSize() { |
| 359 if (layout_manager_.get()) | 359 if (layout_manager_.get()) |
| 360 return layout_manager_->GetPreferredSize(this); | 360 return layout_manager_->GetPreferredSize(this); |
| 361 return gfx::Size(); | 361 return gfx::Size(); |
| 362 } | 362 } |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 if (source != root) | 615 if (source != root) |
| 616 source->ConvertPointForAncestor(root, point); | 616 source->ConvertPointForAncestor(root, point); |
| 617 } | 617 } |
| 618 | 618 |
| 619 if (target != root) | 619 if (target != root) |
| 620 target->ConvertPointFromAncestor(root, point); | 620 target->ConvertPointFromAncestor(root, point); |
| 621 | 621 |
| 622 // API defines NULL |source| as returning the point in screen coordinates. | 622 // API defines NULL |source| as returning the point in screen coordinates. |
| 623 if (!source) { | 623 if (!source) { |
| 624 *point = point->Subtract( | 624 *point = point->Subtract( |
| 625 root->GetWidget()->GetClientAreaScreenBounds().origin()); | 625 root->GetWidget()->GetClientAreaBoundsInScreen().origin()); |
| 626 } | 626 } |
| 627 } | 627 } |
| 628 | 628 |
| 629 // static | 629 // static |
| 630 void View::ConvertPointToWidget(const View* src, gfx::Point* p) { | 630 void View::ConvertPointToWidget(const View* src, gfx::Point* p) { |
| 631 DCHECK(src); | 631 DCHECK(src); |
| 632 DCHECK(p); | 632 DCHECK(p); |
| 633 | 633 |
| 634 src->ConvertPointForAncestor(NULL, p); | 634 src->ConvertPointForAncestor(NULL, p); |
| 635 } | 635 } |
| 636 | 636 |
| 637 // static | 637 // static |
| 638 void View::ConvertPointFromWidget(const View* dest, gfx::Point* p) { | 638 void View::ConvertPointFromWidget(const View* dest, gfx::Point* p) { |
| 639 DCHECK(dest); | 639 DCHECK(dest); |
| 640 DCHECK(p); | 640 DCHECK(p); |
| 641 | 641 |
| 642 dest->ConvertPointFromAncestor(NULL, p); | 642 dest->ConvertPointFromAncestor(NULL, p); |
| 643 } | 643 } |
| 644 | 644 |
| 645 // static | 645 // static |
| 646 void View::ConvertPointToScreen(const View* src, gfx::Point* p) { | 646 void View::ConvertPointToScreen(const View* src, gfx::Point* p) { |
| 647 DCHECK(src); | 647 DCHECK(src); |
| 648 DCHECK(p); | 648 DCHECK(p); |
| 649 | 649 |
| 650 // If the view is not connected to a tree, there's nothing we can do. | 650 // If the view is not connected to a tree, there's nothing we can do. |
| 651 const Widget* widget = src->GetWidget(); | 651 const Widget* widget = src->GetWidget(); |
| 652 if (widget) { | 652 if (widget) { |
| 653 ConvertPointToWidget(src, p); | 653 ConvertPointToWidget(src, p); |
| 654 gfx::Rect r = widget->GetClientAreaScreenBounds(); | 654 gfx::Rect r = widget->GetClientAreaBoundsInScreen(); |
| 655 p->SetPoint(p->x() + r.x(), p->y() + r.y()); | 655 p->SetPoint(p->x() + r.x(), p->y() + r.y()); |
| 656 } | 656 } |
| 657 } | 657 } |
| 658 | 658 |
| 659 // static | 659 // static |
| 660 void View::ConvertPointFromScreen(const View* dst, gfx::Point* p) { | 660 void View::ConvertPointFromScreen(const View* dst, gfx::Point* p) { |
| 661 DCHECK(dst); | 661 DCHECK(dst); |
| 662 DCHECK(p); | 662 DCHECK(p); |
| 663 | 663 |
| 664 const views::Widget* widget = dst->GetWidget(); | 664 const views::Widget* widget = dst->GetWidget(); |
| 665 if (!widget) | 665 if (!widget) |
| 666 return; | 666 return; |
| 667 const gfx::Rect r = widget->GetClientAreaScreenBounds(); | 667 const gfx::Rect r = widget->GetClientAreaBoundsInScreen(); |
| 668 p->Offset(-r.x(), -r.y()); | 668 p->Offset(-r.x(), -r.y()); |
| 669 views::View::ConvertPointFromWidget(dst, p); | 669 views::View::ConvertPointFromWidget(dst, p); |
| 670 } | 670 } |
| 671 | 671 |
| 672 gfx::Rect View::ConvertRectToParent(const gfx::Rect& rect) const { | 672 gfx::Rect View::ConvertRectToParent(const gfx::Rect& rect) const { |
| 673 gfx::Rect x_rect = rect; | 673 gfx::Rect x_rect = rect; |
| 674 GetTransform().TransformRect(&x_rect); | 674 GetTransform().TransformRect(&x_rect); |
| 675 x_rect.Offset(GetMirroredPosition()); | 675 x_rect.Offset(GetMirroredPosition()); |
| 676 return x_rect; | 676 return x_rect; |
| 677 } | 677 } |
| (...skipping 1427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2105 gfx::Point widget_location(event.location()); | 2105 gfx::Point widget_location(event.location()); |
| 2106 ConvertPointToWidget(this, &widget_location); | 2106 ConvertPointToWidget(this, &widget_location); |
| 2107 GetWidget()->RunShellDrag(this, data, widget_location, drag_operations); | 2107 GetWidget()->RunShellDrag(this, data, widget_location, drag_operations); |
| 2108 return true; | 2108 return true; |
| 2109 #else | 2109 #else |
| 2110 return false; | 2110 return false; |
| 2111 #endif // !defined(OS_MACOSX) | 2111 #endif // !defined(OS_MACOSX) |
| 2112 } | 2112 } |
| 2113 | 2113 |
| 2114 } // namespace views | 2114 } // namespace views |
| OLD | NEW |