summaryrefslogtreecommitdiffstats
path: root/views
diff options
context:
space:
mode:
authorbacker@chromium.org <backer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-06 15:38:59 +0000
committerbacker@chromium.org <backer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-06 15:38:59 +0000
commit1d27aa53a0f4a16c8c22f764cb4fe808c318e98c (patch)
tree98ab2ccd03eb3865bb052ac639a08d4434fcd28e /views
parent8dd1f5778b67cec32b169e0a7e6558c9ca19c75c (diff)
downloadchromium_src-1d27aa53a0f4a16c8c22f764cb4fe808c318e98c.zip
chromium_src-1d27aa53a0f4a16c8c22f764cb4fe808c318e98c.tar.gz
chromium_src-1d27aa53a0f4a16c8c22f764cb4fe808c318e98c.tar.bz2
Fixed issue with layers being deleted upon SetVisible with an argument of true
Steps for Repro. From a touch build 1) Goto google.com 2) Type into text field 3) Typed text does not show up BUG=87840 TEST=views_unittest (ToggleVisibilityWithLayer) Review URL: http://codereview.chromium.org/7273067 Patch from Peter Kotwicz <pkotwicz@chromium.org>. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@91563 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r--views/view.cc8
-rw-r--r--views/view_unittest.cc19
2 files changed, 25 insertions, 2 deletions
diff --git a/views/view.cc b/views/view.cc
index 7825804..5f126a7 100644
--- a/views/view.cc
+++ b/views/view.cc
@@ -387,11 +387,15 @@ void View::SetVisible(bool visible) {
// If the tab is currently visible, schedule paint to refresh parent.
if (visible_)
SchedulePaint();
- else
- DestroyLayerRecurse();
visible_ = visible;
+ if (visible_)
+ CreateLayerIfNecessary();
+ else
+ // Destroy layer if tab is invisible as invisible tabs never paint
+ DestroyLayerRecurse();
+
// This notifies all sub-views recursively.
PropagateVisibilityNotifications(this, visible_);
diff --git a/views/view_unittest.cc b/views/view_unittest.cc
index 58a8c7a..6d8a35c 100644
--- a/views/view_unittest.cc
+++ b/views/view_unittest.cc
@@ -2599,6 +2599,25 @@ TEST_F(ViewLayerTest, ResetTransformOnLayerAfterAdd) {
EXPECT_EQ(2.0f, view->layer()->transform().matrix()[0]);
}
+// Makes sure that layer persists after toggling the visibility
+TEST_F(ViewLayerTest, ToggleVisibilityWithLayer) {
+ View* content_view = new View;
+ widget()->SetContentsView(content_view);
+
+ View* v1 = new View;
+ content_view->AddChildView(v1);
+ v1->SetPaintToLayer(true);
+
+ v1->SetVisible(true);
+ EXPECT_TRUE(v1->layer());
+
+ v1->SetVisible(false);
+ EXPECT_TRUE(v1->layer() == NULL);
+
+ v1->SetVisible(true);
+ EXPECT_TRUE(v1->layer());
+}
+
// Verifies that the complete bounds of a texture are updated if the texture
// needs to be refreshed and paint with a clip is invoked.
TEST_F(ViewLayerTest, PaintAll) {