Index: ui/views/view_unittest.cc |
diff --git a/ui/views/view_unittest.cc b/ui/views/view_unittest.cc |
index 1dbb59e20cc5ac17e19a091bbe26486be2af4dae..d1eb37135147ea8cb3f9b16ce18ff1e1cdf11ed6 100644 |
--- a/ui/views/view_unittest.cc |
+++ b/ui/views/view_unittest.cc |
@@ -40,6 +40,7 @@ |
#include "ui/views/controls/native/native_view_host.h" |
#include "ui/views/controls/scroll_view.h" |
#include "ui/views/controls/textfield/textfield.h" |
+#include "ui/views/paint_info.h" |
#include "ui/views/test/views_test_base.h" |
#include "ui/views/view_observer.h" |
#include "ui/views/widget/native_widget.h" |
@@ -527,7 +528,9 @@ TEST_F(ViewTest, PaintEmptyView) { |
// Paint "everything". |
gfx::Rect first_paint(1, 1); |
auto list = base::MakeRefCounted<cc::DisplayItemList>(); |
- root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint)); |
+ root_view->Paint(PaintInfo::CreateRootPaintInfo( |
+ ui::PaintContext(list.get(), 1.f, first_paint, false), |
+ first_paint.size())); |
// 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. |
@@ -548,8 +551,8 @@ TEST_F(ViewTest, PaintWithMovedViewUsesCache) { |
gfx::Rect pixel_rect = gfx::Rect(1, 1); |
float device_scale_factor = 1.f; |
auto list = base::MakeRefCounted<cc::DisplayItemList>(); |
- root_view->Paint( |
- ui::PaintContext(list.get(), device_scale_factor, pixel_rect)); |
+ root_view->PaintFromPaintRoot( |
+ ui::PaintContext(list.get(), device_scale_factor, pixel_rect, false)); |
EXPECT_TRUE(v1->did_paint_); |
v1->Reset(); |
// The visual rects for (clip, drawing, transform) should be in layer space. |
@@ -564,15 +567,15 @@ TEST_F(ViewTest, PaintWithMovedViewUsesCache) { |
// If invalidation doesn't intersect v1, we paint with the cache. |
list = base::MakeRefCounted<cc::DisplayItemList>(); |
- root_view->Paint( |
- ui::PaintContext(list.get(), device_scale_factor, pixel_rect)); |
+ root_view->PaintFromPaintRoot( |
+ ui::PaintContext(list.get(), device_scale_factor, pixel_rect, false)); |
EXPECT_FALSE(v1->did_paint_); |
v1->Reset(); |
// If invalidation does intersect v1, we don't paint with the cache. |
list = base::MakeRefCounted<cc::DisplayItemList>(); |
- root_view->Paint( |
- ui::PaintContext(list.get(), device_scale_factor, v1->bounds())); |
+ root_view->PaintFromPaintRoot( |
+ ui::PaintContext(list.get(), device_scale_factor, v1->bounds(), false)); |
EXPECT_TRUE(v1->did_paint_); |
v1->Reset(); |
@@ -580,8 +583,8 @@ TEST_F(ViewTest, PaintWithMovedViewUsesCache) { |
// intersect v1. |
list = base::MakeRefCounted<cc::DisplayItemList>(); |
v1->SetX(9); |
- root_view->Paint( |
- ui::PaintContext(list.get(), device_scale_factor, pixel_rect)); |
+ root_view->PaintFromPaintRoot( |
+ ui::PaintContext(list.get(), device_scale_factor, pixel_rect, false)); |
EXPECT_FALSE(v1->did_paint_); |
v1->Reset(); |
item_index = 3; |
@@ -597,8 +600,8 @@ TEST_F(ViewTest, PaintWithMovedViewUsesCache) { |
// invalidation. |
list = base::MakeRefCounted<cc::DisplayItemList>(); |
v1->SetX(8); |
- root_view->Paint(ui::PaintContext( |
- ui::PaintContext(list.get(), device_scale_factor, pixel_rect), |
+ root_view->PaintFromPaintRoot(ui::PaintContext( |
+ ui::PaintContext(list.get(), device_scale_factor, pixel_rect, false), |
ui::PaintContext::CLONE_WITHOUT_INVALIDATION)); |
EXPECT_TRUE(v1->did_paint_); |
v1->Reset(); |
@@ -625,8 +628,8 @@ TEST_F(ViewTest, PaintWithMovedViewUsesCacheInRTL) { |
gfx::Rect pixel_rect = gfx::Rect(1, 1); |
float device_scale_factor = 1.f; |
auto list = base::MakeRefCounted<cc::DisplayItemList>(); |
- root_view->Paint( |
- ui::PaintContext(list.get(), device_scale_factor, pixel_rect)); |
+ root_view->PaintFromPaintRoot( |
+ ui::PaintContext(list.get(), device_scale_factor, pixel_rect, false)); |
EXPECT_TRUE(v1->did_paint_); |
v1->Reset(); |
// The visual rects for (clip, drawing, transform) should be in layer space. |
@@ -642,15 +645,15 @@ TEST_F(ViewTest, PaintWithMovedViewUsesCacheInRTL) { |
// If invalidation doesn't intersect v1, we paint with the cache. |
list = base::MakeRefCounted<cc::DisplayItemList>(); |
- root_view->Paint( |
- ui::PaintContext(list.get(), device_scale_factor, pixel_rect)); |
+ root_view->PaintFromPaintRoot( |
+ ui::PaintContext(list.get(), device_scale_factor, pixel_rect, false)); |
EXPECT_FALSE(v1->did_paint_); |
v1->Reset(); |
// If invalidation does intersect v1, we don't paint with the cache. |
list = base::MakeRefCounted<cc::DisplayItemList>(); |
- root_view->Paint( |
- ui::PaintContext(list.get(), device_scale_factor, v1->bounds())); |
+ root_view->PaintFromPaintRoot( |
+ ui::PaintContext(list.get(), device_scale_factor, v1->bounds(), false)); |
EXPECT_TRUE(v1->did_paint_); |
v1->Reset(); |
@@ -658,8 +661,8 @@ TEST_F(ViewTest, PaintWithMovedViewUsesCacheInRTL) { |
// intersect v1. |
list = base::MakeRefCounted<cc::DisplayItemList>(); |
v1->SetX(9); |
- root_view->Paint( |
- ui::PaintContext(list.get(), device_scale_factor, pixel_rect)); |
+ root_view->PaintFromPaintRoot( |
+ ui::PaintContext(list.get(), device_scale_factor, pixel_rect, false)); |
EXPECT_FALSE(v1->did_paint_); |
v1->Reset(); |
item_index = 3; |
@@ -676,8 +679,8 @@ TEST_F(ViewTest, PaintWithMovedViewUsesCacheInRTL) { |
// invalidation. |
list = base::MakeRefCounted<cc::DisplayItemList>(); |
v1->SetX(8); |
- root_view->Paint(ui::PaintContext( |
- ui::PaintContext(list.get(), device_scale_factor, pixel_rect), |
+ root_view->PaintFromPaintRoot(ui::PaintContext( |
+ ui::PaintContext(list.get(), device_scale_factor, pixel_rect, false), |
ui::PaintContext::CLONE_WITHOUT_INVALIDATION)); |
EXPECT_TRUE(v1->did_paint_); |
v1->Reset(); |
@@ -708,7 +711,8 @@ TEST_F(ViewTest, PaintWithUnknownInvalidation) { |
// invalidation. |
gfx::Rect first_paint(1, 1); |
auto list = base::MakeRefCounted<cc::DisplayItemList>(); |
- root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint)); |
+ root_view->PaintFromPaintRoot( |
+ ui::PaintContext(list.get(), 1.f, first_paint, false)); |
v1->Reset(); |
v2->Reset(); |
@@ -719,13 +723,14 @@ TEST_F(ViewTest, PaintWithUnknownInvalidation) { |
// With a known invalidation, v1 and v2 are not painted. |
EXPECT_FALSE(v1->did_paint_); |
EXPECT_FALSE(v2->did_paint_); |
- root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); |
+ root_view->PaintFromPaintRoot( |
+ ui::PaintContext(list.get(), 1.f, paint_area, false)); |
EXPECT_FALSE(v1->did_paint_); |
EXPECT_FALSE(v2->did_paint_); |
// With unknown invalidation, v1 and v2 are painted. |
- root_view->Paint( |
- ui::PaintContext(ui::PaintContext(list.get(), 1.f, paint_area), |
+ root_view->PaintFromPaintRoot( |
+ ui::PaintContext(ui::PaintContext(list.get(), 1.f, paint_area, false), |
ui::PaintContext::CLONE_WITHOUT_INVALIDATION)); |
EXPECT_TRUE(v1->did_paint_); |
EXPECT_TRUE(v2->did_paint_); |
@@ -747,7 +752,9 @@ TEST_F(ViewTest, PaintContainsChildren) { |
// invalidation. |
gfx::Rect first_paint(1, 1); |
auto list = base::MakeRefCounted<cc::DisplayItemList>(); |
- root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint)); |
+ root_view->Paint(PaintInfo::CreateRootPaintInfo( |
+ ui::PaintContext(list.get(), 1.f, first_paint, false), |
+ root_view->size())); |
v1->Reset(); |
v2->Reset(); |
@@ -757,7 +764,8 @@ TEST_F(ViewTest, PaintContainsChildren) { |
EXPECT_FALSE(v1->did_paint_); |
EXPECT_FALSE(v2->did_paint_); |
- root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); |
+ root_view->Paint(PaintInfo::CreateRootPaintInfo( |
+ ui::PaintContext(list.get(), 1.f, paint_area, false), root_view->size())); |
EXPECT_TRUE(v1->did_paint_); |
EXPECT_TRUE(v2->did_paint_); |
} |
@@ -790,7 +798,9 @@ TEST_F(ViewTest, PaintContainsChildrenInRTL) { |
// invalidation. |
gfx::Rect first_paint(1, 1); |
auto list = base::MakeRefCounted<cc::DisplayItemList>(); |
- root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint)); |
+ root_view->Paint(PaintInfo::CreateRootPaintInfo( |
+ ui::PaintContext(list.get(), 1.f, first_paint, false), |
+ root_view->size())); |
v1->Reset(); |
v2->Reset(); |
@@ -800,7 +810,8 @@ TEST_F(ViewTest, PaintContainsChildrenInRTL) { |
EXPECT_FALSE(v1->did_paint_); |
EXPECT_FALSE(v2->did_paint_); |
- root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); |
+ root_view->Paint(PaintInfo::CreateRootPaintInfo( |
+ ui::PaintContext(list.get(), 1.f, paint_area, false), root_view->size())); |
EXPECT_TRUE(v1->did_paint_); |
EXPECT_TRUE(v2->did_paint_); |
} |
@@ -821,7 +832,9 @@ TEST_F(ViewTest, PaintIntersectsChildren) { |
// invalidation. |
gfx::Rect first_paint(1, 1); |
auto list = base::MakeRefCounted<cc::DisplayItemList>(); |
- root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint)); |
+ root_view->Paint(PaintInfo::CreateRootPaintInfo( |
+ ui::PaintContext(list.get(), 1.f, first_paint, false), |
+ root_view->size())); |
v1->Reset(); |
v2->Reset(); |
@@ -831,7 +844,8 @@ TEST_F(ViewTest, PaintIntersectsChildren) { |
EXPECT_FALSE(v1->did_paint_); |
EXPECT_FALSE(v2->did_paint_); |
- root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); |
+ root_view->Paint(PaintInfo::CreateRootPaintInfo( |
+ ui::PaintContext(list.get(), 1.f, paint_area, false), root_view->size())); |
EXPECT_TRUE(v1->did_paint_); |
EXPECT_TRUE(v2->did_paint_); |
} |
@@ -864,7 +878,9 @@ TEST_F(ViewTest, PaintIntersectsChildrenInRTL) { |
// invalidation. |
gfx::Rect first_paint(1, 1); |
auto list = base::MakeRefCounted<cc::DisplayItemList>(); |
- root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint)); |
+ root_view->Paint(PaintInfo::CreateRootPaintInfo( |
+ ui::PaintContext(list.get(), 1.f, first_paint, false), |
+ root_view->size())); |
v1->Reset(); |
v2->Reset(); |
@@ -874,7 +890,8 @@ TEST_F(ViewTest, PaintIntersectsChildrenInRTL) { |
EXPECT_FALSE(v1->did_paint_); |
EXPECT_FALSE(v2->did_paint_); |
- root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); |
+ root_view->Paint(PaintInfo::CreateRootPaintInfo( |
+ ui::PaintContext(list.get(), 1.f, paint_area, false), root_view->size())); |
EXPECT_TRUE(v1->did_paint_); |
EXPECT_TRUE(v2->did_paint_); |
} |
@@ -895,7 +912,9 @@ TEST_F(ViewTest, PaintIntersectsChildButNotGrandChild) { |
// invalidation. |
gfx::Rect first_paint(1, 1); |
auto list = base::MakeRefCounted<cc::DisplayItemList>(); |
- root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint)); |
+ root_view->Paint(PaintInfo::CreateRootPaintInfo( |
+ ui::PaintContext(list.get(), 1.f, first_paint, false), |
+ root_view->size())); |
v1->Reset(); |
v2->Reset(); |
@@ -905,7 +924,8 @@ TEST_F(ViewTest, PaintIntersectsChildButNotGrandChild) { |
EXPECT_FALSE(v1->did_paint_); |
EXPECT_FALSE(v2->did_paint_); |
- root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); |
+ root_view->Paint(PaintInfo::CreateRootPaintInfo( |
+ ui::PaintContext(list.get(), 1.f, paint_area, false), root_view->size())); |
EXPECT_TRUE(v1->did_paint_); |
EXPECT_FALSE(v2->did_paint_); |
} |
@@ -938,7 +958,9 @@ TEST_F(ViewTest, PaintIntersectsChildButNotGrandChildInRTL) { |
// invalidation. |
gfx::Rect first_paint(1, 1); |
auto list = base::MakeRefCounted<cc::DisplayItemList>(); |
- root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint)); |
+ root_view->Paint(PaintInfo::CreateRootPaintInfo( |
+ ui::PaintContext(list.get(), 1.f, first_paint, false), |
+ root_view->size())); |
v1->Reset(); |
v2->Reset(); |
@@ -948,7 +970,8 @@ TEST_F(ViewTest, PaintIntersectsChildButNotGrandChildInRTL) { |
EXPECT_FALSE(v1->did_paint_); |
EXPECT_FALSE(v2->did_paint_); |
- root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); |
+ root_view->Paint(PaintInfo::CreateRootPaintInfo( |
+ ui::PaintContext(list.get(), 1.f, paint_area, false), root_view->size())); |
EXPECT_TRUE(v1->did_paint_); |
EXPECT_FALSE(v2->did_paint_); |
} |
@@ -969,7 +992,9 @@ TEST_F(ViewTest, PaintIntersectsNoChildren) { |
// invalidation. |
gfx::Rect first_paint(1, 1); |
auto list = base::MakeRefCounted<cc::DisplayItemList>(); |
- root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint)); |
+ root_view->Paint(PaintInfo::CreateRootPaintInfo( |
+ ui::PaintContext(list.get(), 1.f, first_paint, false), |
+ root_view->size())); |
v1->Reset(); |
v2->Reset(); |
@@ -979,7 +1004,8 @@ TEST_F(ViewTest, PaintIntersectsNoChildren) { |
EXPECT_FALSE(v1->did_paint_); |
EXPECT_FALSE(v2->did_paint_); |
- root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); |
+ root_view->Paint(PaintInfo::CreateRootPaintInfo( |
+ ui::PaintContext(list.get(), 1.f, paint_area, false), root_view->size())); |
EXPECT_FALSE(v1->did_paint_); |
EXPECT_FALSE(v2->did_paint_); |
} |
@@ -1012,7 +1038,9 @@ TEST_F(ViewTest, PaintIntersectsNoChildrenInRTL) { |
// invalidation. |
gfx::Rect first_paint(1, 1); |
auto list = base::MakeRefCounted<cc::DisplayItemList>(); |
- root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint)); |
+ root_view->Paint(PaintInfo::CreateRootPaintInfo( |
+ ui::PaintContext(list.get(), 1.f, first_paint, false), |
+ root_view->size())); |
v1->Reset(); |
v2->Reset(); |
@@ -1022,7 +1050,8 @@ TEST_F(ViewTest, PaintIntersectsNoChildrenInRTL) { |
EXPECT_FALSE(v1->did_paint_); |
EXPECT_FALSE(v2->did_paint_); |
- root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); |
+ root_view->Paint(PaintInfo::CreateRootPaintInfo( |
+ ui::PaintContext(list.get(), 1.f, paint_area, false), root_view->size())); |
EXPECT_FALSE(v1->did_paint_); |
EXPECT_FALSE(v2->did_paint_); |
} |
@@ -1043,7 +1072,9 @@ TEST_F(ViewTest, PaintIntersectsOneChild) { |
// invalidation. |
gfx::Rect first_paint(1, 1); |
auto list = base::MakeRefCounted<cc::DisplayItemList>(); |
- root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint)); |
+ root_view->Paint(PaintInfo::CreateRootPaintInfo( |
+ ui::PaintContext(list.get(), 1.f, first_paint, false), |
+ root_view->size())); |
v1->Reset(); |
v2->Reset(); |
@@ -1054,7 +1085,8 @@ TEST_F(ViewTest, PaintIntersectsOneChild) { |
EXPECT_FALSE(v1->did_paint_); |
EXPECT_FALSE(v2->did_paint_); |
- root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); |
+ root_view->Paint(PaintInfo::CreateRootPaintInfo( |
+ ui::PaintContext(list.get(), 1.f, paint_area, false), root_view->size())); |
EXPECT_FALSE(v1->did_paint_); |
EXPECT_TRUE(v2->did_paint_); |
@@ -1065,7 +1097,8 @@ TEST_F(ViewTest, PaintIntersectsOneChild) { |
v2->Reset(); |
EXPECT_FALSE(v1->did_paint_); |
EXPECT_FALSE(v2->did_paint_); |
- root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); |
+ root_view->Paint(PaintInfo::CreateRootPaintInfo( |
+ ui::PaintContext(list.get(), 1.f, paint_area, false), root_view->size())); |
EXPECT_TRUE(v1->did_paint_); |
EXPECT_FALSE(v2->did_paint_); |
} |
@@ -1098,7 +1131,9 @@ TEST_F(ViewTest, PaintIntersectsOneChildInRTL) { |
// invalidation. |
gfx::Rect first_paint(1, 1); |
auto list = base::MakeRefCounted<cc::DisplayItemList>(); |
- root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint)); |
+ root_view->Paint(PaintInfo::CreateRootPaintInfo( |
+ ui::PaintContext(list.get(), 1.f, first_paint, false), |
+ root_view->size())); |
v1->Reset(); |
v2->Reset(); |
@@ -1109,7 +1144,8 @@ TEST_F(ViewTest, PaintIntersectsOneChildInRTL) { |
EXPECT_FALSE(v1->did_paint_); |
EXPECT_FALSE(v2->did_paint_); |
- root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); |
+ root_view->Paint(PaintInfo::CreateRootPaintInfo( |
+ ui::PaintContext(list.get(), 1.f, paint_area, false), root_view->size())); |
EXPECT_TRUE(v1->did_paint_); |
EXPECT_FALSE(v2->did_paint_); |
@@ -1120,7 +1156,8 @@ TEST_F(ViewTest, PaintIntersectsOneChildInRTL) { |
v2->Reset(); |
EXPECT_FALSE(v1->did_paint_); |
EXPECT_FALSE(v2->did_paint_); |
- root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); |
+ root_view->Paint(PaintInfo::CreateRootPaintInfo( |
+ ui::PaintContext(list.get(), 1.f, paint_area, false), root_view->size())); |
EXPECT_FALSE(v1->did_paint_); |
EXPECT_TRUE(v2->did_paint_); |
} |
@@ -1142,7 +1179,8 @@ TEST_F(ViewTest, PaintInPromotedToLayer) { |
// invalidation. |
gfx::Rect first_paint(1, 1); |
auto list = base::MakeRefCounted<cc::DisplayItemList>(); |
- v1->Paint(ui::PaintContext(list.get(), 1.f, first_paint)); |
+ v1->Paint(PaintInfo::CreateRootPaintInfo( |
+ ui::PaintContext(list.get(), 1.f, first_paint, false), v1->size())); |
v1->Reset(); |
v2->Reset(); |
@@ -1152,7 +1190,9 @@ TEST_F(ViewTest, PaintInPromotedToLayer) { |
auto list = base::MakeRefCounted<cc::DisplayItemList>(); |
// The promoted views are not painted as they are separate paint roots. |
- root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); |
+ root_view->Paint(PaintInfo::CreateRootPaintInfo( |
+ ui::PaintContext(list.get(), 1.f, paint_area, false), |
+ root_view->size())); |
EXPECT_FALSE(v1->did_paint_); |
EXPECT_FALSE(v2->did_paint_); |
} |
@@ -1164,7 +1204,8 @@ TEST_F(ViewTest, PaintInPromotedToLayer) { |
// The |v1| view is painted. If it used its offset incorrect, it would think |
// its at (10,11) instead of at (0,0) since it is the paint root. |
- v1->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); |
+ v1->Paint(PaintInfo::CreateRootPaintInfo( |
+ ui::PaintContext(list.get(), 1.f, paint_area, false), v1->size())); |
EXPECT_TRUE(v1->did_paint_); |
EXPECT_FALSE(v2->did_paint_); |
} |
@@ -1178,7 +1219,8 @@ TEST_F(ViewTest, PaintInPromotedToLayer) { |
// The |v2| view is painted also. If it used its offset incorrect, it would |
// think its at (13,15) instead of at (3,4) since |v1| is the paint root. |
- v1->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); |
+ v1->Paint(PaintInfo::CreateRootPaintInfo( |
+ ui::PaintContext(list.get(), 1.f, paint_area, false), v1->size())); |
EXPECT_TRUE(v1->did_paint_); |
EXPECT_TRUE(v2->did_paint_); |
} |
@@ -1221,9 +1263,9 @@ TEST_F(ViewTest, PaintLocalBounds) { |
EXPECT_EQ(gfx::Rect(0, 1000, 100, 100), v1->GetVisibleBounds()); |
auto list = base::MakeRefCounted<cc::DisplayItemList>(); |
- ui::PaintContext context(list.get(), 1.f, gfx::Rect()); |
+ ui::PaintContext context(list.get(), 1.f, gfx::Rect(), false); |
- v1->Paint(context); |
+ v1->Paint(PaintInfo::CreateRootPaintInfo(context, gfx::Size())); |
EXPECT_TRUE(v1->did_paint_); |
// Check that the canvas produced by |v1| for paint contains all of |v1|'s |