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

Side by Side Diff: ui/webui/resources/js/util.js

Issue 1056213003: Add 2.0 for win/linux as they now supports high dpi (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698