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

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

Issue 1279023002: [Views] Make ConvertPointToScreen work without Widget. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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 | « no previous file | no next file » | 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>
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698