summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-20 20:00:30 +0000
committerpkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-20 20:00:30 +0000
commitedca205868de864a21b709b402e772ecceb4ea08 (patch)
tree26ee48728439cf17d1201d96acdb4784c578f8bd
parent56fd031b4934cc5033fa8e7b93ffa194680422b0 (diff)
downloadchromium_src-edca205868de864a21b709b402e772ecceb4ea08.zip
chromium_src-edca205868de864a21b709b402e772ecceb4ea08.tar.gz
chromium_src-edca205868de864a21b709b402e772ecceb4ea08.tar.bz2
Fixes hole bounds
The hole bounds are with respect to the bounds of the parent. Thus they should be intersected with a representation of the bounds of the parent in terms of the parent BUG= None TEST= None Review URL: http://codereview.chromium.org/8356017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@106551 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ui/gfx/compositor/layer.cc2
-rw-r--r--ui/gfx/compositor/layer_unittest.cc11
2 files changed, 12 insertions, 1 deletions
diff --git a/ui/gfx/compositor/layer.cc b/ui/gfx/compositor/layer.cc
index 34444ec..c094b1e 100644
--- a/ui/gfx/compositor/layer.cc
+++ b/ui/gfx/compositor/layer.cc
@@ -347,7 +347,7 @@ void Layer::RecomputeHole() {
// This layer might not contain the child (e.g., a portion of the child may
// be offscreen). Only the portion of the child that overlaps this layer is
// of any importance, so take the intersection.
- candidate_hole = bounds().Intersect(candidate_hole);
+ candidate_hole = gfx::Rect(bounds().size()).Intersect(candidate_hole);
// Ensure we have the largest hole.
if (candidate_hole.size().GetArea() > hole_rect_.size().GetArea())
diff --git a/ui/gfx/compositor/layer_unittest.cc b/ui/gfx/compositor/layer_unittest.cc
index bb05c0b..6c5efb7 100644
--- a/ui/gfx/compositor/layer_unittest.cc
+++ b/ui/gfx/compositor/layer_unittest.cc
@@ -529,6 +529,17 @@ TEST_F(LayerWithNullDelegateTest, LargestHole) {
EXPECT_EQ(gfx::Rect(75, 75, 200, 200), parent->hole_rect());
}
+// Verifies that the hole is with respect to the local bounds of its parent.
+TEST_F(LayerWithNullDelegateTest, HoleLocalBounds) {
+ scoped_ptr<Layer> parent(CreateTextureRootLayer(
+ gfx::Rect(100, 100, 150, 150)));
+
+ scoped_ptr<Layer> child(CreateTextureLayer(gfx::Rect(50, 50, 100, 100)));
+ parent->Add(child.get());
+
+ EXPECT_EQ(gfx::Rect(50, 50, 100, 100), parent->hole_rect());
+}
+
// Verifies that there is no hole present when one of the child layers has a
// transform.
TEST_F(LayerWithNullDelegateTest, NoHoleWithTransform) {