Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Unified Diff: pdf/paint_manager.cc

Issue 337443002: Fix min threshhold calculation for resizing the PDF graphics context (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pdf/paint_manager.cc
diff --git a/pdf/paint_manager.cc b/pdf/paint_manager.cc
index 093e0cd3e9972861cef225ad204bd8511802b0c6..f452b37186e9765ef7f65d37ef629eb5a298a340 100644
--- a/pdf/paint_manager.cc
+++ b/pdf/paint_manager.cc
@@ -41,15 +41,21 @@ PaintManager::~PaintManager() {
// static
pp::Size PaintManager::GetNewContextSize(const pp::Size& current_context_size,
const pp::Size& plugin_size) {
- // The number of additional space in pixels to allocate to the right/bottom
- // of the context.
- const int kBufferSize = 100;
+ // The amount of additional space in pixels to allocate to the right/bottom of
+ // the context.
+ const int kBufferSize = 50;
// Default to returning the same size.
pp::Size result = current_context_size;
- pp::Size min_size(std::max(current_context_size.width() - kBufferSize, 0),
- std::max(current_context_size.height() - kBufferSize, 0));
+ // The minimum size of the plugin before resizing the context to ensure we
+ // aren't wasting too much memory. We deduct twice the kBufferSize from the
+ // current context size which gives a threshhold that is kBufferSize below
+ // the plugin size when the context size was last computed.
+ pp::Size min_size(
+ std::max(current_context_size.width() - 2 * kBufferSize, 0),
+ std::max(current_context_size.height() - 2 * kBufferSize, 0));
+
// If the plugin size is bigger than the current context size, we need to
// resize the context. If the plugin size is smaller than the current
// context size by a given threshhold then resize the context so that we
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698