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

Side by Side Diff: content/browser/resources/media/util.js

Issue 23769009: Removes the --enable-new-media-internals flag. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: removed unused files from old-media-internals Created 7 years, 3 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 | « content/browser/resources/media/player_info.js ('k') | content/content_resources.grd » ('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 (c) 2011 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 cr.define('media', function() { 5 /**
6 'use strict'; 6 * @fileoverview Some utility functions that don't belong anywhere else in the
7 * code.
8 */
7 9
10 var util = (function() {
11 var util = {};
12 util.object = {};
8 /** 13 /**
9 * The width and height of a bar drawn on a file canvas in pixels. 14 * Calls a function for each element in an object/map/hash.
15 *
16 * @param obj The object to iterate over.
17 * @param f The function to call on every value in the object. F should have
18 * the following arguments: f(value, key, object) where value is the value
19 * of the property, key is the corresponding key, and obj is the object that
20 * was passed in originally.
21 * @param optObj The object use as 'this' within f.
10 */ 22 */
11 var BAR_WIDTH = 500; 23 util.object.forEach = function(obj, f, optObj) {
12 var BAR_HEIGHT = 16; 24 'use strict';
25 var key;
26 for (key in obj) {
27 if (obj.hasOwnProperty(key)) {
28 f.call(optObj, obj[key], key, obj);
29 }
30 }
31 };
32 util.millisecondsToString = function(timeMillis) {
33 function pad(num) {
34 num = num.toString();
35 if (num.length < 2) {
36 return '0' + num;
37 }
38 return num;
39 }
13 40
14 /** 41 var date = new Date(timeMillis);
15 * Draws a 1px white horizontal line across |context|. 42 return pad(date.getUTCHours()) + ':' + pad(date.getUTCMinutes()) + ':' +
16 */ 43 pad(date.getUTCSeconds()) + ' ' + pad((date.getMilliseconds()) % 1000);
17 function drawLine(context, top) { 44 };
18 context.moveTo(0, top);
19 context.lineTo(BAR_WIDTH, top);
20 context.strokeStyle = '#fff';
21 context.stroke();
22 }
23 45
24 /** 46 return util;
25 * Creates an HTMLElement of type |type| with textContent |content|. 47 }());
26 * @param {string} type The type of element to create.
27 * @param {string} content The content to place in the element.
28 * @return {HTMLElement} A newly initialized element.
29 */
30 function makeElement(type, content) {
31 var element = document.createElement(type);
32 element.textContent = content;
33 return element;
34 }
35
36 /**
37 * Creates a new <li> containing a <details> with a <summary> and sets
38 * properties to reference them.
39 * @return {Object} The new <li>.
40 */
41 function createDetailsLi() {
42 var li = document.createElement('li');
43 li.details = document.createElement('details');
44 li.summary = document.createElement('summary');
45 li.appendChild(li.details);
46 li.details.appendChild(li.summary);
47 return li
48 }
49
50 /**
51 * Appends each key-value pair in a dictionary to a row in a table.
52 * @param {Object} dict The dictionary to append.
53 * @param {HTMLElement} table The <table> element to append to.
54 */
55 function appendDictionaryToTable(dict, table) {
56 table.textContent = '';
57 for (var key in dict) {
58 var tr = document.createElement('tr');
59 tr.appendChild(makeElement('td', key + ':'));
60 tr.appendChild(makeElement('td', dict[key]));
61 table.appendChild(tr);
62 }
63 return table;
64 }
65
66 return {
67 BAR_WIDTH: BAR_WIDTH,
68 BAR_HEIGHT: BAR_HEIGHT,
69 drawLine: drawLine,
70 makeElement: makeElement,
71 createDetailsLi: createDetailsLi,
72 appendDictionaryToTable: appendDictionaryToTable
73 };
74 });
OLDNEW
« no previous file with comments | « content/browser/resources/media/player_info.js ('k') | content/content_resources.grd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698