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

Unified Diff: chrome/browser/resources/pdf/pdf.js

Issue 347763007: Improve scrolling performance in OOP PDF (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 | chrome/browser/resources/pdf/viewport.js » ('j') | pdf/out_of_process_instance.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/pdf/pdf.js
diff --git a/chrome/browser/resources/pdf/pdf.js b/chrome/browser/resources/pdf/pdf.js
index 60384e5db6e1fe6a49a7d6fd4bac41e6c537691f..976c2f649a1ac27aa6c8a79627bae3683ccdc57e 100644
--- a/chrome/browser/resources/pdf/pdf.js
+++ b/chrome/browser/resources/pdf/pdf.js
@@ -52,7 +52,9 @@ function PDFViewer() {
// Create the viewport.
this.viewport_ = new Viewport(window,
this.sizer_,
- this.viewportChangedCallback_.bind(this),
+ this.viewportChanged_.bind(this),
+ this.beforeZoom_.bind(this),
+ this.afterZoom_.bind(this),
getScrollbarWidth());
// Create the plugin object dynamically so we can set its src. The plugin
@@ -353,9 +355,36 @@ PDFViewer.prototype = {
/**
* @private
- * A callback that's called when the viewport changes.
+ * A callback that's called before the zoom changes. Notify the plugin to stop
+ * reacting to scroll events while zoom is taking place to avoid flickering.
*/
- viewportChangedCallback_: function() {
+ beforeZoom_: function() {
+ this.plugin_.postMessage({
+ type: 'stopScrolling'
+ });
+ },
+
+ /**
+ * @private
+ * A callback that's called after the zoom changes. Notify the plugin of the
+ * zoom change and to continue reacting to scroll events.
+ */
+ afterZoom_: function() {
+ var position = this.viewport_.position;
+ var zoom = this.viewport_.zoom;
+ this.plugin_.postMessage({
+ type: 'viewport',
+ zoom: zoom,
+ xOffset: position.x,
+ yOffset: position.y
+ });
+ },
+
+ /**
+ * @private
+ * A callback that's called after the viewport changes.
+ */
+ viewportChanged_: function() {
if (!this.documentDimensions_)
return;
@@ -391,16 +420,6 @@ PDFViewer.prototype = {
this.pageIndicator_.style.visibility = 'hidden';
}
- var position = this.viewport_.position;
- var zoom = this.viewport_.zoom;
- // Notify the plugin of the viewport change.
- this.plugin_.postMessage({
- type: 'viewport',
- zoom: zoom,
- xOffset: position.x,
- yOffset: position.y
- });
-
var visiblePageDimensions = this.viewport_.getPageScreenRect(visiblePage);
var size = this.viewport_.size;
this.sendScriptingMessage_({
« no previous file with comments | « no previous file | chrome/browser/resources/pdf/viewport.js » ('j') | pdf/out_of_process_instance.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698