diff options
author | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-11 00:24:28 +0000 |
---|---|---|
committer | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-11 00:24:28 +0000 |
commit | 2936ac28c737283ec9b0ada0b84daffc810293ac (patch) | |
tree | d55637b4fed97c9d94f2a9150e202c64b74ada31 | |
parent | 028117dee12726ec5bdcd7774022d6fbfe2ade52 (diff) | |
download | chromium_src-2936ac28c737283ec9b0ada0b84daffc810293ac.zip chromium_src-2936ac28c737283ec9b0ada0b84daffc810293ac.tar.gz chromium_src-2936ac28c737283ec9b0ada0b84daffc810293ac.tar.bz2 |
Handle the case of two scroll events cancelling each other out.
R=pkasting
BUG=none
TEST=covered by unittests
Review URL: http://codereview.chromium.org/491022
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@34314 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/renderer/paint_aggregator.cc | 6 | ||||
-rw-r--r-- | chrome/renderer/paint_aggregator_unittest.cc | 15 |
2 files changed, 21 insertions, 0 deletions
diff --git a/chrome/renderer/paint_aggregator.cc b/chrome/renderer/paint_aggregator.cc index 125f7b5..c5c4405 100644 --- a/chrome/renderer/paint_aggregator.cc +++ b/chrome/renderer/paint_aggregator.cc @@ -155,6 +155,12 @@ void PaintAggregator::ScrollRect(int dx, int dy, const gfx::Rect& clip_rect) { update_.scroll_rect = clip_rect; update_.scroll_delta.Offset(dx, dy); + // We might have just wiped out a pre-existing scroll. + if (update_.scroll_delta == gfx::Point()) { + update_.scroll_rect = gfx::Rect(); + return; + } + // Adjust any contained paint rects and check for any overlapping paints. for (size_t i = 0; i < update_.paint_rects.size(); ++i) { if (update_.scroll_rect.Contains(update_.paint_rects[i])) { diff --git a/chrome/renderer/paint_aggregator_unittest.cc b/chrome/renderer/paint_aggregator_unittest.cc index be7f72a..25503c8 100644 --- a/chrome/renderer/paint_aggregator_unittest.cc +++ b/chrome/renderer/paint_aggregator_unittest.cc @@ -87,6 +87,21 @@ TEST(PaintAggregator, DoubleOverlappingScroll) { EXPECT_EQ(expected_damage, resulting_damage); } +TEST(PaintAggregator, NegatingScroll) { + PaintAggregator greg; + + // Scroll twice in opposite directions by equal amounts. The result + // should be no scrolling. + + gfx::Rect rect(1, 2, 3, 4); + gfx::Point delta1(1, 0); + gfx::Point delta2(-1, 0); + greg.ScrollRect(delta1.x(), delta1.y(), rect); + greg.ScrollRect(delta2.x(), delta2.y(), rect); + + EXPECT_FALSE(greg.HasPendingUpdate()); +} + TEST(PaintAggregator, DiagonalScroll) { PaintAggregator greg; |