OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // <include src="assert.js"> | 5 // <include src="assert.js"> |
6 | 6 |
7 /** | 7 /** |
8 * Alias for document.getElementById. | 8 * Alias for document.getElementById. |
9 * @param {string} id The ID of the element to find. | 9 * @param {string} id The ID of the element to find. |
10 * @return {HTMLElement} The found element or null if not found. | 10 * @return {HTMLElement} The found element or null if not found. |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 // restore | 45 // restore |
46 global[callbackName] = old; | 46 global[callbackName] = old; |
47 | 47 |
48 var args = Array.prototype.slice.call(arguments); | 48 var args = Array.prototype.slice.call(arguments); |
49 return callback.apply(global, args); | 49 return callback.apply(global, args); |
50 }; | 50 }; |
51 chrome.send(name, params); | 51 chrome.send(name, params); |
52 } | 52 } |
53 | 53 |
54 /** | 54 /** |
55 * Returns the scale factors supported by this platform. | 55 * Returns the scale factors supported by this platform for webui |
| 56 * resources. |
56 * @return {Array} The supported scale factors. | 57 * @return {Array} The supported scale factors. |
57 */ | 58 */ |
58 function getSupportedScaleFactors() { | 59 function getSupportedScaleFactors() { |
59 var supportedScaleFactors = []; | 60 var supportedScaleFactors = []; |
60 if (cr.isMac || cr.isChromeOS) { | 61 if (cr.isMac || cr.isChromeOS || cr.isWindows || cr.isLinux) { |
| 62 // All desktop platforms support zooming which also updates the |
| 63 // renderer's device scale factors (a.k.a devicePixelRatio), and |
| 64 // these platforms has high DPI assets for 2.0x. Use 1x and 2x in |
| 65 // image-set on these platforms so that the renderer can pick the |
| 66 // closest image for the current device scale factor. |
61 supportedScaleFactors.push(1); | 67 supportedScaleFactors.push(1); |
62 supportedScaleFactors.push(2); | 68 supportedScaleFactors.push(2); |
63 } else { | 69 } else { |
64 // Windows must be restarted to display at a different scale factor. | 70 // For other platforms that use fixed device scale factor, use |
| 71 // the window's device pixel ratio. |
| 72 // TODO(oshima): Investigate if Android/iOS need to use image-set. |
65 supportedScaleFactors.push(window.devicePixelRatio); | 73 supportedScaleFactors.push(window.devicePixelRatio); |
66 } | 74 } |
67 return supportedScaleFactors; | 75 return supportedScaleFactors; |
68 } | 76 } |
69 | 77 |
70 /** | 78 /** |
71 * Generates a CSS url string. | 79 * Generates a CSS url string. |
72 * @param {string} s The URL to generate the CSS url for. | 80 * @param {string} s The URL to generate the CSS url for. |
73 * @return {string} The CSS url string. | 81 * @return {string} The CSS url string. |
74 */ | 82 */ |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 * @param {number} maxLength The maximum length allowed for the string. | 455 * @param {number} maxLength The maximum length allowed for the string. |
448 * @return {string} The original string if its length does not exceed | 456 * @return {string} The original string if its length does not exceed |
449 * |maxLength|. Otherwise the first |maxLength| - 1 characters with '...' | 457 * |maxLength|. Otherwise the first |maxLength| - 1 characters with '...' |
450 * appended. | 458 * appended. |
451 */ | 459 */ |
452 function elide(original, maxLength) { | 460 function elide(original, maxLength) { |
453 if (original.length <= maxLength) | 461 if (original.length <= maxLength) |
454 return original; | 462 return original; |
455 return original.substring(0, maxLength - 1) + '\u2026'; | 463 return original.substring(0, maxLength - 1) + '\u2026'; |
456 } | 464 } |
OLD | NEW |