Chromium Code Reviews| Index: pdf/paint_aggregator.cc |
| diff --git a/pdf/paint_aggregator.cc b/pdf/paint_aggregator.cc |
| index 549cab6d091646a783f52ccafeae94c4cbf12cff..363749347a24dd5f58b546b3562aa233f5d8ce93 100644 |
| --- a/pdf/paint_aggregator.cc |
| +++ b/pdf/paint_aggregator.cc |
| @@ -8,6 +8,15 @@ |
| #include "base/logging.h" |
| +namespace { |
| + |
| +// We don't use std::sign here to avoid any issues with negative 0. |
|
Sam McNally
2015/06/02 03:29:26
Don't pp:Points contain ints?
|
| +int32_t sign(int32_t num) { |
|
Sam McNally
2015/06/02 03:29:26
How about
bool IsNegative(int32_t num) { return nu
raymes
2015/06/02 06:57:08
Done.
|
| + return num < 0 ? -1 : 1; |
| +} |
| + |
| +} // namespace |
| + |
| // ---------------------------------------------------------------------------- |
| // ALGORITHM NOTES |
| // |
| @@ -145,6 +154,25 @@ void PaintAggregator::ScrollRect(const pp::Rect& clip_rect, |
| return; |
| } |
| + // If we scroll in a reverse direction to the direction we originally scrolled |
| + // and there were invalidations that happened in-between we may end up |
| + // incorrectly clipping the invalidated rects (see crbug.com/488390). This bug |
| + // doesn't exist in the original implementation |
| + // (ppapi/utility/graphics/paint_aggregator.cc) which uses a different method |
| + // of handling invalidations that occur after a scroll. The problem is that |
| + // when we scroll the invalidated region, we clip it to the scroll rect. This |
| + // can cause us to lose information about what the invalidated region was if |
| + // it gets scrolled back into view. We either need to not do this clipping or |
| + // disallow combining scrolls that occur in different directions with |
| + // invalidations that happen in-between. This code really needs some tests... |
| + if (!update_.paint_rects.empty()) { |
| + if (sign(amount.x()) != sign(update_.scroll_delta.x()) || |
| + sign(amount.y()) != sign(update_.scroll_delta.y())) { |
| + InvalidateRect(clip_rect); |
| + return; |
| + } |
| + } |
| + |
| // The scroll rect is new or isn't changing (though the scroll amount may |
| // be changing). |
| update_.scroll_rect = clip_rect; |