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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/ui/UIUtils.js

Issue 2781193002: DevTools: Adopt nbsp as unit & thousands separator for broader font support (Closed)
Patch Set: update all uses of thinsp. rebaseline tests. Created 3 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 | « third_party/WebKit/Source/devtools/front_end/timeline/TimelineUIUtils.js ('k') | 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 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. 3 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
4 * Copyright (C) 2007 Matt Lilek (pewtermoose@gmail.com). 4 * Copyright (C) 2007 Matt Lilek (pewtermoose@gmail.com).
5 * Copyright (C) 2009 Joseph Pecoraro 5 * Copyright (C) 2009 Joseph Pecoraro
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 10 *
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 return false; 569 return false;
570 }; 570 };
571 571
572 /** 572 /**
573 * @param {number} ms 573 * @param {number} ms
574 * @param {number=} precision 574 * @param {number=} precision
575 * @return {string} 575 * @return {string}
576 */ 576 */
577 Number.preciseMillisToString = function(ms, precision) { 577 Number.preciseMillisToString = function(ms, precision) {
578 precision = precision || 0; 578 precision = precision || 0;
579 var format = '%.' + precision + 'f\u2009ms'; 579 var format = '%.' + precision + 'f\xa0ms';
580 return Common.UIString(format, ms); 580 return Common.UIString(format, ms);
581 }; 581 };
582 582
583 /** @type {!Common.UIStringFormat} */ 583 /** @type {!Common.UIStringFormat} */
584 UI._microsFormat = new Common.UIStringFormat('%.0f\u2009\u03bcs'); 584 UI._microsFormat = new Common.UIStringFormat('%.0f\xa0\u03bcs');
585 585
586 /** @type {!Common.UIStringFormat} */ 586 /** @type {!Common.UIStringFormat} */
587 UI._subMillisFormat = new Common.UIStringFormat('%.2f\u2009ms'); 587 UI._subMillisFormat = new Common.UIStringFormat('%.2f\xa0ms');
588 588
589 /** @type {!Common.UIStringFormat} */ 589 /** @type {!Common.UIStringFormat} */
590 UI._millisFormat = new Common.UIStringFormat('%.0f\u2009ms'); 590 UI._millisFormat = new Common.UIStringFormat('%.0f\xa0ms');
591 591
592 /** @type {!Common.UIStringFormat} */ 592 /** @type {!Common.UIStringFormat} */
593 UI._secondsFormat = new Common.UIStringFormat('%.2f\u2009s'); 593 UI._secondsFormat = new Common.UIStringFormat('%.2f\xa0s');
594 594
595 /** @type {!Common.UIStringFormat} */ 595 /** @type {!Common.UIStringFormat} */
596 UI._minutesFormat = new Common.UIStringFormat('%.1f\u2009min'); 596 UI._minutesFormat = new Common.UIStringFormat('%.1f\xa0min');
597 597
598 /** @type {!Common.UIStringFormat} */ 598 /** @type {!Common.UIStringFormat} */
599 UI._hoursFormat = new Common.UIStringFormat('%.1f\u2009hrs'); 599 UI._hoursFormat = new Common.UIStringFormat('%.1f\xa0hrs');
600 600
601 /** @type {!Common.UIStringFormat} */ 601 /** @type {!Common.UIStringFormat} */
602 UI._daysFormat = new Common.UIStringFormat('%.1f\u2009days'); 602 UI._daysFormat = new Common.UIStringFormat('%.1f\xa0days');
603 603
604 /** 604 /**
605 * @param {number} ms 605 * @param {number} ms
606 * @param {boolean=} higherResolution 606 * @param {boolean=} higherResolution
607 * @return {string} 607 * @return {string}
608 */ 608 */
609 Number.millisToString = function(ms, higherResolution) { 609 Number.millisToString = function(ms, higherResolution) {
610 if (!isFinite(ms)) 610 if (!isFinite(ms))
611 return '-'; 611 return '-';
612 612
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 return '-'; 646 return '-';
647 return Number.millisToString(seconds * 1000, higherResolution); 647 return Number.millisToString(seconds * 1000, higherResolution);
648 }; 648 };
649 649
650 /** 650 /**
651 * @param {number} bytes 651 * @param {number} bytes
652 * @return {string} 652 * @return {string}
653 */ 653 */
654 Number.bytesToString = function(bytes) { 654 Number.bytesToString = function(bytes) {
655 if (bytes < 1024) 655 if (bytes < 1024)
656 return Common.UIString('%.0f\u2009B', bytes); 656 return Common.UIString('%.0f\xa0B', bytes);
657 657
658 var kilobytes = bytes / 1024; 658 var kilobytes = bytes / 1024;
659 if (kilobytes < 100) 659 if (kilobytes < 100)
660 return Common.UIString('%.1f\u2009KB', kilobytes); 660 return Common.UIString('%.1f\xa0KB', kilobytes);
661 if (kilobytes < 1024) 661 if (kilobytes < 1024)
662 return Common.UIString('%.0f\u2009KB', kilobytes); 662 return Common.UIString('%.0f\xa0KB', kilobytes);
663 663
664 var megabytes = kilobytes / 1024; 664 var megabytes = kilobytes / 1024;
665 if (megabytes < 100) 665 if (megabytes < 100)
666 return Common.UIString('%.1f\u2009MB', megabytes); 666 return Common.UIString('%.1f\xa0MB', megabytes);
667 else 667 else
668 return Common.UIString('%.0f\u2009MB', megabytes); 668 return Common.UIString('%.0f\xa0MB', megabytes);
669 }; 669 };
670 670
671 /** 671 /**
672 * @param {number} num 672 * @param {number} num
673 * @return {string} 673 * @return {string}
674 */ 674 */
675 Number.withThousandsSeparator = function(num) { 675 Number.withThousandsSeparator = function(num) {
676 var str = num + ''; 676 var str = num + '';
677 var re = /(\d+)(\d{3})/; 677 var re = /(\d+)(\d{3})/;
678 while (str.match(re)) 678 while (str.match(re))
679 str = str.replace(re, '$1\u2009$2'); // \u2009 is a thin space. 679 str = str.replace(re, '$1\xa0$2'); // \xa0 is a non-breaking space
680 return str; 680 return str;
681 }; 681 };
682 682
683 /** 683 /**
684 * @param {string} format 684 * @param {string} format
685 * @param {?ArrayLike} substitutions 685 * @param {?ArrayLike} substitutions
686 * @return {!Element} 686 * @return {!Element}
687 */ 687 */
688 UI.formatLocalized = function(format, substitutions) { 688 UI.formatLocalized = function(format, substitutions) {
689 var formatters = {s: substitution => substitution}; 689 var formatters = {s: substitution => substitution};
(...skipping 1373 matching lines...) Expand 10 before | Expand all | Expand 10 after
2063 */ 2063 */
2064 constructor(message, okCallback, cancelCallback) { 2064 constructor(message, okCallback, cancelCallback) {
2065 super(true); 2065 super(true);
2066 this.registerRequiredCSS('ui/confirmDialog.css'); 2066 this.registerRequiredCSS('ui/confirmDialog.css');
2067 this.contentElement.createChild('div', 'message').createChild('span').textCo ntent = message; 2067 this.contentElement.createChild('div', 'message').createChild('span').textCo ntent = message;
2068 var buttonsBar = this.contentElement.createChild('div', 'button'); 2068 var buttonsBar = this.contentElement.createChild('div', 'button');
2069 buttonsBar.appendChild(UI.createTextButton(Common.UIString('Ok'), okCallback )); 2069 buttonsBar.appendChild(UI.createTextButton(Common.UIString('Ok'), okCallback ));
2070 buttonsBar.appendChild(UI.createTextButton(Common.UIString('Cancel'), cancel Callback)); 2070 buttonsBar.appendChild(UI.createTextButton(Common.UIString('Cancel'), cancel Callback));
2071 } 2071 }
2072 }; 2072 };
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/timeline/TimelineUIUtils.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698