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

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

Issue 2595163002: Add origin() method on View and use it to simplify some callers. (Closed)
Patch Set: Created 4 years 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
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 768 matching lines...) Expand 10 before | Expand all | Expand 10 after
779 void View::Paint(const ui::PaintContext& parent_context) { 779 void View::Paint(const ui::PaintContext& parent_context) {
780 if (!visible_) 780 if (!visible_)
781 return; 781 return;
782 if (size().IsEmpty()) 782 if (size().IsEmpty())
783 return; 783 return;
784 784
785 gfx::Vector2d offset_to_parent; 785 gfx::Vector2d offset_to_parent;
786 if (!layer()) { 786 if (!layer()) {
787 // If the View has a layer() then it is a paint root. Otherwise, we need to 787 // If the View has a layer() then it is a paint root. Otherwise, we need to
788 // add the offset from the parent into the total offset from the paint root. 788 // add the offset from the parent into the total offset from the paint root.
789 DCHECK(parent() || bounds().origin() == gfx::Point()); 789 DCHECK(parent() || origin() == gfx::Point());
790 offset_to_parent = GetMirroredPosition().OffsetFromOrigin(); 790 offset_to_parent = GetMirroredPosition().OffsetFromOrigin();
791 } 791 }
792 ui::PaintContext context(parent_context, offset_to_parent); 792 ui::PaintContext context(parent_context, offset_to_parent);
793 793
794 bool is_invalidated = true; 794 bool is_invalidated = true;
795 if (context.CanCheckInvalid()) { 795 if (context.CanCheckInvalid()) {
796 #if DCHECK_IS_ON() 796 #if DCHECK_IS_ON()
797 gfx::Vector2d offset; 797 gfx::Vector2d offset;
798 context.Visited(this); 798 context.Visited(this);
799 View* view = this; 799 View* view = this;
(...skipping 1648 matching lines...) Expand 10 before | Expand all | Expand 10 after
2448 // Message the RootView to do the drag and drop. That way if we're removed 2448 // Message the RootView to do the drag and drop. That way if we're removed
2449 // the RootView can detect it and avoid calling us back. 2449 // the RootView can detect it and avoid calling us back.
2450 gfx::Point widget_location(event.location()); 2450 gfx::Point widget_location(event.location());
2451 ConvertPointToWidget(this, &widget_location); 2451 ConvertPointToWidget(this, &widget_location);
2452 widget->RunShellDrag(this, data, widget_location, drag_operations, source); 2452 widget->RunShellDrag(this, data, widget_location, drag_operations, source);
2453 // WARNING: we may have been deleted. 2453 // WARNING: we may have been deleted.
2454 return true; 2454 return true;
2455 } 2455 }
2456 2456
2457 } // namespace views 2457 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698