Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "pdf/paint_manager.h" | 5 #include "pdf/paint_manager.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 134 | 134 |
| 135 void PaintManager::Invalidate() { | 135 void PaintManager::Invalidate() { |
| 136 if (graphics_.is_null() && !has_pending_resize_) | 136 if (graphics_.is_null() && !has_pending_resize_) |
| 137 return; | 137 return; |
| 138 | 138 |
| 139 EnsureCallbackPending(); | 139 EnsureCallbackPending(); |
| 140 aggregator_.InvalidateRect(pp::Rect(GetEffectiveSize())); | 140 aggregator_.InvalidateRect(pp::Rect(GetEffectiveSize())); |
| 141 } | 141 } |
| 142 | 142 |
| 143 void PaintManager::InvalidateRect(const pp::Rect& rect) { | 143 void PaintManager::InvalidateRect(const pp::Rect& rect) { |
| 144 DCHECK(!in_paint_); | 144 // Note, we can't DCHECK(!in_paint_) here because javascript inside the |
|
Tom Sepez
2017/01/19 17:43:37
Do we just want to no-op it in this special case?
dsinclair
2017/01/19 18:56:10
I don't know. My concern when I did this originall
| |
| 145 | 145 // PDF can trigger at any point. So, while we're attempting to paint it's |
| 146 // possible for the JS to trigger and cause an invalidation. | |
| 146 if (graphics_.is_null() && !has_pending_resize_) | 147 if (graphics_.is_null() && !has_pending_resize_) |
| 147 return; | 148 return; |
| 148 | 149 |
| 149 // Clip the rect to the device area. | 150 // Clip the rect to the device area. |
| 150 pp::Rect clipped_rect = rect.Intersect(pp::Rect(GetEffectiveSize())); | 151 pp::Rect clipped_rect = rect.Intersect(pp::Rect(GetEffectiveSize())); |
| 151 if (clipped_rect.IsEmpty()) | 152 if (clipped_rect.IsEmpty()) |
| 152 return; // Nothing to do. | 153 return; // Nothing to do. |
| 153 | 154 |
| 154 EnsureCallbackPending(); | 155 if (!in_paint_) |
| 156 EnsureCallbackPending(); | |
| 155 aggregator_.InvalidateRect(clipped_rect); | 157 aggregator_.InvalidateRect(clipped_rect); |
| 156 } | 158 } |
| 157 | 159 |
| 158 void PaintManager::ScrollRect(const pp::Rect& clip_rect, | 160 void PaintManager::ScrollRect(const pp::Rect& clip_rect, |
| 159 const pp::Point& amount) { | 161 const pp::Point& amount) { |
| 160 DCHECK(!in_paint_); | 162 DCHECK(!in_paint_); |
| 161 | 163 |
| 162 if (graphics_.is_null() && !has_pending_resize_) | 164 if (graphics_.is_null() && !has_pending_resize_) |
| 163 return; | 165 return; |
| 164 | 166 |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 339 DCHECK(manual_callback_pending_); | 341 DCHECK(manual_callback_pending_); |
| 340 manual_callback_pending_ = false; | 342 manual_callback_pending_ = false; |
| 341 | 343 |
| 342 // Just because we have a manual callback doesn't mean there are actually any | 344 // Just because we have a manual callback doesn't mean there are actually any |
| 343 // invalid regions. Even though we only schedule this callback when something | 345 // invalid regions. Even though we only schedule this callback when something |
| 344 // is pending, a Flush callback could have come in before this callback was | 346 // is pending, a Flush callback could have come in before this callback was |
| 345 // executed and that could have cleared the queue. | 347 // executed and that could have cleared the queue. |
| 346 if (aggregator_.HasPendingUpdate()) | 348 if (aggregator_.HasPendingUpdate()) |
| 347 DoPaint(); | 349 DoPaint(); |
| 348 } | 350 } |
| OLD | NEW |