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

Side by Side Diff: chrome/browser/resources/pdf/open_pdf_params_parser.js

Issue 2617663002: WIP: run clang-format-js on lots of things (Closed)
Patch Set: merge Created 3 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 | « chrome/browser/resources/pdf/navigator.js ('k') | chrome/browser/resources/pdf/pdf.js » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 * Creates a new OpenPDFParamsParser. This parses the open pdf parameters 8 * Creates a new OpenPDFParamsParser. This parses the open pdf parameters
9 * passed in the url to set initial viewport settings for opening the pdf. 9 * passed in the url to set initial viewport settings for opening the pdf.
10 * @param {Object} getNamedDestinationsFunction The function called to fetch 10 * @param {Object} getNamedDestinationsFunction The function called to fetch
(...skipping 23 matching lines...) Expand all
34 if (isNaN(zoomFactor)) 34 if (isNaN(zoomFactor))
35 return; 35 return;
36 36
37 // Handle #zoom=scale. 37 // Handle #zoom=scale.
38 if (paramValueSplit.length == 1) { 38 if (paramValueSplit.length == 1) {
39 viewportPosition['zoom'] = zoomFactor; 39 viewportPosition['zoom'] = zoomFactor;
40 return; 40 return;
41 } 41 }
42 42
43 // Handle #zoom=scale,left,top. 43 // Handle #zoom=scale,left,top.
44 var position = {x: parseFloat(paramValueSplit[1]), 44 var position = {
45 y: parseFloat(paramValueSplit[2])}; 45 x: parseFloat(paramValueSplit[1]),
46 y: parseFloat(paramValueSplit[2])
47 };
46 viewportPosition['position'] = position; 48 viewportPosition['position'] = position;
47 viewportPosition['zoom'] = zoomFactor; 49 viewportPosition['zoom'] = zoomFactor;
48 }, 50 },
49 51
50 /** 52 /**
51 * Parse the parameters encoded in the fragment of a URL into a dictionary. 53 * Parse the parameters encoded in the fragment of a URL into a dictionary.
52 * @private 54 * @private
53 * @param {string} url to parse 55 * @param {string} url to parse
54 * @return {Object} Key-value pairs of URL parameters 56 * @return {Object} Key-value pairs of URL parameters
55 */ 57 */
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 var pageNumber = parseInt(paramsDictionary['page']); 117 var pageNumber = parseInt(paramsDictionary['page']);
116 if (!isNaN(pageNumber) && pageNumber > 0) 118 if (!isNaN(pageNumber) && pageNumber > 0)
117 viewportPosition['page'] = pageNumber - 1; 119 viewportPosition['page'] = pageNumber - 1;
118 } 120 }
119 121
120 if ('zoom' in paramsDictionary) 122 if ('zoom' in paramsDictionary)
121 this.parseZoomParam_(paramsDictionary['zoom'], viewportPosition); 123 this.parseZoomParam_(paramsDictionary['zoom'], viewportPosition);
122 124
123 if (viewportPosition.page === undefined && 125 if (viewportPosition.page === undefined &&
124 'nameddest' in paramsDictionary) { 126 'nameddest' in paramsDictionary) {
125 this.outstandingRequests_.push({ 127 this.outstandingRequests_.push(
126 callback: callback, 128 {callback: callback, viewportPosition: viewportPosition});
127 viewportPosition: viewportPosition
128 });
129 this.getNamedDestinationsFunction_(paramsDictionary['nameddest']); 129 this.getNamedDestinationsFunction_(paramsDictionary['nameddest']);
130 } else { 130 } else {
131 callback(viewportPosition); 131 callback(viewportPosition);
132 } 132 }
133 }, 133 },
134 134
135 /** 135 /**
136 * This is called when a named destination is received and the page number 136 * This is called when a named destination is received and the page number
137 * corresponding to the request for which a named destination is passed. 137 * corresponding to the request for which a named destination is passed.
138 * @param {number} pageNumber The page corresponding to the named destination 138 * @param {number} pageNumber The page corresponding to the named destination
139 * requested. 139 * requested.
140 */ 140 */
141 onNamedDestinationReceived: function(pageNumber) { 141 onNamedDestinationReceived: function(pageNumber) {
142 var outstandingRequest = this.outstandingRequests_.shift(); 142 var outstandingRequest = this.outstandingRequests_.shift();
143 if (pageNumber != -1) 143 if (pageNumber != -1)
144 outstandingRequest.viewportPosition.page = pageNumber; 144 outstandingRequest.viewportPosition.page = pageNumber;
145 outstandingRequest.callback(outstandingRequest.viewportPosition); 145 outstandingRequest.callback(outstandingRequest.viewportPosition);
146 }, 146 },
147 }; 147 };
OLDNEW
« no previous file with comments | « chrome/browser/resources/pdf/navigator.js ('k') | chrome/browser/resources/pdf/pdf.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698