Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 <include src="../../../../ui/webui/resources/js/util.js"> | 7 <include src="../../../../ui/webui/resources/js/util.js"> |
| 8 <include src="open_pdf_params_parser.js"> | 8 <include src="open_pdf_params_parser.js"> |
| 9 <include src="pdf_scripting_api.js"> | 9 <include src="pdf_scripting_api.js"> |
| 10 <include src="viewport.js"> | 10 <include src="viewport.js"> |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 162 | 162 |
| 163 PDFViewer.prototype = { | 163 PDFViewer.prototype = { |
| 164 /** | 164 /** |
| 165 * @private | 165 * @private |
| 166 * Handle key events. These may come from the user directly or via the | 166 * Handle key events. These may come from the user directly or via the |
| 167 * scripting API. | 167 * scripting API. |
| 168 * @param {KeyboardEvent} e the event to handle. | 168 * @param {KeyboardEvent} e the event to handle. |
| 169 */ | 169 */ |
| 170 handleKeyEvent_: function(e) { | 170 handleKeyEvent_: function(e) { |
| 171 var position = this.viewport_.position; | 171 var position = this.viewport_.position; |
| 172 var viewport = this.viewport_; | |
|
raymes
2014/09/15 00:12:14
nit: remove this line and just add ".bind(this) be
Nikhil
2014/09/16 10:23:29
Done.
| |
| 172 // Certain scroll events may be sent from outside of the extension. | 173 // Certain scroll events may be sent from outside of the extension. |
| 173 var fromScriptingAPI = e.type == 'scriptingKeypress'; | 174 var fromScriptingAPI = e.type == 'scriptingKeypress'; |
| 174 | 175 |
| 175 var pageUpHandler = function() { | 176 var pageUpHandler = function() { |
| 176 // Go to the previous page if we are fit-to-page. | 177 // Go to the previous page if we are fit-to-page. |
| 177 if (this.viewport_.fittingType == Viewport.FittingType.FIT_TO_PAGE) { | 178 if (viewport.fittingType == Viewport.FittingType.FIT_TO_PAGE) { |
| 178 this.viewport_.goToPage(this.viewport_.getMostVisiblePage() - 1); | 179 viewport.goToPage(viewport.getMostVisiblePage() - 1); |
| 179 // Since we do the movement of the page. | 180 // Since we do the movement of the page. |
| 180 e.preventDefault(); | 181 e.preventDefault(); |
| 181 } else if (fromScriptingAPI) { | 182 } else if (fromScriptingAPI) { |
| 182 position.y -= this.viewport.size.height; | 183 position.y -= this.viewport.size.height; |
| 183 this.viewport.position = position; | 184 this.viewport.position = position; |
| 184 } | 185 } |
| 185 }; | 186 }; |
|
raymes
2014/09/15 00:12:14
}.bind(this);
Nikhil
2014/09/16 10:23:29
Done.
| |
| 186 var pageDownHandler = function() { | 187 var pageDownHandler = function() { |
| 187 // Go to the next page if we are fit-to-page. | 188 // Go to the next page if we are fit-to-page. |
| 188 if (this.viewport_.fittingType == Viewport.FittingType.FIT_TO_PAGE) { | 189 if (viewport.fittingType == Viewport.FittingType.FIT_TO_PAGE) { |
| 189 this.viewport_.goToPage(this.viewport_.getMostVisiblePage() + 1); | 190 viewport.goToPage(viewport.getMostVisiblePage() + 1); |
| 190 // Since we do the movement of the page. | 191 // Since we do the movement of the page. |
| 191 e.preventDefault(); | 192 e.preventDefault(); |
| 192 } else if (fromScriptingAPI) { | 193 } else if (fromScriptingAPI) { |
| 193 position.y += this.viewport.size.height; | 194 position.y += this.viewport.size.height; |
| 194 this.viewport.position = position; | 195 this.viewport.position = position; |
| 195 } | 196 } |
| 196 }; | 197 }; |
|
raymes
2014/09/15 00:12:14
}.bind(this);
Nikhil
2014/09/16 10:23:29
Done.
| |
| 197 | 198 |
| 198 switch (e.keyCode) { | 199 switch (e.keyCode) { |
| 199 case 32: // Space key. | 200 case 32: // Space key. |
| 200 if (e.shiftKey) | 201 if (e.shiftKey) |
| 201 pageUpHandler(); | 202 pageUpHandler(); |
| 202 else | 203 else |
| 203 pageDownHandler(); | 204 pageDownHandler(); |
| 204 return; | 205 return; |
| 205 case 33: // Page up key. | 206 case 33: // Page up key. |
| 206 pageUpHandler(); | 207 pageUpHandler(); |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 568 | 569 |
| 569 /** | 570 /** |
| 570 * @type {Viewport} the viewport of the PDF viewer. | 571 * @type {Viewport} the viewport of the PDF viewer. |
| 571 */ | 572 */ |
| 572 get viewport() { | 573 get viewport() { |
| 573 return this.viewport_; | 574 return this.viewport_; |
| 574 } | 575 } |
| 575 }; | 576 }; |
| 576 | 577 |
| 577 var viewer = new PDFViewer(); | 578 var viewer = new PDFViewer(); |
| OLD | NEW |