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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | pdf/out_of_process_instance.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 'use strict'; 5 'use strict';
6 6
7 /** 7 /**
8 * @return {number} Width of a scrollbar in pixels 8 * @return {number} Width of a scrollbar in pixels
9 */ 9 */
10 function getScrollbarWidth() { 10 function getScrollbarWidth() {
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 break; 401 break;
402 case 'setTranslatedStrings': 402 case 'setTranslatedStrings':
403 this.passwordScreen_.text = message.data.getPasswordString; 403 this.passwordScreen_.text = message.data.getPasswordString;
404 this.progressBar_.text = message.data.loadingString; 404 this.progressBar_.text = message.data.loadingString;
405 this.progressBar_.style.visibility = 'visible'; 405 this.progressBar_.style.visibility = 'visible';
406 this.errorScreen_.text = message.data.loadFailedString; 406 this.errorScreen_.text = message.data.loadFailedString;
407 break; 407 break;
408 case 'cancelStreamUrl': 408 case 'cancelStreamUrl':
409 chrome.streamsPrivate.abort(this.streamDetails_.streamUrl); 409 chrome.streamsPrivate.abort(this.streamDetails_.streamUrl);
410 break; 410 break;
411 case 'isSelecting':
412 if (message.data.isSelecting == this.isSelecting_)
413 break;
414 this.isSelecting_ = message.data.isSelecting_;
415 if (this.isSelecting_) {
416 this.plugin_.addEventListener('mousemove',
417 selectionDragListener,
418 false);
419 } else {
420 this.plugin_.removeEventListener('mousemove',
421 selectionDragListener,
422 false);
423 }
424 break;
411 } 425 }
412 }, 426 },
413 427
428 getDragScrollVelocity_: function(pos, max_pos) {
429 // This gives a higher velocity as the pos approaches 0 or max_pos.
430 var velocity = Math.abs(ACCEL_COEFFICIENT * pos - (max_pos / 2));
431 // This gives a range in which there is no velocity for the given pos.
432 velocity -= DRAG_START_COEFFICIENT;
433 // Bound the velocity between 0 and MAX_VELOCITY.
434 velocity = Math.max(0, min(MAX_VELOCITY, velocity));
435 }
436
437 selectionDragListener_: function(event) {
438 var relative_x = event.x - this.plugin_.clientLeft;
439 var relative_y = event.y - this.plugin_.clientTop;
440 var x_velocity = this.getDragScrollVelocity_(relative_x, this.plugin_.width) ;
441 var y_velocity = this.getDragScrollVelocity_(relative_y, this.plugin_.height );
442 if (event.x )
443 },
444
414 /** 445 /**
415 * @private 446 * @private
416 * A callback that's called before the zoom changes. Notify the plugin to stop 447 * A callback that's called before the zoom changes. Notify the plugin to stop
417 * reacting to scroll events while zoom is taking place to avoid flickering. 448 * reacting to scroll events while zoom is taking place to avoid flickering.
418 */ 449 */
419 beforeZoom_: function() { 450 beforeZoom_: function() {
420 this.plugin_.postMessage({ 451 this.plugin_.postMessage({
421 type: 'stopScrolling' 452 type: 'stopScrolling'
422 }); 453 });
423 }, 454 },
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 this.streamDetails_.tabId != -1); 638 this.streamDetails_.tabId != -1);
608 }, 639 },
609 640
610 /** 641 /**
611 * @type {Viewport} the viewport of the PDF viewer. 642 * @type {Viewport} the viewport of the PDF viewer.
612 */ 643 */
613 get viewport() { 644 get viewport() {
614 return this.viewport_; 645 return this.viewport_;
615 } 646 }
616 }; 647 };
OLDNEW
« 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