Skip to content

Commit

Permalink
catapult @ master.
Browse files Browse the repository at this point in the history
  • Loading branch information
paulirish committed Sep 21, 2016
1 parent 30a7036 commit c8d0b9c
Show file tree
Hide file tree
Showing 156 changed files with 3,732 additions and 13,362 deletions.
27 changes: 0 additions & 27 deletions lighthouse-core/third_party/traceviewer-js/LICENSE

This file was deleted.

16 changes: 7 additions & 9 deletions lighthouse-core/third_party/traceviewer-js/base/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,14 @@ global.tr = (function() {
panicElement = document.createElement('div');
panicElement.style.webkitFlex = '1 1 auto';
panicElement.style.overflow = 'auto';
Polymer.dom(panicOverlay).appendChild(panicElement);
panicOverlay.appendChild(panicElement);

if (!document.body) {
setTimeout(function() {
Polymer.dom(document.body).appendChild(panicOverlay);
document.body.appendChild(panicOverlay);
}, 150);
} else {
Polymer.dom(document.body).appendChild(panicOverlay);
document.body.appendChild(panicOverlay);
}
}

Expand All @@ -118,14 +118,12 @@ global.tr = (function() {

showPanicElementIfNeeded();
var panicMessageEl = document.createElement('div');
Polymer.dom(panicMessageEl).innerHTML =
panicMessageEl.innerHTML =
'<h2 id="message"></h2>' +
'<pre id="details"></pre>';
Polymer.dom(Polymer.dom(panicMessageEl).querySelector('#message')).
textContent = panicTitle;
Polymer.dom(Polymer.dom(panicMessageEl).querySelector('#details')).
textContent = panicDetails;
Polymer.dom(panicElement).appendChild(panicMessageEl);
panicMessageEl.querySelector('#message').textContent = panicTitle;
panicMessageEl.querySelector('#details').textContent = panicDetails;
panicElement.appendChild(panicMessageEl);

rawPanicMessages.push({
title: panicTitle,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ global.tr.exportTo('tr.b', function() {
thread_state_sleeping: new tr.b.Color(240, 240, 240),
thread_state_unknown: new tr.b.Color(199, 155, 125),

background_memory_dump: new tr.b.Color(0, 180, 180),
light_memory_dump: new tr.b.Color(0, 0, 180),
detailed_memory_dump: new tr.b.Color(180, 0, 180),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
**/

require("./extension_registry_base.js");
require("./event.js");
require("./category_util.js");
require("./event.js");
require("./extension_registry_base.js");

'use strict';

Expand All @@ -23,8 +23,8 @@ global.tr.exportTo('tr.b', function() {

registry.registeredTypeInfos_ = [];

registry.categoryPartToTypeInfoMap_ = {};
registry.typeNameToTypeInfoMap_ = {};
registry.categoryPartToTypeInfoMap_ = new Map();
registry.typeNameToTypeInfoMap_ = new Map();

registry.register = function(constructor,
metadata) {
Expand Down Expand Up @@ -54,11 +54,11 @@ global.tr.exportTo('tr.b', function() {

// Sanity checks...
typeInfo.typeNames.forEach(function(typeName) {
if (registry.typeNameToTypeInfoMap_[typeName])
if (registry.typeNameToTypeInfoMap_.has(typeName))
throw new Error('typeName ' + typeName + ' already registered');
});
typeInfo.categoryParts.forEach(function(categoryPart) {
if (registry.categoryPartToTypeInfoMap_[categoryPart]) {
if (registry.categoryPartToTypeInfoMap_.has(categoryPart)) {
throw new Error('categoryPart ' + categoryPart +
' already registered');
}
Expand All @@ -70,10 +70,10 @@ global.tr.exportTo('tr.b', function() {

// Actual registration.
typeInfo.typeNames.forEach(function(typeName) {
registry.typeNameToTypeInfoMap_[typeName] = typeInfo;
registry.typeNameToTypeInfoMap_.set(typeName, typeInfo);
});
typeInfo.categoryParts.forEach(function(categoryPart) {
registry.categoryPartToTypeInfoMap_[categoryPart] = typeInfo;
registry.categoryPartToTypeInfoMap_.set(categoryPart, typeInfo);
});
registry.registeredTypeInfos_.push(typeInfo);

Expand All @@ -88,8 +88,8 @@ global.tr.exportTo('tr.b', function() {
categoryPartToTypeInfoMap: registry.categoryPartToTypeInfoMap_
});
registry.registeredTypeInfos_ = [];
registry.typeNameToTypeInfoMap_ = {};
registry.categoryPartToTypeInfoMap_ = {};
registry.typeNameToTypeInfoMap_ = new Map();
registry.categoryPartToTypeInfoMap_ = new Map();
var e = new tr.b.Event('registry-changed');
registry.dispatchEvent(e);
};
Expand Down Expand Up @@ -119,10 +119,10 @@ global.tr.exportTo('tr.b', function() {
var typeInfo = registry.registeredTypeInfos_[typeInfoIndex];
registry.registeredTypeInfos_.splice(typeInfoIndex, 1);
typeInfo.typeNames.forEach(function(typeName) {
delete registry.typeNameToTypeInfoMap_[typeName];
registry.typeNameToTypeInfoMap_.delete(typeName);
});
typeInfo.categoryParts.forEach(function(categoryPart) {
delete registry.categoryPartToTypeInfoMap_[categoryPart];
registry.categoryPartToTypeInfoMap_.delete(categoryPart);
});
var e = new tr.b.Event('registry-changed');
registry.dispatchEvent(e);
Expand All @@ -133,12 +133,14 @@ global.tr.exportTo('tr.b', function() {
var categoryParts = getCategoryParts(category);
for (var i = 0; i < categoryParts.length; i++) {
var categoryPart = categoryParts[i];
if (registry.categoryPartToTypeInfoMap_[categoryPart])
return registry.categoryPartToTypeInfoMap_[categoryPart];
var typeInfo = registry.categoryPartToTypeInfoMap_.get(categoryPart);
if (typeInfo !== undefined)
return typeInfo;
}
}
if (registry.typeNameToTypeInfoMap_[typeName])
return registry.typeNameToTypeInfoMap_[typeName];
var typeInfo = registry.typeNameToTypeInfoMap_.get(typeName);
if (typeInfo !== undefined)
return typeInfo;

return extensionRegistryOptions.defaultTypeInfo;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,37 @@ global.tr.exportTo('tr.b', function() {
* value and the map key.
* @param {*=} opt_this
*/
function group(ary, callback, opt_this) {
function group(ary, callback, opt_this, opt_arrayConstructor) {
var arrayConstructor = opt_arrayConstructor || Array;
var results = {};
for (var element of ary) {
var key = callback.call(opt_this, element);
if (key in results)
results[key].push(element);
else
results[key] = [element];
if (!(key in results))
results[key] = new arrayConstructor();
results[key].push(element);
}
return results;
}

/**
* Returns a new Map with items grouped by the return value of the
* specified function being called on each item.
* @param {!Array.<!*>} ary The array being iterated through
* @param {!function(!*):!*} callback The mapping function between the array
* value and the map key.
* @param {*=} opt_this
*/
function groupIntoMap(ary, callback, opt_this, opt_arrayConstructor) {
var arrayConstructor = opt_arrayConstructor || Array;
var results = new Map();
for (var element of ary) {
var key = callback.call(opt_this, element);
var items = results.get(key);
if (items === undefined) {
items = new arrayConstructor();
results.set(key, items);
}
items.push(element);
}
return results;
}
Expand Down Expand Up @@ -429,6 +452,7 @@ global.tr.exportTo('tr.b', function() {
getOnlyElement: getOnlyElement,
getFirstElement: getFirstElement,
group: group,
groupIntoMap: groupIntoMap,
iterItems: iterItems,
mapItems: mapItems,
filterItems: filterItems,
Expand Down
5 changes: 4 additions & 1 deletion lighthouse-core/third_party/traceviewer-js/base/range.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ global.tr.exportTo('tr.b', function() {
this.isEmpty_ = true;
this.min_ = undefined;
this.max_ = undefined;
};
}

Range.prototype = {
__proto__: Object.prototype,
Expand Down Expand Up @@ -265,6 +265,9 @@ global.tr.exportTo('tr.b', function() {
return 0;
};

Range.PERCENT_RANGE = Range.fromExplicitRange(0, 1);
Object.freeze(Range.PERCENT_RANGE);

return {
Range: Range
};
Expand Down

0 comments on commit c8d0b9c

Please sign in to comment.