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

Unified Diff: ui/views/view_unittest.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: emptyview: size 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/view.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/view_unittest.cc
diff --git a/ui/views/view_unittest.cc b/ui/views/view_unittest.cc
index 1a103b731deb77f359ff10f7048caa4d6c15c196..bdcf48be132fe12b72643a5090a02ecc3dfb3e63 100644
--- a/ui/views/view_unittest.cc
+++ b/ui/views/view_unittest.cc
@@ -432,6 +432,41 @@ void TestView::OnPaint(gfx::Canvas* canvas) {
did_paint_ = true;
}
+TEST_F(ViewTest, PaintEmptyView) {
+ Widget* widget = new Widget;
+ Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP);
+ widget->Init(params);
+ View* root_view = widget->GetRootView();
+ root_view->SetBounds(0, 0, 25, 26);
+
+ // |v1| is empty.
+ TestView* v1 = new TestView;
+ v1->SetBounds(10, 11, 0, 1);
+ root_view->AddChildView(v1);
+
+ // |v11| is a child of an empty |v1|.
+ TestView* v11 = new TestView;
+ v11->SetBounds(3, 4, 6, 5);
+ v1->AddChildView(v11);
+
+ // |v2| is not.
+ TestView* v2 = new TestView;
+ v2->SetBounds(3, 4, 6, 5);
+ root_view->AddChildView(v2);
+
+ // Paint "everything".
+ gfx::Rect first_paint(1, 1);
+ scoped_refptr<cc::DisplayItemList> list =
+ cc::DisplayItemList::Create(first_paint, cc::DisplayItemListSettings());
+ root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint, first_paint));
+
+ // The empty view has nothing to paint so it doesn't try build a cache, nor do
+ // its children which would be clipped by its (empty) self.
+ EXPECT_FALSE(v1->did_paint_);
+ EXPECT_FALSE(v11->did_paint_);
+ EXPECT_TRUE(v2->did_paint_);
+}
+
TEST_F(ViewTest, PaintWithUnknownInvalidation) {
Widget* widget = new Widget;
Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP);
« no previous file with comments | « ui/views/view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698