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 |