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

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

Issue 1166373008: views: Early out of painting Views with empty bounds. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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 | ui/views/view_unittest.cc » ('j') | 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 719 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 } else if (parent_) { 730 } else if (parent_) {
731 // Translate the requested paint rect to the parent's coordinate system 731 // Translate the requested paint rect to the parent's coordinate system
732 // then pass this notification up to the parent. 732 // then pass this notification up to the parent.
733 parent_->SchedulePaintInRect(ConvertRectToParent(rect)); 733 parent_->SchedulePaintInRect(ConvertRectToParent(rect));
734 } 734 }
735 } 735 }
736 736
737 void View::Paint(const ui::PaintContext& parent_context) { 737 void View::Paint(const ui::PaintContext& parent_context) {
738 if (!visible_) 738 if (!visible_)
739 return; 739 return;
740 if (bounds().IsEmpty())
weiliangc 2015/06/09 22:04:42 nit: We can use size() instead?
danakj 2015/06/09 22:05:15 Ya, though size() is bounds().size() so that's an
741 return;
740 742
741 gfx::Vector2d offset_to_parent; 743 gfx::Vector2d offset_to_parent;
742 if (!layer()) { 744 if (!layer()) {
743 // If the View has a layer() then it is a paint root. Otherwise, we need to 745 // If the View has a layer() then it is a paint root. Otherwise, we need to
744 // add the offset from the parent into the total offset from the paint root. 746 // add the offset from the parent into the total offset from the paint root.
745 DCHECK_IMPLIES(!parent(), bounds().origin() == gfx::Point()); 747 DCHECK_IMPLIES(!parent(), bounds().origin() == gfx::Point());
746 offset_to_parent = GetMirroredPosition().OffsetFromOrigin(); 748 offset_to_parent = GetMirroredPosition().OffsetFromOrigin();
747 } 749 }
748 ui::PaintContext context(parent_context, offset_to_parent); 750 ui::PaintContext context(parent_context, offset_to_parent);
749 751
(...skipping 1618 matching lines...) Expand 10 before | Expand all | Expand 10 after
2368 // Message the RootView to do the drag and drop. That way if we're removed 2370 // Message the RootView to do the drag and drop. That way if we're removed
2369 // the RootView can detect it and avoid calling us back. 2371 // the RootView can detect it and avoid calling us back.
2370 gfx::Point widget_location(event.location()); 2372 gfx::Point widget_location(event.location());
2371 ConvertPointToWidget(this, &widget_location); 2373 ConvertPointToWidget(this, &widget_location);
2372 widget->RunShellDrag(this, data, widget_location, drag_operations, source); 2374 widget->RunShellDrag(this, data, widget_location, drag_operations, source);
2373 // WARNING: we may have been deleted. 2375 // WARNING: we may have been deleted.
2374 return true; 2376 return true;
2375 } 2377 }
2376 2378
2377 } // namespace views 2379 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | ui/views/view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698