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

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

Issue 865533002: Scroll while selecting Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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 | pdf/out_of_process_instance.cc » ('j') | no next file with comments »
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 735c508fdd197c0924cf7b8127f5f9d6c0eb9ee0..4924cae8ddd33528baac3270f64f83d0c18de39d 100644
--- a/chrome/browser/resources/pdf/pdf.js
+++ b/chrome/browser/resources/pdf/pdf.js
@@ -408,9 +408,40 @@ PDFViewer.prototype = {
case 'cancelStreamUrl':
chrome.streamsPrivate.abort(this.streamDetails_.streamUrl);
break;
+ case 'isSelecting':
+ if (message.data.isSelecting == this.isSelecting_)
+ break;
+ this.isSelecting_ = message.data.isSelecting_;
+ if (this.isSelecting_) {
+ this.plugin_.addEventListener('mousemove',
+ selectionDragListener,
+ false);
+ } else {
+ this.plugin_.removeEventListener('mousemove',
+ selectionDragListener,
+ false);
+ }
+ break;
}
},
+ getDragScrollVelocity_: function(pos, max_pos) {
+ // This gives a higher velocity as the pos approaches 0 or max_pos.
+ var velocity = Math.abs(ACCEL_COEFFICIENT * pos - (max_pos / 2));
+ // This gives a range in which there is no velocity for the given pos.
+ velocity -= DRAG_START_COEFFICIENT;
+ // Bound the velocity between 0 and MAX_VELOCITY.
+ velocity = Math.max(0, min(MAX_VELOCITY, velocity));
+ }
+
+ selectionDragListener_: function(event) {
+ var relative_x = event.x - this.plugin_.clientLeft;
+ var relative_y = event.y - this.plugin_.clientTop;
+ var x_velocity = this.getDragScrollVelocity_(relative_x, this.plugin_.width);
+ var y_velocity = this.getDragScrollVelocity_(relative_y, this.plugin_.height);
+ if (event.x )
+ },
+
/**
* @private
* A callback that's called before the zoom changes. Notify the plugin to stop
« no previous file with comments | « no previous file | pdf/out_of_process_instance.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698