diff options
Diffstat (limited to 'chromium/third_party/catapult/tracing/tracing/ui')
396 files changed, 0 insertions, 66960 deletions
diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/alert_sub_view.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/alert_sub_view.html deleted file mode 100644 index 67ff160cea9..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/alert_sub_view.html +++ /dev/null @@ -1,161 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/base.html"> -<link rel="import" href="/tracing/base/iteration_helpers.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/ui/analysis/analysis_sub_view.html"> -<link rel="import" href="/tracing/ui/base/dom_helpers.html"> -<link rel="import" href="/tracing/ui/base/table.html"> -<link rel="import" href="/tracing/ui/base/ui.html"> - -<polymer-element name="tr-ui-a-alert-sub-view" - extends="tr-ui-a-sub-view"> - <template> - <style> - :host { - display: flex; - flex-direction: column; - } - #table { - flex: 1 1 auto; - align-self: stretch; - } - </style> - <tr-ui-b-table id="table"> - </tr-ui-b-table> - </template> - <script> - 'use strict'; - - Polymer({ - ready: function() { - this.currentSelection_ = undefined; - this.$.table.tableColumns = [ - { - title: 'Label', - value: function(row) { return row.name; }, - width: '150px' - }, - { - title: 'Value', - width: '100%', - value: function(row) { return row.value; } - } - ]; - this.$.table.showHeader = false; - }, - - get selection() { - return this.currentSelection_; - }, - - set selection(selection) { - this.currentSelection_ = selection; - this.updateContents_(); - }, - - getRowsForSingleAlert_: function(alert) { - var rows = []; - - // Arguments - for (var argName in alert.args) { - var argView = - document.createElement('tr-ui-a-generic-object-view'); - argView.object = alert.args[argName]; - rows.push({ name: argName, value: argView }); - } - - // Associated events - if (alert.associatedEvents.length) { - alert.associatedEvents.forEach(function(event, i) { - var linkEl = document.createElement('tr-ui-a-analysis-link'); - linkEl.setSelectionAndContent(function() { - return event; - }, event.title); - - var valueString = ''; - if (event instanceof tr.model.TimedEvent) - valueString = 'took ' + event.duration.toFixed(2) + 'ms'; - - rows.push({ - name: linkEl, - value: valueString - }); - }); - } - - // Description - var descriptionEl = tr.ui.b.createDiv({ - textContent: alert.info.description, - maxWidth: '300px' - }); - rows.push({ - name: 'Description', - value: descriptionEl - }); - - // Additional Reading Links - if (alert.info.docLinks) { - alert.info.docLinks.forEach(function(linkObject) { - var linkEl = document.createElement('a'); - linkEl.target = '_blank'; - linkEl.href = linkObject.href; - linkEl.textContent = linkObject.textContent; - rows.push({ - name: linkObject.label, - value: linkEl - }); - }); - } - return rows; - }, - - getRowsForAlerts_: function(alerts) { - if (alerts.length == 1) { - var rows = [{ - name: 'Alert', - value: tr.b.getOnlyElement(alerts).title - }]; - var detailRows = this.getRowsForSingleAlert_(alerts[0]); - rows.push.apply(rows, detailRows); - return rows; - } else { - return alerts.map(function(alert) { - return { - name: 'Alert', - value: alert.title, - isExpanded: alerts.size < 10, // This is somewhat arbitrary for now. - subRows: this.getRowsForSingleAlert_(alert) - }; - }, this); - } - }, - - updateContents_: function() { - if (this.currentSelection_ === undefined) { - this.$.table.rows = []; - this.$.table.rebuild(); - return; - } - - var alerts = this.currentSelection_; - this.$.table.tableRows = this.getRowsForAlerts_(alerts); - this.$.table.rebuild(); - }, - - get relatedEventsToHighlight() { - if (!this.currentSelection_) - return undefined; - var result = new tr.model.EventSet(); - for (var event of this.currentSelection_) - result.addEventSet(event.associatedEvents); - return result; - } - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/alert_sub_view_test.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/alert_sub_view_test.html deleted file mode 100644 index cc2a1b668ae..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/alert_sub_view_test.html +++ /dev/null @@ -1,82 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/iteration_helpers.html"> -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/ui/analysis/analysis_view.html"> -<link rel="import" href="/tracing/ui/base/deep_utils.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var newSliceEx = tr.c.TestUtils.newSliceEx; - - test('instantiate', function() { - var slice = newSliceEx({title: 'b', start: 0, duration: 0.002}); - - var alertInfo = new tr.model.EventInfo( - 'alertInfo', 'Critical alert', - [{ - label: 'Project Page', - textContent: 'Trace-Viewer Github Project', - href: 'https://github.com/google/trace-viewer/' - }]); - - var alert = new tr.model.Alert(alertInfo, 5, [slice]); - assert.equal(1, alert.associatedEvents.length); - - var subView = document.createElement('tr-ui-a-alert-sub-view'); - subView.selection = new tr.model.EventSet(alert); - assert.isTrue( - subView.relatedEventsToHighlight.equals(alert.associatedEvents)); - this.addHTMLOutput(subView); - - var table = tr.b.findDeepElementMatching( - subView, 'tr-ui-b-table'); - - var rows = table.tableRows; - var columns = table.tableColumns; - assert.lengthOf(rows, 4); - assert.lengthOf(columns, 2); - }); - - test('instantiate_twoAlertsWithRelatedEvents', function() { - var slice1 = newSliceEx({title: 'b', start: 0, duration: 0.002}); - var slice2 = newSliceEx({title: 'b', start: 1, duration: 0.002}); - - var alertInfo1 = new tr.model.EventInfo( - 'alertInfo1', 'Critical alert', - [{ - label: 'Project Page', - textContent: 'Trace-Viewer Github Project', - href: 'https://github.com/google/trace-viewer/' - }]); - - var alertInfo2 = new tr.model.EventInfo( - 'alertInfo2', 'Critical alert', - [{ - label: 'Google Homepage', - textContent: 'Google Search Page', - href: 'http://www.google.com' - }]); - - var alert1 = new tr.model.Alert(alertInfo1, 5, [slice1]); - var alert2 = new tr.model.Alert(alertInfo2, 5, [slice2]); - - var subView = document.createElement('tr-ui-a-alert-sub-view'); - subView.selection = new tr.model.EventSet([alert1, alert2]); - assert.isTrue(subView.relatedEventsToHighlight.equals( - new tr.model.EventSet([ - tr.b.getOnlyElement(alert1.associatedEvents), - tr.b.getOnlyElement(alert2.associatedEvents) - ]))); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/analysis_link.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/analysis_link.html deleted file mode 100644 index 3619e4a9b40..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/analysis_link.html +++ /dev/null @@ -1,124 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/ui/base/ui.html"> -<link rel="import" href="/tracing/ui/brushing_state_controller.html"> - -<polymer-element name="tr-ui-a-analysis-link" is="a" - on-click="{{onClicked_}}" - on-mouseenter="{{onMouseEnter_}}" - on-mouseleave="{{onMouseLeave_}}"> - <template> - <style> - :host { - display: inline; - color: -webkit-link; - cursor: pointer; - text-decoration: underline; - cursor: pointer; - } - </style> - <content></content> - </template> - <script> - 'use strict'; - Polymer({ - ready: function() { - this.selection_ = undefined; - }, - - attached: function() { - // Save an instance of the controller since it's going to be used in - // detached() where it can no longer be obtained. - this.controller_ = - tr.c.BrushingStateController.getControllerForElement(this); - }, - - detached: function() { - // Reset highlights. - this.clearHighlight_(); - this.controller_ = undefined; - }, - - /** - * @return {*|function():*} - */ - get selection() { - return this.selection_; - }, - - /** - * |selection| can be anything except a function, or else a function that - * can return anything. - * - * In the context of trace_viewer, |selection| is typically an EventSet, - * whose events will be highlighted by trace_viewer when this link is - * clicked or mouse-entered. - * - * If |selection| is not a function, then it will be dispatched to this - * link's embedder via a RequestSelectionChangeEvent when this link is - * clicked or mouse-entered. - * - * If |selection| is a function, then it will be called when this link is - * clicked or mouse-entered, and its result will be dispatched to this - * link's embedder via a RequestSelectionChangeEvent. - * - * @param {*|function():*} selection - */ - set selection(selection) { - this.selection_ = selection; - this.textContent = selection.userFriendlyName; - }, - - setSelectionAndContent: function(selection, opt_textContent) { - this.selection_ = selection; - if (opt_textContent) - this.textContent = opt_textContent; - }, - - /** - * If |selection| is a function, call it and return the result. - * Otherwise return |selection| directly. - * - * @return {*} - */ - getCurrentSelection_: function() { - // Gets the current selection, invoking the selection function if needed. - if (typeof this.selection_ === 'function') - return this.selection_(); - return this.selection_; - }, - - setHighlight_: function(opt_eventSet) { - if (this.controller_) - this.controller_.changeAnalysisLinkHoveredEvents(opt_eventSet); - }, - - clearHighlight_: function(opt_eventSet) { - this.setHighlight_(); - }, - - onClicked_: function() { - if (!this.selection_) - return; - - var event = new tr.model.RequestSelectionChangeEvent(); - event.selection = this.getCurrentSelection_(); - this.dispatchEvent(event); - }, - - onMouseEnter_: function() { - this.setHighlight_(this.getCurrentSelection_()); - }, - - onMouseLeave_: function() { - this.clearHighlight_(); - } - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/analysis_link_test.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/analysis_link_test.html deleted file mode 100644 index 9245acb3ee9..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/analysis_link_test.html +++ /dev/null @@ -1,59 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/ui/analysis/analysis_link.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - test('testBasic', function() { - var link = document.createElement('tr-ui-a-analysis-link'); - - var i10 = new tr.model.ObjectInstance( - {}, '0x1000', 'cat', 'name', 10); - var s10 = i10.addSnapshot(10, {foo: 1}); - - link.selection = new tr.model.EventSet(s10); - this.addHTMLOutput(link); - - var didRSC = false; - link.addEventListener('requestSelectionChange', function(e) { - didRSC = true; - assert.isTrue(e.selection.equals(new tr.model.EventSet(s10))); - }); - link.click(); - assert.isTrue(didRSC); - }); - - test('testGeneratorVersion', function() { - var link = document.createElement('tr-ui-a-analysis-link'); - - var i10 = new tr.model.ObjectInstance( - {}, '0x1000', 'cat', 'name', 10); - var s10 = i10.addSnapshot(10, {foo: 1}); - - function selectionGenerator() { - return new tr.model.EventSet(s10); - } - selectionGenerator.userFriendlyName = 'hello world'; - link.selection = selectionGenerator; - this.addHTMLOutput(link); - - var didRSC = false; - link.addEventListener('requestSelectionChange', function(e) { - assert.isTrue(e.selection.equals(new tr.model.EventSet(s10))); - didRSC = true; - }); - link.click(); - assert.isTrue(didRSC); - }); - -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/analysis_sub_view.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/analysis_sub_view.html deleted file mode 100644 index 203eed642df..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/analysis_sub_view.html +++ /dev/null @@ -1,46 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/base.html"> - -<!-- -@fileoverview Polymer element for various analysis sub-views. ---> -<polymer-element name="tr-ui-a-sub-view"> - <script> - 'use strict'; - Polymer({ - set tabLabel(label) { - return this.setAttribute('tab-label', label); - }, - - get tabLabel() { - return this.getAttribute('tab-label'); - }, - - get requiresTallView() { - return false; - }, - - get relatedEventsToHighlight() { - return undefined; - }, - - /** - * Each element extending this one must implement - * a 'selection' property. - */ - set selection(selection) { - throw new Error('Not implemented!'); - }, - - get selection() { - throw new Error('Not implemented!'); - } - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/analysis_sub_view_test.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/analysis_sub_view_test.html deleted file mode 100644 index dfe8e30d96c..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/analysis_sub_view_test.html +++ /dev/null @@ -1,35 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/ui/analysis/analysis_sub_view.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - test('subViewThrowsNotImplementedErrors', function() { - var subView = document.createElement('tr-ui-a-sub-view'); - - assert.throw(function() { - subView.selection = new tr.model.EventSet(); - }, 'Not implemented!'); - - assert.throw(function() { - var viewSelection = subView.selection; - }, 'Not implemented!'); - - subView.tabLabel = 'Tab Label'; - assert.equal(subView.getAttribute('tab-label'), 'Tab Label'); - assert.equal(subView.tabLabel, 'Tab Label'); - - subView.tabLabel = 'New Label'; - assert.equal(subView.getAttribute('tab-label'), 'New Label'); - assert.equal(subView.tabLabel, 'New Label'); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/analysis_view.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/analysis_view.html deleted file mode 100644 index b5961acda7d..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/analysis_view.html +++ /dev/null @@ -1,258 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/iteration_helpers.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/ui/analysis/alert_sub_view.html"> -<link rel="import" href="/tracing/ui/analysis/analysis_sub_view.html"> -<link rel="import" - href="/tracing/ui/analysis/container_memory_dump_sub_view.html"> -<link rel="import" href="/tracing/ui/analysis/counter_sample_sub_view.html"> -<link rel="import" href="/tracing/ui/analysis/layout_tree_sub_view.html"> -<link rel="import" href="/tracing/ui/analysis/multi_async_slice_sub_view.html"> -<link rel="import" href="/tracing/ui/analysis/multi_cpu_slice_sub_view.html"> -<link rel="import" href="/tracing/ui/analysis/multi_flow_event_sub_view.html"> -<link rel="import" href="/tracing/ui/analysis/multi_frame_sub_view.html"> -<link rel="import" - href="/tracing/ui/analysis/multi_instant_event_sub_view.html"> -<link rel="import" href="/tracing/ui/analysis/multi_object_sub_view.html"> -<link rel="import" href="/tracing/ui/analysis/multi_power_sample_sub_view.html"> -<link rel="import" href="/tracing/ui/analysis/multi_sample_sub_view.html"> -<link rel="import" href="/tracing/ui/analysis/multi_thread_slice_sub_view.html"> -<link rel="import" - href="/tracing/ui/analysis/multi_thread_time_slice_sub_view.html"> -<link rel="import" - href="/tracing/ui/analysis/multi_user_expectation_sub_view.html"> -<link rel="import" href="/tracing/ui/analysis/single_async_slice_sub_view.html"> -<link rel="import" href="/tracing/ui/analysis/single_cpu_slice_sub_view.html"> -<link rel="import" href="/tracing/ui/analysis/single_flow_event_sub_view.html"> -<link rel="import" href="/tracing/ui/analysis/single_frame_sub_view.html"> -<link rel="import" - href="/tracing/ui/analysis/single_instant_event_sub_view.html"> -<link rel="import" - href="/tracing/ui/analysis/single_object_instance_sub_view.html"> -<link rel="import" - href="/tracing/ui/analysis/single_object_snapshot_sub_view.html"> -<link rel="import" - href="/tracing/ui/analysis/single_power_sample_sub_view.html"> -<link rel="import" href="/tracing/ui/analysis/single_sample_sub_view.html"> -<link rel="import" - href="/tracing/ui/analysis/single_thread_slice_sub_view.html"> -<link rel="import" - href="/tracing/ui/analysis/single_thread_time_slice_sub_view.html"> -<link rel="import" - href="/tracing/ui/analysis/single_user_expectation_sub_view.html"> -<link rel="import" href="/tracing/ui/base/polymer_utils.html"> -<link rel="import" href="/tracing/ui/base/tab_view.html"> - -<!-- -@fileoverview A component used to display an analysis of a selection, -using custom elements specialized for different event types. ---> -<polymer-element name="tr-ui-a-analysis-view"> - <template> - <style> - :host { - background-color: white; - display: flex; - flex-direction: column; - height: 275px; - overflow: auto; - } - - :host(.tall-mode) { - height: 525px; - } - - ::content > * { - flex: 1 0 auto; - } - </style> - <content></content> - </template> - <script> - 'use strict'; - (function() { - var EventRegistry = tr.model.EventRegistry; - - Polymer({ - ready: function() { - this.tabView_ = document.createElement('tr-ui-a-tab-view'); - this.tabView_.style.flex = '1 1 auto'; - this.appendChild(this.tabView_); - this.brushingStateController_ = undefined; - this.onSelectedTabChange_ = this.onSelectedTabChange_.bind(this); - this.onSelectionChanged_ = this.onSelectionChanged_.bind(this); - - this.lastSeenSelection_ = new tr.model.EventSet(); - }, - - set tallMode(value) { - if (value) - this.classList.add('tall-mode'); - else - this.classList.remove('tall-mode'); - }, - - get tallMode() { - return this.classList.contains('tall-mode'); - }, - - get tabView() { - return this.tabView_; - }, - - get brushingStateController() { - return this.brushingStateController_; - }, - - set brushingStateController(brushingStateController) { - if (this.brushingStateController) { - this.brushingStateController_.removeEventListener( - 'change', this.onSelectionChanged_); - } - this.brushingStateController_ = brushingStateController; - if (this.brushingStateController) { - this.brushingStateController_.addEventListener( - 'change', this.onSelectionChanged_); - } - this.onSelectionChanged_(); - }, - - get selection() { - return this.brushingStateController_.selection; - }, - - onSelectionChanged_: function(e) { - var selection = this.brushingStateController_.selection; - - var selectionHasSameValue = this.lastSeenSelection_.equals(selection); - this.lastSeenSelection_ = selection; - if (selectionHasSameValue) - return; - - var lastSelectedTabTagName; - var lastSelectedTabTypeName; - if (this.tabView_.selectedTab) { - lastSelectedTabTagName = this.tabView_.selectedTab.tagName; - lastSelectedTabTypeName = this.tabView_.selectedTab._eventTypeName; - } - - this.tallMode = false; - - var previouslySelectedTab = this.tabView_.selectedTab; - this.tabView_.removeEventListener( - 'selected-tab-change', this.onSelectedTabChange_); - - var previousSubViews = {}; - for (var i = 0; i < this.tabView_.children.length; i++) { - var previousSubView = this.tabView_.children[i]; - previousSubViews[previousSubView._eventTypeName] = previousSubView; - } - - this.tabView_.saveTabStates(); - this.tabView_.textContent = ''; - if (selection.length == 0) { - this.tabView_.tabStripHeadingText = 'Nothing selected. Tap stuff.'; - } else if (selection.length == 1) { - this.tabView_.tabStripHeadingText = '1 item selected: '; - } else { - this.tabView_.tabStripHeadingText = selection.length + - ' items selected: '; - } - - var eventsByBaseTypeName = selection.getEventsOrganizedByBaseType(true); - - var numBaseTypesToAnalyze = tr.b.dictionaryLength(eventsByBaseTypeName); - for (var eventTypeName in eventsByBaseTypeName) { - var subSelection = eventsByBaseTypeName[eventTypeName]; - var subView = this.createSubViewForSelection_( - eventTypeName, subSelection, previousSubViews[eventTypeName]); - // Store the eventTypeName for future tab restoration. - subView._eventTypeName = eventTypeName; - this.tabView_.appendChild(subView); - - subView.selection = subSelection; - } - - // Restore the tab type that was previously selected. First try by tag - // name. - var tab; - if (lastSelectedTabTagName) - tab = this.tabView_.querySelector(lastSelectedTabTagName); - - // If that fails, look for a tab with that typeName. - if (!tab && lastSelectedTabTypeName) { - var tab = tr.b.findFirstInArray( - this.tabView_.children, function(tab) { - return tab._eventTypeName === lastSelectedTabTypeName; - }); - } - // If all else fails, pick the first tab. - if (!tab) - tab = this.tabView_.firstChild; - - this.tabView_.selectedTab = tab; - this.onSelectedTabChange_(); - - this.tabView_.addEventListener( - 'selected-tab-change', this.onSelectedTabChange_); - }, - - createSubViewForSelection_: function(eventTypeName, subSelection, - previousSubView) { - // Find. - var eventTypeInfo = EventRegistry.getEventTypeInfoByTypeName( - eventTypeName); - var singleMode = subSelection.length == 1; - var tagName; - if (subSelection.length === 1) - tagName = eventTypeInfo.metadata.singleViewElementName; - else - tagName = eventTypeInfo.metadata.multiViewElementName; - - if (!tr.ui.b.getPolymerElementNamed(tagName)) - throw new Error('Element not registered: ' + tagName); - - // Create if necessary. - var subView; - if (previousSubView && - previousSubView.tagName === tagName.toUpperCase()) - subView = previousSubView; - else - subView = document.createElement(tagName); - - // Set label. - var camelLabel; - if (subSelection.length === 1) - camelLabel = EventRegistry.getUserFriendlySingularName(eventTypeName); - else - camelLabel = EventRegistry.getUserFriendlyPluralName(eventTypeName); - subView.tabLabel = camelLabel + ' (' + subSelection.length + ')'; - - return subView; - }, - - onSelectedTabChange_: function() { - var brushingStateController = this.brushingStateController_; - if (this.tabView_.selectedTab) { - var selectedTab = this.tabView_.selectedTab; - this.tallMode = selectedTab.requiresTallView; - if (brushingStateController) { - var rlth = selectedTab.relatedEventsToHighlight; - brushingStateController.changeAnalysisViewRelatedEvents(rlth); - } - } else { - this.tallMode = false; - if (brushingStateController) - brushingStateController.changeAnalysisViewRelatedEvents(undefined); - } - } - }); - })(); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/analysis_view_test.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/analysis_view_test.html deleted file mode 100644 index 37776f819bd..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/analysis_view_test.html +++ /dev/null @@ -1,145 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/counter.html"> -<link rel="import" href="/tracing/model/counter_sample.html"> -<link rel="import" href="/tracing/model/counter_series.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/model/user_model/stub_expectation.html"> -<link rel="import" href="/tracing/ui/analysis/analysis_view.html"> -<link rel="import" href="/tracing/ui/brushing_state_controller.html"> -<link rel="import" href="/tracing/ui/extras/full_config.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var EventSet = tr.model.EventSet; - var BrushingStateController = tr.c.BrushingStateController; - var Model = tr.Model; - var Counter = tr.model.Counter; - var CounterSeries = tr.model.CounterSeries; - var CounterSample = tr.model.CounterSample; - var newThreadSlice = tr.c.TestUtils.newThreadSlice; - var SCHEDULING_STATE = tr.model.SCHEDULING_STATE; - var StubExpectation = tr.model.um.StubExpectation; - - function assertEventSet(actualEventSet, expectedEvents) { - var expectedEventSet = new EventSet(expectedEvents); - assert.isTrue(actualEventSet.equals(expectedEventSet), - 'EventSet objects are not equal'); - } - - function checkTab(tab, expectedTagName, expectedSelectionEvents) { - assert.equal(tab.tagName, expectedTagName.toUpperCase()); - assertEventSet(tab.selection, expectedSelectionEvents); - } - - test('selectedTabChange', function() { - // Set up the model. - var model = new Model(); - var process = model.getOrCreateProcess(1); - - var counter = process.getOrCreateCounter('universe', 'planets'); - var series = counter.addSeries(new CounterSeries('x', 0)); - var sample1 = series.addCounterSample(0, 100); - var sample2 = series.addCounterSample(1, 90); - var sample3 = series.addCounterSample(2, 80); - - var thread = process.getOrCreateThread(2); - var slice1 = newThreadSlice(thread, SCHEDULING_STATE.RUNNING, 0, 1); - var slice2 = newThreadSlice(thread, SCHEDULING_STATE.SLEEPING, 1, 2.718); - thread.timeSlices = [slice1, slice2]; - - var record1 = new StubExpectation( - {parentModel: model, initiatorTitle: 'r1', start: 200, duration: 300}); - record1.associatedEvents.push(sample1); - record1.associatedEvents.push(slice1); - var record2 = new StubExpectation( - {parentModel: model, initiatorTitle: 'r2', start: 600, duration: 100}); - record2.associatedEvents.push(sample2); - record2.associatedEvents.push(sample3); - record2.associatedEvents.push(slice1); - - // Set up the analysis views and brushing state controller. - var analysisView = document.createElement('tr-ui-a-analysis-view'); - this.addHTMLOutput(analysisView); - var tabView = analysisView.tabView; - var controller = new BrushingStateController(undefined); - analysisView.brushingStateController = controller; - - function checkSelectedTab(expectedSelectedTab, expectedRelatedEvents) { - assert.strictEqual(tabView.selectedTab, expectedSelectedTab); - assertEventSet(controller.currentBrushingState.analysisViewRelatedEvents, - expectedRelatedEvents); - } - - // 1. Empty selection (implicit). - assert.lengthOf(tabView.tabs, 0); - checkSelectedTab(undefined, []); - - // 2. Event selection: two samples and one thread slice. - controller.changeSelectionFromRequestSelectionChangeEvent( - new EventSet([sample1, slice1, sample2])); - assert.lengthOf(tabView.tabs, 2); - var sampleTab2 = tabView.tabs[0]; - checkTab(sampleTab2, - 'tr-ui-a-counter-sample-sub-view', - [sample1, sample2]); - var singleThreadSliceTab2 = tabView.tabs[1]; - checkTab(singleThreadSliceTab2, - 'tr-ui-a-single-thread-time-slice-sub-view', - [slice1]); - // First tab should be selected. - checkSelectedTab(sampleTab2, []); - - // 3. Tab selection: single thread slice tab. - tabView.selectedTab = singleThreadSliceTab2; - checkSelectedTab(singleThreadSliceTab2, []); - - // 4. Event selection: one sample, two thread slices, and one - // user expectation. - controller.changeSelectionFromRequestSelectionChangeEvent( - new EventSet([slice1, slice2, sample3, record1])); - assert.lengthOf(tabView.tabs, 3); - var sampleTab4 = tabView.tabs[1]; - checkTab(sampleTab4, - 'tr-ui-a-counter-sample-sub-view', - [sample3]); - // Reuse tab (same event type and sub-view tag name). - assert.strictEqual(sampleTab4, sampleTab2); - var singleRecordTab4 = tabView.tabs[2]; - checkTab(singleRecordTab4, - 'tr-ui-a-single-user-expectation-sub-view', - [record1]); - var multiThreadSliceTab4 = tabView.tabs[0]; - checkTab(multiThreadSliceTab4, - 'tr-ui-a-multi-thread-time-slice-sub-view', - [slice1, slice2]); - // Remember selected tab (even though the tab was destroyed). - checkSelectedTab(multiThreadSliceTab4, []); - - // 5. Tab selection: single user expectation tab. - tabView.selectedTab = singleRecordTab4; - checkSelectedTab(singleRecordTab4, [sample1, slice1]); - - // 6. Event selection: one user expectation. - controller.changeSelectionFromRequestSelectionChangeEvent( - new EventSet([record2])); - assert.lengthOf(tabView.tabs, 1); - var singleRecordTab6 = tabView.tabs[0]; - checkTab(singleRecordTab6, - 'tr-ui-a-single-user-expectation-sub-view', - [record2]); - // Reuse tab (same event type and sub-view tag name). - assert.strictEqual(singleRecordTab6, singleRecordTab4); - // Remember selected tab. - checkSelectedTab(singleRecordTab6, [sample2, sample3, slice1]); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/container_memory_dump_sub_view.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/container_memory_dump_sub_view.html deleted file mode 100644 index d6a437e775a..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/container_memory_dump_sub_view.html +++ /dev/null @@ -1,165 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/iteration_helpers.html"> -<link rel="import" href="/tracing/model/container_memory_dump.html"> -<link rel="import" href="/tracing/ui/analysis/analysis_link.html"> -<link rel="import" href="/tracing/ui/analysis/analysis_sub_view.html"> -<link rel="import" href="/tracing/ui/analysis/memory_dump_header_pane.html"> -<link rel="import" href="/tracing/ui/analysis/stacked_pane_view.html"> -<link rel="import" href="/tracing/ui/base/dom_helpers.html"> -<link rel="import" href="/tracing/value/ui/scalar_span.html"> -<link rel="import" href="/tracing/value/unit.html"> - -<polymer-element name="tr-ui-a-container-memory-dump-sub-view" - extends="tr-ui-a-sub-view"> - <template> - <div id="content"></div> - </template> -</polymer-element> -<script> -'use strict'; - -tr.exportTo('tr.ui.analysis', function() { - - Polymer('tr-ui-a-container-memory-dump-sub-view', { - set selection(selection) { - if (selection === undefined) { - this.currentSelection_ = undefined; - this.dumpsByContainerName_ = undefined; - this.updateContents_(); - return; - } - - // Check that the selection contains only container memory dumps. - selection.forEach(function(event) { - if (!(event instanceof tr.model.ContainerMemoryDump)) { - throw new Error( - 'Memory dump sub-view only supports container memory dumps'); - } - }); - this.currentSelection_ = selection; - - // Group the selected memory dumps by container name and sort them - // chronologically. - this.dumpsByContainerName_ = tr.b.group(this.currentSelection_.toArray(), - function(dump) { - return dump.containerName; - }); - tr.b.iterItems(this.dumpsByContainerName_, - function(containerName, dumps) { - dumps.sort(function(a, b) { return a.start - b.start; }); - }); - - this.updateContents_(); - }, - - get selection() { - return this.currentSelection_; - }, - - get requiresTallView() { - return true; - }, - - updateContents_: function() { - this.$.content.textContent = ''; - - if (this.dumpsByContainerName_ === undefined) - return; - - var containerNames = Object.keys(this.dumpsByContainerName_); - if (containerNames.length === 0) - return; - - if (containerNames.length > 1) - this.buildViewForMultipleContainerNames_(); - else - this.buildViewForSingleContainerName_(); - }, - - buildViewForSingleContainerName_: function() { - var containerMemoryDumps = - tr.b.dictionaryValues(this.dumpsByContainerName_)[0]; - var dumpView = this.ownerDocument.createElement( - 'tr-ui-a-stacked-pane-view'); - this.$.content.appendChild(dumpView); - dumpView.setPaneBuilder(function() { - var headerPane = document.createElement( - 'tr-ui-a-memory-dump-header-pane'); - headerPane.containerMemoryDumps = containerMemoryDumps; - return headerPane; - }); - }, - - buildViewForMultipleContainerNames_: function() { - // TODO(petrcermak): Provide a more sophisticated view for this case. - var ownerDocument = this.ownerDocument; - - var rows = tr.b.dictionaryValues(tr.b.mapItems(this.dumpsByContainerName_, - function(containerName, dumps) { - return { - containerName: containerName, - subRows: dumps, - isExpanded: true - }; - })); - rows.sort(function(a, b) { - return a.containerName.localeCompare(b.containerName); - }); - - var columns = [ - { - title: 'Dump', - - value: function(row) { - if (row.subRows === undefined) - return this.singleDumpValue_(row); - else - return this.groupedDumpValue_(row); - }, - - singleDumpValue_: function(row) { - var linkEl = ownerDocument.createElement('tr-ui-a-analysis-link'); - linkEl.setSelectionAndContent(new tr.model.EventSet([row])); - linkEl.appendChild(tr.v.ui.createScalarSpan(row.start, { - unit: tr.v.Unit.byName.timeStampInMs, - ownerDocument: ownerDocument - })); - return linkEl; - }, - - groupedDumpValue_: function(row) { - var linkEl = ownerDocument.createElement('tr-ui-a-analysis-link'); - linkEl.setSelectionAndContent(new tr.model.EventSet(row.subRows)); - linkEl.appendChild(tr.ui.b.createSpan({ - ownerDocument: ownerDocument, - textContent: row.subRows.length + ' memory dump' + - (row.subRows.length === 1 ? '' : 's') + ' in ' - })); - linkEl.appendChild(tr.ui.b.createSpan({ - ownerDocument: ownerDocument, - textContent: row.containerName, - bold: true - })); - return linkEl; - } - } - ]; - - var table = this.ownerDocument.createElement('tr-ui-b-table'); - table.tableColumns = columns; - table.tableRows = rows; - table.showHeader = false; - table.rebuild(); - this.$.content.appendChild(table); - } - }); - - return {}; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/container_memory_dump_sub_view_test.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/container_memory_dump_sub_view_test.html deleted file mode 100644 index 0619106cd1f..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/container_memory_dump_sub_view_test.html +++ /dev/null @@ -1,349 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/iteration_helpers.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" - href="/tracing/ui/analysis/container_memory_dump_sub_view.html"> -<link rel="import" - href="/tracing/ui/analysis/memory_dump_sub_view_test_utils.html"> -<link rel="import" href="/tracing/ui/base/deep_utils.html"> -<link rel="import" href="/tracing/ui/brushing_state_controller.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var EventSet = tr.model.EventSet; - var extractVmRegions = tr.ui.analysis.extractVmRegions; - var extractMemoryAllocatorDumps = tr.ui.analysis.extractMemoryAllocatorDumps; - var extractHeapDumps = tr.ui.analysis.extractHeapDumps; - - function createViewWithSelection(selection, opt_parentElement) { - var viewEl = document.createElement( - 'tr-ui-a-container-memory-dump-sub-view'); - if (opt_parentElement) - opt_parentElement.appendChild(viewEl); - if (selection === undefined) { - viewEl.selection = undefined; - } else { - // Rotate the list of selected dumps to check that the sub-view sorts - // them properly. - var length = selection.length; - viewEl.selection = new tr.model.EventSet( - selection.slice(length / 2, length).concat( - selection.slice(0, length / 2))); - } - return viewEl; - } - - function createAndCheckContainerMemoryDumpView( - test, containerMemoryDumps, detailsCheckCallback, opt_parentElement) { - var viewEl = - createViewWithSelection(containerMemoryDumps, opt_parentElement); - if (!opt_parentElement) - test.addHTMLOutput(viewEl); - - // The view should contain a stacked pane view with memory dump header and - // overview panes. - var stackedPaneViewEl = tr.b.findDeepElementMatching( - viewEl, 'tr-ui-a-stacked-pane-view'); - var headerPaneEl = tr.b.findDeepElementMatching( - stackedPaneViewEl, 'tr-ui-a-memory-dump-header-pane'); - var overviewPaneEl = tr.b.findDeepElementMatching( - stackedPaneViewEl, 'tr-ui-a-memory-dump-overview-pane'); - - // Check that the header pane and overview pane are correctly set up. - var processMemoryDumps = containerMemoryDumps.map(function(containerDump) { - return containerDump.processMemoryDumps; - }); - assert.deepEqual( - tr.b.asArray(headerPaneEl.containerMemoryDumps), containerMemoryDumps); - assert.deepEqual(overviewPaneEl.processMemoryDumps, processMemoryDumps); - assert.strictEqual( - overviewPaneEl.aggregationMode, headerPaneEl.aggregationMode); - - // Get the overview pane table to drive the details pane checks. - var overviewTableEl = tr.b.findDeepElementMatching( - overviewPaneEl, 'tr-ui-b-table'); - - function checkVmRegionsPane(pid) { - var detailsPaneEl = tr.b.findDeepElementMatching( - stackedPaneViewEl, 'tr-ui-a-memory-dump-vm-regions-details-pane'); - if (pid === undefined) { - assert.isUndefined(detailsPaneEl); - } else { - assert.deepEqual(tr.b.asArray(detailsPaneEl.vmRegions), - extractVmRegions(processMemoryDumps, pid)); - assert.strictEqual( - detailsPaneEl.aggregationMode, headerPaneEl.aggregationMode); - } - } - - function checkAllocatorPane(pid, allocatorName, withHeapDetailsPane) { - var allocatorDetailsPaneEl = tr.b.findDeepElementMatching( - stackedPaneViewEl, 'tr-ui-a-memory-dump-allocator-details-pane'); - if (pid === undefined) { - assert.isUndefined(allocatorDetailsPaneEl); - assert.isUndefined(allocatorName); // Test sanity check. - assert.isUndefined(withHeapDetailsPane); // Test sanity check. - return; - } - - assert.deepEqual( - tr.b.asArray(allocatorDetailsPaneEl.memoryAllocatorDumps), - extractMemoryAllocatorDumps(processMemoryDumps, pid, allocatorName)); - assert.strictEqual( - allocatorDetailsPaneEl.aggregationMode, headerPaneEl.aggregationMode); - - var heapDetailsPaneEl = tr.b.findDeepElementMatching( - stackedPaneViewEl, 'tr-ui-a-memory-dump-heap-details-pane'); - if (!withHeapDetailsPane) { - assert.isUndefined(heapDetailsPaneEl); - return; - } - - assert.deepEqual(tr.b.asArray(heapDetailsPaneEl.heapDumps), - extractHeapDumps(processMemoryDumps, pid, allocatorName)); - assert.strictEqual( - heapDetailsPaneEl.aggregationMode, headerPaneEl.aggregationMode); - } - - detailsCheckCallback( - overviewTableEl, checkVmRegionsPane, checkAllocatorPane); - } - - test('instantiate_empty', function() { - // All these views should be completely empty. - var unsetViewEl = document.createElement( - 'tr-ui-a-container-memory-dump-sub-view'); - this.addHTMLOutput(unsetViewEl); - assert.equal(unsetViewEl.getBoundingClientRect().width, 0); - assert.equal(unsetViewEl.getBoundingClientRect().height, 0); - - var undefinedViewEl = createViewWithSelection(undefined); - this.addHTMLOutput(undefinedViewEl); - assert.equal(undefinedViewEl.getBoundingClientRect().width, 0); - assert.equal(undefinedViewEl.getBoundingClientRect().height, 0); - - var emptyViewEl = createViewWithSelection([]); - this.addHTMLOutput(emptyViewEl); - assert.equal(emptyViewEl.getBoundingClientRect().width, 0); - assert.equal(emptyViewEl.getBoundingClientRect().height, 0); - }); - - test('instantiate_singleGlobalMemoryDump', function() { - createAndCheckContainerMemoryDumpView(this, - [tr.ui.analysis.createSingleTestGlobalMemoryDump()], - function(overviewTableEl, checkVmRegionsPane, checkAllocatorPane) { - // Nothing should be selected initially. - assert.isUndefined(overviewTableEl.selectedTableRow); - assert.isUndefined(overviewTableEl.selectedColumnIndex); - checkVmRegionsPane(undefined); - checkAllocatorPane(undefined); - - // Total resident of Process 1. - overviewTableEl.selectedTableRow = overviewTableEl.tableRows[0]; - overviewTableEl.selectedColumnIndex = 1; - checkVmRegionsPane(1 /* PID */); - checkAllocatorPane(undefined); - - // PSS of process 4. - overviewTableEl.selectedColumnIndex = 3; - overviewTableEl.selectedTableRow = overviewTableEl.tableRows[2]; - checkVmRegionsPane(undefined); - checkAllocatorPane(undefined); - - // Malloc of process 2. - overviewTableEl.selectedTableRow = overviewTableEl.tableRows[1]; - overviewTableEl.selectedColumnIndex = 9; - checkVmRegionsPane(undefined); - checkAllocatorPane(2 /* PID */, 'malloc', - false /* no heap details pane */); - }); - }); - - test('instantiate_multipleGlobalMemoryDumps', function() { - createAndCheckContainerMemoryDumpView(this, - tr.ui.analysis.createMultipleTestGlobalMemoryDumps(), - function(overviewTableEl, checkVmRegionsPane, checkAllocatorPane) { - // Nothing should be selected initially. - assert.isUndefined(overviewTableEl.selectedTableRow); - assert.isUndefined(overviewTableEl.selectedColumnIndex); - checkVmRegionsPane(undefined); - checkAllocatorPane(undefined); - - // Blink of Process 1. - overviewTableEl.selectedTableRow = overviewTableEl.tableRows[0]; - overviewTableEl.selectedColumnIndex = 7; - checkVmRegionsPane(undefined); - checkAllocatorPane(undefined); - - // Peak total resident of Process 4. - overviewTableEl.selectedTableRow = overviewTableEl.tableRows[3]; - overviewTableEl.selectedColumnIndex = 2; - checkVmRegionsPane(undefined); - checkAllocatorPane(undefined); - - // V8 of Process 3. - overviewTableEl.selectedTableRow = overviewTableEl.tableRows[2]; - overviewTableEl.selectedColumnIndex = 11; - checkVmRegionsPane(undefined); - checkAllocatorPane(3 /* PID */, 'v8', true /* heap details pane */); - }); - }); - - test('instantiate_singleProcessMemoryDump', function() { - createAndCheckContainerMemoryDumpView(this, - [tr.ui.analysis.createSingleTestProcessMemoryDump()], - function(overviewTableEl, checkVmRegionsPane, checkAllocatorPane) { - // Nothing should be selected initially. - assert.isUndefined(overviewTableEl.selectedTableRow); - assert.isUndefined(overviewTableEl.selectedColumnIndex); - checkVmRegionsPane(undefined); - checkAllocatorPane(undefined); - - // Tracing of Process 2. - overviewTableEl.selectedTableRow = overviewTableEl.tableRows[0]; - overviewTableEl.selectedColumnIndex = 12; - checkVmRegionsPane(undefined); - checkAllocatorPane(2 /* PID */, 'tracing', - false /* no heap details pane */); - - // Blink of Process 2. - overviewTableEl.selectedColumnIndex = 7; - checkVmRegionsPane(undefined); - checkAllocatorPane(2 /* PID */, 'blink', - false /* no heap details pane */); - - // Total resident of Process 2. - overviewTableEl.selectedColumnIndex = 1; - checkVmRegionsPane(2 /* PID */); - checkAllocatorPane(undefined); - }); - }); - - test('instantiate_multipleProcessMemoryDumps', function() { - createAndCheckContainerMemoryDumpView(this, - tr.ui.analysis.createMultipleTestProcessMemoryDumps(), - function(overviewTableEl, checkVmRegionsPane, checkAllocatorPane) { - // Nothing should be selected initially. - assert.isUndefined(overviewTableEl.selectedTableRow); - assert.isUndefined(overviewTableEl.selectedColumnIndex); - checkVmRegionsPane(undefined); - checkAllocatorPane(undefined); - - // Tracing of Process 2. - overviewTableEl.selectedTableRow = overviewTableEl.tableRows[0]; - overviewTableEl.selectedColumnIndex = 12; - checkVmRegionsPane(undefined); - checkAllocatorPane(2 /* PID */, 'tracing', - false /* no heap details pane */); - - // V8 of Process 2. - overviewTableEl.selectedColumnIndex = 11; - checkVmRegionsPane(undefined); - checkAllocatorPane(2 /* PID */, 'v8', - false /* no heap details pane */); - - // PSS of Process 2. - overviewTableEl.selectedColumnIndex = 3; - checkVmRegionsPane(2 /* PID */); - checkAllocatorPane(undefined); - }); - }); - - test('memory', function() { - var containerEl = document.createElement('div'); - containerEl.brushingStateController = - new tr.c.BrushingStateController(undefined); - - // Create the first container memory view. - createAndCheckContainerMemoryDumpView(this, - [tr.ui.analysis.createSingleTestProcessMemoryDump()], - function(overviewTableEl, checkVmRegionsPane, checkAllocatorPane) { - // Nothing should be selected initially. - assert.isUndefined(overviewTableEl.selectedTableRow); - assert.isUndefined(overviewTableEl.selectedColumnIndex); - checkVmRegionsPane(undefined); - checkAllocatorPane(undefined); - - // Select V8 of Process 2. - overviewTableEl.selectedTableRow = overviewTableEl.tableRows[0]; - overviewTableEl.selectedColumnIndex = 11; - checkVmRegionsPane(undefined); - checkAllocatorPane(2 /* PID */, 'v8', - false /* no heap details pane */); - }, containerEl); - - // Destroy the first container memory view. - containerEl.textContent = ''; - - // Create the second container memory view. - createAndCheckContainerMemoryDumpView(this, - tr.ui.analysis.createMultipleTestGlobalMemoryDumps(), - function(overviewTableEl, checkVmRegionsPane, checkAllocatorPane) { - // V8 of Process 2 should still be selected (even though the selection - // changed). - assert.strictEqual( - overviewTableEl.selectedTableRow, overviewTableEl.tableRows[1]); - assert.equal(overviewTableEl.selectedColumnIndex, 11); - checkVmRegionsPane(undefined); - checkAllocatorPane(2 /* PID */, 'v8', - false /* no heap details pane */); - }, containerEl); - }); - - test('instantiate_differentProcessMemoryDumps', function() { - var globalMemoryDumps = - tr.ui.analysis.createMultipleTestGlobalMemoryDumps(); - // 2 dumps in Process 1, 3 dumps in Process 2, and 1 dump in Process 4 - // (intentionally shuffled to check sorting). - var differentProcessDumps = [ - globalMemoryDumps[1].processMemoryDumps[2], - globalMemoryDumps[0].processMemoryDumps[1], - globalMemoryDumps[0].processMemoryDumps[2], - globalMemoryDumps[1].processMemoryDumps[4], - globalMemoryDumps[1].processMemoryDumps[1], - globalMemoryDumps[2].processMemoryDumps[2] - ]; - - var viewEl = createViewWithSelection(differentProcessDumps); - this.addHTMLOutput(viewEl); - - var tableEl = tr.b.findDeepElementMatching(viewEl, 'tr-ui-b-table'); - assert.lengthOf(tableEl.tableRows, 3); - assert.lengthOf(tableEl.tableColumns, 1); - var rows = tableEl.tableRows; - var col = tableEl.tableColumns[0]; - - assert.equal(col.value(rows[0]).textContent, - '2 memory dumps in Process 1'); - assert.equal(col.value(rows[1]).textContent, - '3 memory dumps in Process 2'); - assert.equal(col.value(rows[2]).textContent, - '1 memory dump in Process 4'); - - // Check that the analysis link is associated with the right dumps. - assert.isTrue(col.value(rows[1]).selection.equals(new tr.model.EventSet([ - globalMemoryDumps[0].processMemoryDumps[2], - globalMemoryDumps[1].processMemoryDumps[2], - globalMemoryDumps[2].processMemoryDumps[2] - ]))); - - assert.lengthOf(rows[1].subRows, 3); - var subRow = rows[1].subRows[0]; - - // Check the timestamp. - assert.equal(col.value(subRow).children[0].value, 42); - - // Check that the analysis link is associated with the right dump. - assert.isTrue(col.value(subRow).selection.equals( - new tr.model.EventSet(globalMemoryDumps[0].processMemoryDumps[2]))); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/counter_sample_sub_view.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/counter_sample_sub_view.html deleted file mode 100644 index 40ae156078c..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/counter_sample_sub_view.html +++ /dev/null @@ -1,120 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/iteration_helpers.html"> -<link rel="import" href="/tracing/ui/analysis/analysis_sub_view.html"> -<link rel="import" href="/tracing/ui/base/table.html"> - -<polymer-element name='tr-ui-a-counter-sample-sub-view' - extends='tr-ui-a-sub-view'> - <template> - <style> - :host { - display: flex; - flex-direction: column; - } - </style> - <tr-ui-b-table id='table'></tr-ui-b-table> - </template> -</polymer-element> - -<script> -'use strict'; -(function() { - var COUNTER_SAMPLE_TABLE_COLUMNS = [ - { - title: 'Counter', - width: '150px', - value: function(row) { return row.counter; } - }, - { - title: 'Series', - width: '150px', - value: function(row) { return row.series; } - }, - { - title: 'Time', - width: '150px', - value: function(row) { return row.start; } - }, - { - title: 'Value', - width: '100%', - value: function(row) { return row.value; } - } - ]; - - Polymer('tr-ui-a-counter-sample-sub-view', { - ready: function() { - this.currentSelection_ = undefined; - this.$.table.tableColumns = COUNTER_SAMPLE_TABLE_COLUMNS; - }, - - get selection() { - return this.currentSelection_; - }, - - set selection(selection) { - this.currentSelection_ = selection; - this.updateContents_(); - }, - - updateContents_: function() { - this.$.table.tableRows = - this.selection ? this.getRows_(this.selection.toArray()) : []; - this.$.table.rebuild(); - }, - - /** - * Returns the table rows for the specified samples. - * - * We print each counter/series combination the first time that it - * appears. For subsequent samples in each series, we omit the counter - * and series name. This makes it easy to scan to find the next series. - * - * Each series can be collapsed. In the expanded state, all samples - * are shown. In the collapsed state, only the first sample is displayed. - */ - getRows_: function(samples) { - var samplesByCounter = tr.b.group(samples, function(sample) { - return sample.series.counter.guid; - }); - - var rows = []; - tr.b.iterItems(samplesByCounter, function(unused, counterSamples) { - var samplesBySeries = tr.b.group(counterSamples, function(sample) { - return sample.series.guid; - }); - - tr.b.iterItems(samplesBySeries, function(unused, seriesSamples) { - var seriesRows = this.getRowsForSamples_(seriesSamples); - seriesRows[0].counter = seriesSamples[0].series.counter.name; - seriesRows[0].series = seriesSamples[0].series.name; - - if (seriesRows.length > 1) { - seriesRows[0].subRows = seriesRows.slice(1); - seriesRows[0].isExpanded = true; - } - - rows.push(seriesRows[0]); - }, this); - }, this); - - return rows; - }, - - getRowsForSamples_: function(samples) { - return samples.map(function(sample) { - return { - start: sample.timestamp, - value: sample.value - }; - }); - } - }); -})(); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/counter_sample_sub_view_test.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/counter_sample_sub_view_test.html deleted file mode 100644 index 4edec830945..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/counter_sample_sub_view_test.html +++ /dev/null @@ -1,172 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/model/counter.html"> -<link rel="import" href="/tracing/model/counter_series.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/ui/analysis/counter_sample_sub_view.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - - var Counter = tr.model.Counter; - var CounterSeries = tr.model.CounterSeries; - var EventSet = tr.model.EventSet; - - test('instantiate_undefinedSelection', function() { - var analysisEl = document.createElement('tr-ui-a-counter-sample-sub-view'); - analysisEl.selection = new EventSet(undefined); - - assert.lengthOf(analysisEl.$.table.tableRows, 0); - }); - - test('instantiate_oneCounterOneSeries', function() { - var series = new CounterSeries('series1', 0); - series.addCounterSample(0, 0); - series.addCounterSample(1, 10); - - var counter = new Counter(null, 0, 'cat', 'ctr1'); - counter.addSeries(series); - - var analysisEl = document.createElement('tr-ui-a-counter-sample-sub-view'); - analysisEl.selection = new EventSet(series.samples); - this.addHTMLOutput(analysisEl); - - // The first sample should be listed as a collapsible header row for the - // series. - var rows = analysisEl.$.table.tableRows; - assert.lengthOf(rows, 1); - assert.isTrue(rows[0].isExpanded); - assert.equal(rows[0].counter, 'ctr1'); - assert.equal(rows[0].series, 'series1'); - assert.equal(rows[0].start, 0); - assert.equal(rows[0].value, 0); - - // The second sample should be listed as a subrow of the first. - var subRows = rows[0].subRows; - assert.lengthOf(subRows, 1); - assert.isUndefined(subRows[0].counter); - assert.isUndefined(subRows[0].series); - assert.equal(subRows[0].start, 1); - assert.equal(subRows[0].value, 10); - }); - - test('instantiate_singleSampleDoesntHaveSubrows', function() { - var series = new CounterSeries('series1', 0); - series.addCounterSample(0, 0); - - var counter = new Counter(null, 0, 'cat', 'ctr1'); - counter.addSeries(series); - - var analysisEl = document.createElement('tr-ui-a-counter-sample-sub-view'); - analysisEl.selection = new EventSet(series.samples); - this.addHTMLOutput(analysisEl); - - // The first sample should be listed as a collapsible header row for the - // series. - var rows = analysisEl.$.table.tableRows; - assert.lengthOf(rows, 1); - assert.equal(rows[0].counter, 'ctr1'); - assert.equal(rows[0].series, 'series1'); - assert.equal(rows[0].start, 0); - assert.equal(rows[0].value, 0); - assert.isUndefined(rows[0].subRows); - }); - - test('instantiate_oneCounterTwoSeries', function() { - var series1 = new CounterSeries('series1', 0); - series1.addCounterSample(1, 10); - series1.addCounterSample(2, 20); - - var series2 = new CounterSeries('series2', 0); - series2.addCounterSample(3, 30); - - var counter = new Counter(null, 0, 'cat', 'ctr1'); - counter.addSeries(series1); - counter.addSeries(series2); - - var analysisEl = document.createElement('tr-ui-a-counter-sample-sub-view'); - analysisEl.selection = - new EventSet(series1.samples.concat(series2.samples)); - this.addHTMLOutput(analysisEl); - - // The first samples should be listed as collapsible header rows for the - // series. - var rows = analysisEl.$.table.tableRows; - assert.lengthOf(rows, 2); - assert.equal(rows[0].counter, 'ctr1'); - assert.equal(rows[0].series, 'series1'); - assert.equal(rows[0].start, 1); - assert.equal(rows[0].value, 10); - - assert.equal(rows[1].counter, 'ctr1'); - assert.equal(rows[1].series, 'series2'); - assert.equal(rows[1].start, 3); - assert.equal(rows[1].value, 30); - - // The subsequent samples should be listed as subrows of the first. - var subRows1 = rows[0].subRows; - assert.lengthOf(subRows1, 1); - assert.isUndefined(subRows1[0].counter); - assert.isUndefined(subRows1[0].series); - assert.equal(subRows1[0].start, 2); - assert.equal(subRows1[0].value, 20); - - assert.isUndefined(rows[1].subRows); - }); - - test('instantiate_twoCountersTwoSeries', function() { - var series1 = new CounterSeries('series1', 0); - series1.addCounterSample(1, 10); - - var series2 = new CounterSeries('series2', 0); - series2.addCounterSample(2, 20); - - var counter1 = new Counter(null, 0, 'cat', 'ctr1'); - var counter2 = new Counter(null, 0, 'cat', 'ctr2'); - counter1.addSeries(series1); - counter2.addSeries(series2); - - var analysisEl = document.createElement('tr-ui-a-counter-sample-sub-view'); - analysisEl.selection = - new EventSet(series1.samples.concat(series2.samples)); - this.addHTMLOutput(analysisEl); - - // Each sample should be a header row with no subrows. - var rows = analysisEl.$.table.tableRows; - assert.lengthOf(rows, 2); - assert.equal(rows[0].counter, 'ctr1'); - assert.equal(rows[0].series, 'series1'); - assert.equal(rows[0].start, 1); - assert.equal(rows[0].value, 10); - assert.isUndefined(rows[0].subRows); - - assert.equal(rows[1].counter, 'ctr2'); - assert.equal(rows[1].series, 'series2'); - assert.equal(rows[1].start, 2); - assert.equal(rows[1].value, 20); - assert.isUndefined(rows[1].subRows); - }); - - test('instantiate_contentsClearedEachSelection', function() { - var series = new CounterSeries('series1', 0); - series.addCounterSample(0, 0); - - var counter = new Counter(null, 0, 'cat', 'ctr1'); - counter.addSeries(series); - - var analysisEl = document.createElement('tr-ui-a-counter-sample-sub-view'); - analysisEl.selection = new EventSet(series.samples); - analysisEl.selection = new EventSet(series.samples); - this.addHTMLOutput(analysisEl); - - assert.lengthOf(analysisEl.$.table.tableRows, 1); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/flow_classifier.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/flow_classifier.html deleted file mode 100644 index 3895af57ea1..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/flow_classifier.html +++ /dev/null @@ -1,89 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/model/event_set.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.analysis', function() { - var FLOW_IN = 0x1; - var FLOW_OUT = 0x2; - var FLOW_IN_OUT = FLOW_IN | FLOW_OUT; - - function FlowClassifier() { - this.numEvents_ = 0; - this.eventsByGUID_ = {}; - } - - FlowClassifier.prototype = { - getFS_: function(event) { - var fs = this.eventsByGUID_[event.guid]; - if (fs === undefined) { - this.numEvents_++; - fs = { - state: 0, - event: event - }; - this.eventsByGUID_[event.guid] = fs; - } - return fs; - }, - - addInFlow: function(event) { - var fs = this.getFS_(event); - fs.state |= FLOW_IN; - return event; - }, - - addOutFlow: function(event) { - var fs = this.getFS_(event); - fs.state |= FLOW_OUT; - return event; - }, - - hasEvents: function() { - return this.numEvents_ > 0; - }, - - get inFlowEvents() { - var selection = new tr.model.EventSet(); - for (var guid in this.eventsByGUID_) { - var fs = this.eventsByGUID_[guid]; - if (fs.state === FLOW_IN) - selection.push(fs.event); - } - return selection; - }, - - get outFlowEvents() { - var selection = new tr.model.EventSet(); - for (var guid in this.eventsByGUID_) { - var fs = this.eventsByGUID_[guid]; - if (fs.state === FLOW_OUT) - selection.push(fs.event); - } - return selection; - }, - - get internalFlowEvents() { - var selection = new tr.model.EventSet(); - for (var guid in this.eventsByGUID_) { - var fs = this.eventsByGUID_[guid]; - if (fs.state === FLOW_IN_OUT) - selection.push(fs.event); - } - return selection; - } - }; - - return { - FlowClassifier: FlowClassifier - }; -}); -</script> - diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/flow_classifier_test.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/flow_classifier_test.html deleted file mode 100644 index 63ea528e2e0..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/flow_classifier_test.html +++ /dev/null @@ -1,53 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/iteration_helpers.html"> -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/ui/analysis/flow_classifier.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var newFlowEventEx = tr.c.TestUtils.newFlowEventEx; - - test('basic', function() { - var a = newFlowEventEx({ - 'title': 'a', start: 0, end: 10 }); - var b = newFlowEventEx({ - 'title': 'b', start: 10, end: 20 }); - var c = newFlowEventEx({ - 'title': 'c', start: 20, end: 25 }); - var d = newFlowEventEx({ - 'title': 'd', start: 30, end: 35 }); - - var fc = new tr.ui.analysis.FlowClassifier(); - fc.addInFlow(a); - - fc.addInFlow(b); - fc.addOutFlow(b); - - fc.addInFlow(c); - fc.addOutFlow(c); - - fc.addOutFlow(d); - - function asSortedArray(selection) { - var events = tr.b.asArray(selection); - events.sort(function(a, b) { - return a.guid - b.guid; - }); - return events; - } - - assert.deepEqual(tr.b.asArray(fc.inFlowEvents), [a]); - assert.deepEqual(tr.b.asArray(fc.outFlowEvents), [d]); - assert.deepEqual(tr.b.asArray(fc.internalFlowEvents), [b, c]); - }); - -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/frame_power_usage_chart.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/frame_power_usage_chart.html deleted file mode 100644 index 87162a4e023..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/frame_power_usage_chart.html +++ /dev/null @@ -1,139 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/ui/base/line_chart.html"> - -<!-- -@fileoverview A line chart showing milliseconds since the start of the frame on -the x-axis and power consumption on the y-axis. Each frame is shown as a -separate line in the chart. Vertical sync events are used as the start of each -frame. - -This chart aims to help users understand the shape of the power consumption -curve over the course of a frame or set of frames. ---> -<polymer-element name="tr-ui-a-frame-power-usage-chart"> - <template> - <div id="content"></div> - </template> -</polymer-element> - -<script> -'use strict'; - -var EventSet = tr.model.EventSet; - -var CHART_TITLE = 'Power (W) by ms since vertical sync'; -// TODO(charliea): Find out how to make this specifiable via CSS. -var CHART_WIDTH_FRACTION_OF_BODY = 0.5; - -Polymer('tr-ui-a-frame-power-usage-chart', { - ready: function() { - this.chart_ = undefined; - this.samples_ = new EventSet(); - this.vSyncTimestamps_ = []; - }, - - get chart() { - return this.chart_; - }, - - get samples() { - return this.samples_; - }, - - get vSyncTimestamps() { - return this.vSyncTimestamps_; - }, - - /** - * Sets the data that powers the chart. Vsync timestamps must be in - * chronological order. - */ - setData: function(samples, vSyncTimestamps) { - this.samples_ = (samples === undefined) ? new EventSet() : samples; - this.vSyncTimestamps_ = - (vSyncTimestamps === undefined) ? [] : vSyncTimestamps; - this.updateContents_(); - }, - - updateContents_: function() { - this.clearChart_(); - - var data = this.getDataForLineChart_(); - - if (data.length === 0) - return; - - this.chart_ = this.createChart_(data); - this.$.content.appendChild(this.chart_); - }, - - createChart_: function(data) { - var chart = new tr.ui.b.LineChart(); - var width = document.body.clientWidth * CHART_WIDTH_FRACTION_OF_BODY; - chart.setSize({width: width, height: chart.height}); - chart.chartTitle = CHART_TITLE; - chart.data = data; - - return chart; - }, - - clearChart_: function() { - var content = this.$.content; - while (content.firstChild) - content.removeChild(content.firstChild); - - this.chart_ = undefined; - }, - - // TODO(charliea): Limit the ms since vsync to the median frame length. The - // vertical syncs are not 100% regular and highlighting any sample that's - // in one of these 'vertical sync lulls' makes the x-axis have a much larger - // scale than it should, effectively squishing the other samples into the - // left side of the chart. - /** - * Returns an array of data points for the chart. Each element in the array - * is of the form { x: <ms since vsync>, f<frame#>: <power in mW> }. - */ - getDataForLineChart_: function() { - var sortedSamples = this.sortSamplesByTimestampAscending_(this.samples); - var vSyncTimestamps = this.vSyncTimestamps.slice(); - - var lastVSyncTimestamp = undefined; - var points = []; - - // For each power sample, find and record the frame number that it belongs - // to as well as the amount of time elapsed since that frame began. - var frameNumber = 0; - sortedSamples.forEach(function(sample) { - while (vSyncTimestamps.length > 0 && vSyncTimestamps[0] <= sample.start) { - lastVSyncTimestamp = vSyncTimestamps.shift(); - frameNumber++; - } - - // If no vertical sync occurred before the power sample, don't use the - // power sample. - if (lastVSyncTimestamp === undefined) - return; - - var point = { x: sample.start - lastVSyncTimestamp }; - point['f' + frameNumber] = sample.power; - points.push(point); - }); - - return points; - }, - - sortSamplesByTimestampAscending_: function(samples) { - return samples.toArray().sort(function(smpl1, smpl2) { - return smpl1.start - smpl2.start; - }); - } -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/frame_power_usage_chart_perf_test.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/frame_power_usage_chart_perf_test.html deleted file mode 100644 index bf8e8619ac5..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/frame_power_usage_chart_perf_test.html +++ /dev/null @@ -1,44 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright 2016 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/model/power_sample.html"> -<link rel="import" href="/tracing/model/power_series.html"> -<link rel="import" href="/tracing/ui/analysis/frame_power_usage_chart.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - - function instantiateManyFrames() { - var model = new tr.Model(); - var numFrames = 200; - var samplesPerFrame = 200; - - // Set up the test data. - var series = new tr.model.PowerSeries(model.device); - var vsyncTimestamps = []; - for (var i = 0; i < numFrames; i++) { - vsyncTimestamps.push(i * samplesPerFrame); - for (var j = 0; j < samplesPerFrame; j++) - series.addPowerSample(vsyncTimestamps[i] + j, j); - } - var samples = series.samples; - - // Display the chart. - var chart = document.createElement('tr-ui-a-frame-power-usage-chart'); - chart.setData(new tr.model.EventSet(samples), vsyncTimestamps); - this.addHTMLOutput(chart); - } - - timedPerfTest('frame_power_usage_chart', instantiateManyFrames, { - iterations: 1 - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/frame_power_usage_chart_test.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/frame_power_usage_chart_test.html deleted file mode 100644 index e65a90b2295..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/frame_power_usage_chart_test.html +++ /dev/null @@ -1,267 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/model/power_sample.html"> -<link rel="import" href="/tracing/model/power_series.html"> -<link rel="import" href="/tracing/ui/analysis/frame_power_usage_chart.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - test('instantiate_noSamples', function() { - var series = new tr.model.PowerSeries(new tr.Model().device); - - var chart = document.createElement('tr-ui-a-frame-power-usage-chart'); - chart.setData(undefined, [0]); - - assert.isUndefined(chart.chart); - }); - - test('instantiate_noVSyncs', function() { - var series = new tr.model.PowerSeries(new tr.Model().device); - - series.addPowerSample(0, 1); - series.addPowerSample(1, 2); - series.addPowerSample(2, 3); - series.addPowerSample(3, 2); - - var chart = document.createElement('tr-ui-a-frame-power-usage-chart'); - chart.setData(new tr.model.EventSet(series.samples), []); - - assert.isUndefined(chart.chart); - }); - - test('instantiate_noSamplesOrVSyncs', function() { - var series = new tr.model.PowerSeries(new tr.Model().device); - - var chart = document.createElement('tr-ui-a-frame-power-usage-chart'); - chart.setData(undefined, []); - - assert.isUndefined(chart.chart); - }); - - test('instantiate_oneFrame', function() { - var series = new tr.model.PowerSeries(new tr.Model().device); - - var vSyncTimestamps = [0]; - series.addPowerSample(0, 1); - series.addPowerSample(1, 2); - series.addPowerSample(2, 3); - series.addPowerSample(3, 2); - - var chart = document.createElement('tr-ui-a-frame-power-usage-chart'); - chart.setData(new tr.model.EventSet(series.samples), vSyncTimestamps); - - this.addHTMLOutput(chart); - - var expectedChartData = [ - { x: 0, f1: 1 }, - { x: 1, f1: 2 }, - { x: 2, f1: 3 }, - { x: 3, f1: 2 } - ]; - assert.sameDeepMembers(chart.chart.data, expectedChartData); - }); - - test('instantiate_twoFrames', function() { - var series = new tr.model.PowerSeries(new tr.Model().device); - - var vSyncTimestamps = [0, 4]; - series.addPowerSample(0, 1); - series.addPowerSample(1, 2); - series.addPowerSample(2, 3); - series.addPowerSample(3, 2); - series.addPowerSample(4, 2); - series.addPowerSample(5, 3); - series.addPowerSample(6, 4); - series.addPowerSample(7, 3); - - var chart = document.createElement('tr-ui-a-frame-power-usage-chart'); - chart.setData(new tr.model.EventSet(series.samples), vSyncTimestamps); - - this.addHTMLOutput(chart); - - var expectedChartData = [ - { x: 0, f1: 1 }, - { x: 1, f1: 2 }, - { x: 2, f1: 3 }, - { x: 3, f1: 2 }, - { x: 0, f2: 2 }, - { x: 1, f2: 3 }, - { x: 2, f2: 4 }, - { x: 3, f2: 3 } - ]; - assert.sameDeepMembers(chart.chart.data, expectedChartData); - }); - - test('instantiate_twoFramesDifferentXValues', function() { - var series = new tr.model.PowerSeries(new tr.Model().device); - - // Power samples taken at 0, 1, 2, and 3s after frame start. - var vSyncTimestamps = [0, 4]; - series.addPowerSample(0, 1); - series.addPowerSample(1, 2); - series.addPowerSample(2, 3); - series.addPowerSample(3, 2); - // Power samples taken at 0.5, 1.5, 2.5, and 3.5s after frame start. - series.addPowerSample(4.5, 2); - series.addPowerSample(5.5, 3); - series.addPowerSample(6.5, 4); - series.addPowerSample(7.5, 3); - - var chart = document.createElement('tr-ui-a-frame-power-usage-chart'); - chart.setData(new tr.model.EventSet(series.samples), vSyncTimestamps); - - this.addHTMLOutput(chart); - - var expectedChartData = [ - { x: 0, f1: 1 }, - { x: 1, f1: 2 }, - { x: 2, f1: 3 }, - { x: 3, f1: 2 }, - { x: 0.5, f2: 2 }, - { x: 1.5, f2: 3 }, - { x: 2.5, f2: 4 }, - { x: 3.5, f2: 3 } - ]; - assert.sameDeepMembers(chart.chart.data, expectedChartData); - }); - - test('instantiate_samplesBeforeFirstVSync', function() { - var series = new tr.model.PowerSeries(new tr.Model().device); - - var vSyncTimestamps = [4]; - series.addPowerSample(0, 1); - series.addPowerSample(1, 2); - series.addPowerSample(2, 3); - series.addPowerSample(3, 2); - series.addPowerSample(4, 2); - series.addPowerSample(5, 3); - series.addPowerSample(6, 4); - series.addPowerSample(7, 3); - - var chart = document.createElement('tr-ui-a-frame-power-usage-chart'); - chart.setData(new tr.model.EventSet(series.samples), vSyncTimestamps); - - this.addHTMLOutput(chart); - - var expectedChartData = [ - { x: 0, f1: 2 }, - { x: 1, f1: 3 }, - { x: 2, f1: 4 }, - { x: 3, f1: 3 } - ]; - assert.sameDeepMembers(chart.chart.data, expectedChartData); - }); - - test('instantiate_allSamplesBeforeFirstVSync', function() { - var series = new tr.model.PowerSeries(new tr.Model().device); - - var vSyncTimestamps = [4]; - series.addPowerSample(0, 1); - series.addPowerSample(1, 2); - series.addPowerSample(2, 3); - series.addPowerSample(3, 2); - - var chart = document.createElement('tr-ui-a-frame-power-usage-chart'); - chart.setData(new tr.model.EventSet(series.samples), vSyncTimestamps); - - var expectedChartData = [ - { x: 0, f1: 2 }, - { x: 1, f1: 3 }, - { x: 2, f1: 4 }, - { x: 3, f1: 3 } - ]; - assert.isUndefined(chart.chart); - }); - - test('instantiate_vSyncsAfterLastPowerSample', function() { - var series = new tr.model.PowerSeries(new tr.Model().device); - - var vSyncTimestamps = [0, 4, 8, 12]; - series.addPowerSample(0, 1); - series.addPowerSample(1, 2); - series.addPowerSample(2, 3); - series.addPowerSample(3, 2); - series.addPowerSample(4, 2); - series.addPowerSample(5, 3); - series.addPowerSample(6, 4); - series.addPowerSample(7, 3); - - var chart = document.createElement('tr-ui-a-frame-power-usage-chart'); - chart.setData(new tr.model.EventSet(series.samples), vSyncTimestamps); - - this.addHTMLOutput(chart); - - var expectedChartData = [ - { x: 0, f1: 1 }, - { x: 1, f1: 2 }, - { x: 2, f1: 3 }, - { x: 3, f1: 2 }, - { x: 0, f2: 2 }, - { x: 1, f2: 3 }, - { x: 2, f2: 4 }, - { x: 3, f2: 3 } - ]; - assert.sameDeepMembers(chart.chart.data, expectedChartData); - }); - - test('instantiate_onlyVSyncAfterLastPowerSample', function() { - var series = new tr.model.PowerSeries(new tr.Model().device); - - var vSyncTimestamps = [8]; - series.addPowerSample(0, 1); - series.addPowerSample(1, 2); - series.addPowerSample(2, 3); - series.addPowerSample(3, 2); - series.addPowerSample(4, 2); - series.addPowerSample(5, 3); - series.addPowerSample(6, 4); - series.addPowerSample(7, 3); - - var chart = document.createElement('tr-ui-a-frame-power-usage-chart'); - chart.setData(new tr.model.EventSet(series.samples), vSyncTimestamps); - - assert.isUndefined(chart.chart); - }); - - - test('instantiate_samplesNotInChronologicalOrder', function() { - var series = new tr.model.PowerSeries(new tr.Model().device); - - var vSyncTimestamps = [0, 4]; - series.addPowerSample(4, 2); - series.addPowerSample(5, 3); - series.addPowerSample(6, 4); - series.addPowerSample(7, 3); - series.addPowerSample(0, 1); - series.addPowerSample(1, 2); - series.addPowerSample(2, 3); - series.addPowerSample(3, 2); - - var chart = document.createElement('tr-ui-a-frame-power-usage-chart'); - chart.setData(new tr.model.EventSet(series.samples), vSyncTimestamps); - - this.addHTMLOutput(chart); - - var expectedChartData = [ - { x: 0, f1: 1 }, - { x: 1, f1: 2 }, - { x: 2, f1: 3 }, - { x: 3, f1: 2 }, - { x: 0, f2: 2 }, - { x: 1, f2: 3 }, - { x: 2, f2: 4 }, - { x: 3, f2: 3 } - ]; - assert.sameDeepMembers(chart.chart.data, expectedChartData); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/generic_object_view.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/generic_object_view.html deleted file mode 100644 index 521699ee129..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/generic_object_view.html +++ /dev/null @@ -1,339 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/rect.html"> -<link rel="import" href="/tracing/base/utils.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/model/object_instance.html"> -<link rel="import" href="/tracing/model/object_snapshot.html"> -<link rel="import" href="/tracing/ui/analysis/analysis_link.html"> -<link rel="import" href="/tracing/ui/base/table.html"> -<link rel="import" href="/tracing/ui/base/ui.html"> -<link rel="import" href="/tracing/value/numeric.html"> -<link rel="import" href="/tracing/value/ui/scalar_span.html"> - -<polymer-element name="tr-ui-a-generic-object-view" - is="HTMLUnknownElement"> - <template> - <style> - :host { - display: block; - font-family: monospace; - } - </style> - <div id="content"> - </div> - </template> - - <script> - 'use strict'; - - function isTable(object) { - if (!(object instanceof Array) || - (object.length < 2)) return false; - for (var colName in object[0]) { - if (typeof colName !== 'string') return false; - } - for (var i = 0; i < object.length; ++i) { - if (!(object[i] instanceof Object)) return false; - for (var colName in object[i]) { - if (i && (object[0][colName] === undefined)) return false; - var cellType = typeof object[i][colName]; - if (cellType !== 'string' && cellType != 'number') return false; - } - if (i) { - for (var colName in object[0]) { - if (object[i][colName] === undefined) return false; - } - } - } - return true; - } - - Polymer({ - ready: function() { - this.object_ = undefined; - }, - - get object() { - return this.object_; - }, - - set object(object) { - this.object_ = object; - this.updateContents_(); - }, - - updateContents_: function() { - this.$.content.textContent = ''; - this.appendElementsForType_('', this.object_, 0, 0, 5, ''); - }, - - appendElementsForType_: function( - label, object, indent, depth, maxDepth, suffix) { - if (depth > maxDepth) { - this.appendSimpleText_( - label, indent, '<recursion limit reached>', suffix); - return; - } - - if (object === undefined) { - this.appendSimpleText_(label, indent, 'undefined', suffix); - return; - } - - if (object === null) { - this.appendSimpleText_(label, indent, 'null', suffix); - return; - } - - if (!(object instanceof Object)) { - var type = typeof object; - if (type == 'string') { - var objectReplaced = false; - if ((object[0] == '{' && object[object.length - 1] == '}') || - (object[0] == '[' && object[object.length - 1] == ']')) { - try { - object = JSON.parse(object); - objectReplaced = true; - } catch (e) { - } - } - if (!objectReplaced) { - if (object.indexOf('\n') !== -1) { - var lines = object.split('\n'); - lines.forEach(function(line, i) { - var text, ioff, ll, ss; - if (i == 0) { - text = '"' + line; - ioff = 0; - ll = label; - ss = ''; - } else if (i < lines.length - 1) { - text = line; - ioff = 1; - ll = ''; - ss = ''; - } else { - text = line + '"'; - ioff = 1; - ll = ''; - ss = suffix; - } - - var el = this.appendSimpleText_( - ll, indent + ioff * label.length + ioff, text, ss); - el.style.whiteSpace = 'pre'; - return el; - }, this); - return; - } else { - this.appendSimpleText_( - label, indent, '"' + object + '"', suffix); - return; - } - } - else { - /* Fall through to the flow below */ - } - } else { - return this.appendSimpleText_(label, indent, object, suffix); - } - } - - if (object instanceof tr.model.ObjectSnapshot) { - var link = document.createElement('tr-ui-a-analysis-link'); - link.selection = new tr.model.EventSet(object); - this.appendElementWithLabel_(label, indent, link, suffix); - return; - } - - if (object instanceof tr.model.ObjectInstance) { - var link = document.createElement('tr-ui-a-analysis-link'); - link.selection = new tr.model.EventSet(object); - this.appendElementWithLabel_(label, indent, link, suffix); - return; - } - - if (object instanceof tr.b.Rect) { - this.appendSimpleText_(label, indent, object.toString(), suffix); - return; - } - - if (object instanceof tr.v.ScalarNumeric) { - var el = this.ownerDocument.createElement('tr-v-ui-scalar-span'); - el.value = object; - this.appendElementWithLabel_(label, indent, el, suffix); - return; - } - - if (object instanceof Array) { - this.appendElementsForArray_( - label, object, indent, depth, maxDepth, suffix); - return; - } - - this.appendElementsForObject_( - label, object, indent, depth, maxDepth, suffix); - }, - - appendElementsForArray_: function( - label, object, indent, depth, maxDepth, suffix) { - if (object.length == 0) { - this.appendSimpleText_(label, indent, '[]', suffix); - return; - } - - if (isTable(object)) { - var table = document.createElement('tr-ui-b-table'); - var columns = []; - tr.b.iterItems(object[0], function(colName) { - var allStrings = true; - var allNumbers = true; - for (var i = 0; i < object.length; ++i) { - if (typeof(object[i][colName]) !== 'string') - allStrings = false; - - if (typeof(object[i][colName]) !== 'number') - allNumbers = false; - - if (!allStrings && !allNumbers) - break; - } - - var column = {title: colName}; - column.value = function(row) { - return row[colName]; - }; - - if (allStrings) { - column.cmp = function(x, y) { - return x[colName].localeCompare(y[colName]); - }; - } else if (allNumbers) { - column.cmp = function(x, y) { - return x[colName] - y[colName]; - }; - } - columns.push(column); - }); - table.tableColumns = columns; - table.tableRows = object; - this.appendElementWithLabel_(label, indent, table, suffix); - table.rebuild(); - return; - } - - this.appendElementsForType_( - label + '[', - object[0], - indent, depth + 1, maxDepth, - object.length > 1 ? ',' : ']' + suffix); - for (var i = 1; i < object.length; i++) { - this.appendElementsForType_( - '', - object[i], - indent + label.length + 1, depth + 1, maxDepth, - i < object.length - 1 ? ',' : ']' + suffix); - } - return; - }, - - appendElementsForObject_: function( - label, object, indent, depth, maxDepth, suffix) { - var keys = tr.b.dictionaryKeys(object); - if (keys.length == 0) { - this.appendSimpleText_(label, indent, '{}', suffix); - return; - } - - this.appendElementsForType_( - label + '{' + keys[0] + ': ', - object[keys[0]], - indent, depth, maxDepth, - keys.length > 1 ? ',' : '}' + suffix); - for (var i = 1; i < keys.length; i++) { - this.appendElementsForType_( - keys[i] + ': ', - object[keys[i]], - indent + label.length + 1, depth + 1, maxDepth, - i < keys.length - 1 ? ',' : '}' + suffix); - } - }, - - appendElementWithLabel_: function(label, indent, dataElement, suffix) { - var row = document.createElement('div'); - - var indentSpan = document.createElement('span'); - indentSpan.style.whiteSpace = 'pre'; - for (var i = 0; i < indent; i++) - indentSpan.textContent += ' '; - row.appendChild(indentSpan); - - var labelSpan = document.createElement('span'); - labelSpan.textContent = label; - row.appendChild(labelSpan); - - row.appendChild(dataElement); - var suffixSpan = document.createElement('span'); - suffixSpan.textContent = suffix; - row.appendChild(suffixSpan); - - row.dataElement = dataElement; - this.$.content.appendChild(row); - }, - - appendSimpleText_: function(label, indent, text, suffix) { - var el = this.ownerDocument.createElement('span'); - el.textContent = text; - this.appendElementWithLabel_(label, indent, el, suffix); - return el; - } - }); - </script> -</polymer-element> - -<polymer-element name="tr-ui-a-generic-object-view-with-label" - is="HTMLUnknownElement"> - <template> - <style> - :host { - display: block; - } - </style> - </template> - - <script> - 'use strict'; - - Polymer({ - ready: function() { - this.labelEl_ = document.createElement('div'); - this.genericObjectView_ = - document.createElement('tr-ui-a-generic-object-view'); - this.shadowRoot.appendChild(this.labelEl_); - this.shadowRoot.appendChild(this.genericObjectView_); - }, - - get label() { - return this.labelEl_.textContent; - }, - - set label(label) { - this.labelEl_.textContent = label; - }, - - get object() { - return this.genericObjectView_.object; - }, - - set object(object) { - this.genericObjectView_.object = object; - } - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/generic_object_view_test.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/generic_object_view_test.html deleted file mode 100644 index 50997e18622..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/generic_object_view_test.html +++ /dev/null @@ -1,206 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/model/object_instance.html"> -<link rel="import" href="/tracing/ui/analysis/generic_object_view.html"> -<link rel="import" href="/tracing/ui/base/deep_utils.html"> -<link rel="import" href="/tracing/value/numeric.html"> -<link rel="import" href="/tracing/value/unit.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - test('undefinedValue', function() { - var view = document.createElement('tr-ui-a-generic-object-view'); - view.object = undefined; - assert.equal(view.$.content.textContent, 'undefined'); - }); - - test('nullValue', function() { - var view = document.createElement('tr-ui-a-generic-object-view'); - view.object = null; - assert.equal(view.$.content.textContent, 'null'); - }); - - test('stringValue', function() { - var view = document.createElement('tr-ui-a-generic-object-view'); - view.object = 'string value'; - assert.equal(view.$.content.textContent, '"string value"'); - }); - - test('multiLineStringValue', function() { - var view = document.createElement('tr-ui-a-generic-object-view'); - view.object = 'i am a\n string value\ni have\n various indents'; - this.addHTMLOutput(view); - var c = view.$.content; - }); - - test('multiLineStringValueInsideObject', function() { - var view = document.createElement('tr-ui-a-generic-object-view'); - view.object = {key: 'i am a\n string value\ni have\n various indents', - value: 'simple'}; - this.addHTMLOutput(view); - var c = view.$.content; - - }); - - test('jsonObjectStringValue', function() { - var view = document.createElement('tr-ui-a-generic-object-view'); - view.object = '{"x": 1}'; - assert.equal(view.$.content.children.length, 1); - assert.equal(view.$.content.children[0].children.length, 4); - }); - - test('jsonArrayStringValue', function() { - var view = document.createElement('tr-ui-a-generic-object-view'); - view.object = '[1,2,3]'; - assert.equal(view.$.content.children.length, 3); - }); - - test('booleanValue', function() { - var view = document.createElement('tr-ui-a-generic-object-view'); - view.object = false; - assert.equal(view.$.content.textContent, 'false'); - }); - - test('numberValue', function() { - var view = document.createElement('tr-ui-a-generic-object-view'); - view.object = 3.14159; - assert.equal(view.$.content.textContent, '3.14159'); - }); - - test('objectSnapshotValue', function() { - var view = document.createElement('tr-ui-a-generic-object-view'); - - var i10 = new tr.model.ObjectInstance( - {}, '0x1000', 'cat', 'name', 10); - var s10 = i10.addSnapshot(10, {foo: 1}); - - view.object = s10; - this.addHTMLOutput(view); - assert.strictEqual(view.$.content.children[0].dataElement.tagName, - 'TR-UI-A-ANALYSIS-LINK'); - }); - - test('objectInstanceValue', function() { - var view = document.createElement('tr-ui-a-generic-object-view'); - - var i10 = new tr.model.ObjectInstance( - {}, '0x1000', 'cat', 'name', 10); - var s10 = i10.addSnapshot(10, {foo: 1}); - - view.object = i10; - assert.strictEqual(view.$.content.children[0].dataElement.tagName, - 'TR-UI-A-ANALYSIS-LINK'); - }); - - test('instantiate_emptyArrayValue', function() { - var view = document.createElement('tr-ui-a-generic-object-view'); - view.object = []; - this.addHTMLOutput(view); - }); - - test('instantiate_twoValueArrayValue', function() { - var view = document.createElement('tr-ui-a-generic-object-view'); - view.object = [1, 2]; - this.addHTMLOutput(view); - }); - - test('instantiate_twoValueBArrayValue', function() { - var view = document.createElement('tr-ui-a-generic-object-view'); - view.object = [1, {x: 1}]; - this.addHTMLOutput(view); - }); - - test('instantiate_arrayValue', function() { - var view = document.createElement('tr-ui-a-generic-object-view'); - view.object = [1, 2, 'three']; - this.addHTMLOutput(view); - }); - - test('instantiate_arrayWithSimpleObjectValue', function() { - var view = document.createElement('tr-ui-a-generic-object-view'); - view.object = [{simple: 'object'}]; - this.addHTMLOutput(view); - }); - - test('instantiate_arrayWithComplexObjectValue', function() { - var view = document.createElement('tr-ui-a-generic-object-view'); - view.object = [{col0: 'object', col1: 0}, - {col2: 'Object', col3: 1}]; - this.addHTMLOutput(view); - assert.equal(undefined, tr.b.findDeepElementMatching( - view.$.content, 'table')); - }); - - test('instantiate_arrayWithDeepObjectValue', function() { - var view = document.createElement('tr-ui-a-generic-object-view'); - view.object = [{key: {deep: 'object values make isTable() return false'}}]; - this.addHTMLOutput(view); - assert.equal(undefined, tr.b.findDeepElementMatching( - view.$.content, 'table')); - }); - - test('jsonTableValue', function() { - var view = document.createElement('tr-ui-a-generic-object-view'); - view.object = [ - {col0: 'object', col1: 0, col2: 'foo'}, - {col0: 'Object', col1: 1, col2: 42} - ]; - this.addHTMLOutput(view); - - var table = tr.b.findDeepElementMatching(view.$.content, 'tr-ui-b-table'); - assert.equal('col0', table.tableColumns[0].title); - assert.equal('col1', table.tableColumns[1].title); - assert.equal('object', table.tableColumns[0].value(table.tableRows[0])); - assert.equal('Object', table.tableColumns[0].value(table.tableRows[1])); - assert.equal(0, table.tableColumns[1].value(table.tableRows[0])); - assert.equal(1, table.tableColumns[1].value(table.tableRows[1])); - assert.isDefined(table.tableColumns[0].cmp); - assert.isDefined(table.tableColumns[1].cmp); - assert.isUndefined(table.tableColumns[2].cmp); - }); - - test('instantiate_objectValue', function() { - var view = document.createElement('tr-ui-a-generic-object-view'); - view.object = { - 'entry_one': 'entry_one_value', - 'entry_two': 2, - 'entry_three': [3, 4, 5] - }; - this.addHTMLOutput(view); - }); - - test('timeDurationValue', function() { - var view = document.createElement('tr-ui-a-generic-object-view'); - view.object = - new tr.v.ScalarNumeric(tr.v.Unit.byName.timeDurationInMs, 3); - assert.isDefined(tr.b.findDeepElementMatching( - view.$.content, 'tr-v-ui-scalar-span')); - }); - - test('timeStampValue', function() { - var view = document.createElement('tr-ui-a-generic-object-view'); - view.object = new tr.v.ScalarNumeric(tr.v.Unit.byName.timeStampInMs, 3); - assert.isDefined(tr.b.findDeepElementMatching( - view.$.content, 'tr-v-ui-scalar-span')); - }); - - test('scalarValue', function() { - var view = document.createElement('tr-ui-a-generic-object-view'); - view.object = - new tr.v.ScalarNumeric(tr.v.Unit.byName.normalizedPercentage, .3); - var m = tr.b.findDeepElementMatching( - view.$.content, 'tr-v-ui-scalar-span'); - assert.isDefined(m); - assert.equal(m.value, .3); - assert.equal(m.unit, tr.v.Unit.byName.normalizedPercentage); - }); - -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/layout_tree_sub_view.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/layout_tree_sub_view.html deleted file mode 100644 index 75a42c01d42..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/layout_tree_sub_view.html +++ /dev/null @@ -1,203 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright 2016 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/analysis/analysis_sub_view.html"> - -<polymer-element name="tr-ui-a-layout-tree-sub-view" - extends="tr-ui-a-sub-view"> - <template> - <div id="content"></div> - </template> -</polymer-element> -<script> -'use strict'; - -tr.exportTo('tr.ui.analysis', function() { - Polymer('tr-ui-a-layout-tree-sub-view', { - set selection(selection) { - this.currentSelection_ = selection; - this.updateContents_(); - }, - - get selection() { - return this.currentSelection_; - }, - - updateContents_: function() { - this.$.content.textContent = ''; - if (!this.currentSelection_) - return; - - var columns = [ - { - title: 'Tag/Name', - value: function(layoutObject) { - return layoutObject.tag || ':' + layoutObject.name; - } - }, - - { - title: 'htmlId', - value: function(layoutObject) { - return layoutObject.htmlId || ''; - } - }, - - { - title: 'classNames', - value: function(layoutObject) { - return layoutObject.classNames || ''; - } - }, - - { - title: 'reasons', - value: function(layoutObject) { - return layoutObject.needsLayoutReasons.join(', '); - } - }, - - { - title: 'width', - value: function(layoutObject) { - return layoutObject.absoluteRect.width; - } - }, - - { - title: 'height', - value: function(layoutObject) { - return layoutObject.absoluteRect.height; - } - }, - - { - title: 'absX', - value: function(layoutObject) { - return layoutObject.absoluteRect.left; - } - }, - - { - title: 'absY', - value: function(layoutObject) { - return layoutObject.absoluteRect.top; - } - }, - - { - title: 'relX', - value: function(layoutObject) { - return layoutObject.relativeRect.left; - } - }, - - { - title: 'relY', - value: function(layoutObject) { - return layoutObject.relativeRect.top; - } - }, - - { - title: 'float', - value: function(layoutObject) { - return layoutObject.isFloat ? 'float' : ''; - } - }, - - { - title: 'positioned', - value: function(layoutObject) { - return layoutObject.isPositioned ? 'positioned' : ''; - } - }, - - { - title: 'relative', - value: function(layoutObject) { - return layoutObject.isRelativePositioned ? 'relative' : ''; - } - }, - - { - title: 'sticky', - value: function(layoutObject) { - return layoutObject.isStickyPositioned ? 'sticky' : ''; - } - }, - - { - title: 'anonymous', - value: function(layoutObject) { - return layoutObject.isAnonymous ? 'anonymous' : ''; - } - }, - - { - title: 'row', - value: function(layoutObject) { - if (layoutObject.tableRow === undefined) - return ''; - return layoutObject.tableRow; - } - }, - - { - title: 'col', - value: function(layoutObject) { - if (layoutObject.tableCol === undefined) - return ''; - return layoutObject.tableCol; - } - }, - - { - title: 'rowSpan', - value: function(layoutObject) { - if (layoutObject.tableRowSpan === undefined) - return ''; - return layoutObject.tableRowSpan; - } - }, - - { - title: 'colSpan', - value: function(layoutObject) { - if (layoutObject.tableColSpan === undefined) - return ''; - return layoutObject.tableColSpan; - } - }, - - { - title: 'address', - value: function(layoutObject) { - return layoutObject.id.toString(16); - } - } - ]; - - var table = this.ownerDocument.createElement('tr-ui-b-table'); - table.defaultExpansionStateCallback = function( - layoutObject, parentLayoutObject) { - return true; - }; - table.subRowsPropertyName = 'childLayoutObjects'; - table.tableColumns = columns; - table.tableRows = this.currentSelection_.map(function(snapshot) { - return snapshot.rootLayoutObject; - }); - table.rebuild(); - this.$.content.appendChild(table); - } - }); - - return {}; -}); -</script> - diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/memory_dump_allocator_details_pane.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/memory_dump_allocator_details_pane.html deleted file mode 100644 index df1d38264aa..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/memory_dump_allocator_details_pane.html +++ /dev/null @@ -1,854 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/iteration_helpers.html"> -<link rel="import" href="/tracing/base/range.html"> -<link rel="import" href="/tracing/model/memory_allocator_dump.html"> -<link rel="import" - href="/tracing/ui/analysis/memory_dump_heap_details_pane.html"> -<link rel="import" href="/tracing/ui/analysis/memory_dump_sub_view_util.html"> -<link rel="import" href="/tracing/ui/analysis/stacked_pane.html"> -<link rel="import" href="/tracing/ui/base/dom_helpers.html"> -<link rel="import" href="/tracing/ui/base/table.html"> -<link rel="import" href="/tracing/value/unit.html"> - -<polymer-element name="tr-ui-a-memory-dump-allocator-details-pane" - extends="tr-ui-a-stacked-pane"> - <template> - <style> - :host { - display: flex; - flex-direction: column; - } - - #label { - flex: 0 0 auto; - padding: 8px; - - background-color: #eee; - border-bottom: 1px solid #8e8e8e; - border-top: 1px solid white; - - font-size: 15px; - font-weight: bold; - } - - #contents { - flex: 1 0 auto; - align-self: stretch; - font-size: 12px; - } - - #info_text { - padding: 8px; - color: #666; - font-style: italic; - text-align: center; - } - - #table { - display: none; /* Hide until memory allocator dumps are set. */ - flex: 1 0 auto; - align-self: stretch; - } - </style> - <div id="label">Component details</div> - <div id="contents"> - <div id="info_text">No memory allocator dump selected</div> - <tr-ui-b-table id="table"></tr-ui-b-table> - </div> - </template> -</polymer-element> -<script> -'use strict'; - -tr.exportTo('tr.ui.analysis', function() { - - // Constant representing the context in suballocation rows. - var SUBALLOCATION_CONTEXT = true; - - // Size numeric info types. - var MemoryAllocatorDumpInfoType = tr.model.MemoryAllocatorDumpInfoType; - var PROVIDED_SIZE_LESS_THAN_AGGREGATED_CHILDREN = - MemoryAllocatorDumpInfoType.PROVIDED_SIZE_LESS_THAN_AGGREGATED_CHILDREN; - var PROVIDED_SIZE_LESS_THAN_LARGEST_OWNER = - MemoryAllocatorDumpInfoType.PROVIDED_SIZE_LESS_THAN_LARGEST_OWNER; - - // Unicode symbols used for memory cell info icons and messages. - var LEFTWARDS_OPEN_HEADED_ARROW = String.fromCharCode(0x21FD); - var RIGHTWARDS_OPEN_HEADED_ARROW = String.fromCharCode(0x21FE); - var EN_DASH = String.fromCharCode(0x2013); - var CIRCLED_LATIN_SMALL_LETTER_I = String.fromCharCode(0x24D8); - - /** @constructor */ - function AllocatorDumpNameColumn() { - tr.ui.analysis.TitleColumn.call(this, 'Component'); - } - - AllocatorDumpNameColumn.prototype = { - __proto__: tr.ui.analysis.TitleColumn.prototype, - - formatTitle: function(row) { - if (!row.suballocation) - return row.title; - return tr.ui.b.createSpan({ - textContent: row.title, - italic: true, - tooltip: row.fullNames === undefined ? - undefined : row.fullNames.join(', ') - }); - } - }; - - /** - * Retrieve the entry associated with a given name from a map and increment - * its count. - * - * If there is no entry associated with the name, a new entry is created, the - * creation callback is called, the entry's count is incremented (from 0 to - * 1) and the newly created entry is returned. - */ - function getAndUpdateEntry(map, name, createdCallback) { - var entry = map.get(name); - if (entry === undefined) { - entry = {count: 0}; - createdCallback(entry); - map.set(name, entry); - } - entry.count++; - return entry; - } - - /** - * Helper class for building size and effective size column info messages. - * - * @constructor - */ - function SizeInfoMessageBuilder() { - this.parts_ = []; - this.indent_ = 0; - } - - SizeInfoMessageBuilder.prototype = { - append: function(/* arguments */) { - this.parts_.push.apply( - this.parts_, Array.prototype.slice.apply(arguments)); - }, - - /** - * Append the entries of a map to the message according to the following - * rules: - * - * 1. If the map is empty, append emptyText to the message (if provided). - * Examples: - * - * emptyText=undefined - * Hello, World! ====================> Hello, World! - * - * emptyText='empty' - * The bottle is ====================> The bottle is empty - * - * 2. If the map contains a single entry, append a space and call - * itemCallback on the entry (which is in turn expected to append a - * message for the entry). Example: - * - * Please do not ====================> Please do not [item-message] - * - * 3. If the map contains multiple entries, append them as a list - * with itemCallback called on each entry. If hasPluralSuffix is true, - * 's' will be appended to the message before the list. Examples: - * - * hasPluralSuffix=false - * I need to buy ====================> I need to buy: - * - [item1-message] - * - [item2-message] - * [...] - * - [itemN-message] - * - * hasPluralSuffix=true - * Suspected CL ====================> Suspected CLs: - * - [item1-message] - * - [item2-message] - * [...] - * - [itemN-message] - */ - appendMap: function( - map, hasPluralSuffix, emptyText, itemCallback, opt_this) { - opt_this = opt_this || this; - if (map.size === 0) { - if (emptyText) - this.append(emptyText); - } else if (map.size === 1) { - this.parts_.push(' '); - var key = map.keys().next().value; - itemCallback.call(opt_this, key, map.get(key)); - } else { - if (hasPluralSuffix) - this.parts_.push('s'); - this.parts_.push(':'); - this.indent_++; - for (var key of map.keys()) { - this.parts_.push('\n', ' '.repeat(3 * (this.indent_ - 1)), ' - '); - itemCallback.call(opt_this, key, map.get(key)); - } - this.indent_--; - } - }, - - appendImportanceRange: function(range) { - this.append(' (importance: '); - if (range.min === range.max) - this.append(range.min); - else - this.append(range.min, EN_DASH, range.max); - this.append(')'); - }, - - appendSizeIfDefined: function(size) { - if (size !== undefined) - this.append(' (', tr.v.Unit.byName.sizeInBytes.format(size), ')'); - }, - - appendSomeTimestampsQuantifier: function() { - this.append( - ' ', tr.ui.analysis.MemoryColumn.SOME_TIMESTAMPS_INFO_QUANTIFIER); - }, - - build: function() { - return this.parts_.join(''); - } - }; - - /** @constructor */ - function EffectiveSizeColumn(name, cellPath, aggregationMode) { - tr.ui.analysis.DetailsNumericMemoryColumn.call( - this, name, cellPath, aggregationMode); - } - - EffectiveSizeColumn.prototype = { - __proto__: tr.ui.analysis.DetailsNumericMemoryColumn.prototype, - - addInfos: function(numerics, memoryAllocatorDumps, infos) { - if (memoryAllocatorDumps === undefined) - return; - - // Quantified name of an owner dump (of the given dump) -> {count, - // importanceRange}. - var ownerNameToEntry = new Map(); - - // Quantified name of an owned dump (by the given dump) -> {count, - // importanceRange, sharerNameToEntry}, where sharerNameToEntry is a map - // from quantified names of other owners of the owned dump to {count, - // importanceRange}. - var ownedNameToEntry = new Map(); - - for (var i = 0; i < numerics.length; i++) { - if (numerics[i] === undefined) - continue; - var dump = memoryAllocatorDumps[i]; - if (dump === SUBALLOCATION_CONTEXT) - return; // No ownership of suballocation internal rows. - - // Gather owners of this dump. - dump.ownedBy.forEach(function(ownerLink) { - var ownerDump = ownerLink.source; - this.getAndUpdateOwnershipEntry_( - ownerNameToEntry, ownerDump, ownerLink); - }, this); - - // Gather dumps owned by this dump and other owner dumps sharing them - // (with this dump). - var ownedLink = dump.owns; - if (ownedLink !== undefined) { - var ownedDump = ownedLink.target; - var ownedEntry = this.getAndUpdateOwnershipEntry_(ownedNameToEntry, - ownedDump, ownedLink, true /* opt_withSharerNameToEntry */); - var sharerNameToEntry = ownedEntry.sharerNameToEntry; - ownedDump.ownedBy.forEach(function(sharerLink) { - var sharerDump = sharerLink.source; - if (sharerDump === dump) - return; - this.getAndUpdateOwnershipEntry_( - sharerNameToEntry, sharerDump, sharerLink); - }, this); - } - } - - // Emit a single info listing all owners of this dump. - if (ownerNameToEntry.size > 0) { - var messageBuilder = new SizeInfoMessageBuilder(); - messageBuilder.append('shared by'); - messageBuilder.appendMap( - ownerNameToEntry, - false /* hasPluralSuffix */, - undefined /* emptyText */, - function(ownerName, ownerEntry) { - messageBuilder.append(ownerName); - if (ownerEntry.count < numerics.length) - messageBuilder.appendSomeTimestampsQuantifier(); - messageBuilder.appendImportanceRange(ownerEntry.importanceRange); - }, this); - infos.push({ - message: messageBuilder.build(), - icon: LEFTWARDS_OPEN_HEADED_ARROW, - color: 'green' - }); - } - - // Emit a single info listing all dumps owned by this dump together - // with list(s) of other owner dumps sharing them with this dump. - if (ownedNameToEntry.size > 0) { - var messageBuilder = new SizeInfoMessageBuilder(); - messageBuilder.append('shares'); - messageBuilder.appendMap( - ownedNameToEntry, - false /* hasPluralSuffix */, - undefined /* emptyText */, - function(ownedName, ownedEntry) { - messageBuilder.append(ownedName); - var ownedCount = ownedEntry.count; - if (ownedCount < numerics.length) - messageBuilder.appendSomeTimestampsQuantifier(); - messageBuilder.appendImportanceRange(ownedEntry.importanceRange); - messageBuilder.append(' with'); - messageBuilder.appendMap( - ownedEntry.sharerNameToEntry, - false /* hasPluralSuffix */, - ' no other dumps', - function(sharerName, sharerEntry) { - messageBuilder.append(sharerName); - if (sharerEntry.count < ownedCount) - messageBuilder.appendSomeTimestampsQuantifier(); - messageBuilder.appendImportanceRange( - sharerEntry.importanceRange); - }, this); - }, this); - infos.push({ - message: messageBuilder.build(), - icon: RIGHTWARDS_OPEN_HEADED_ARROW, - color: 'green' - }); - } - }, - - getAndUpdateOwnershipEntry_: function( - map, dump, link, opt_withSharerNameToEntry) { - var entry = getAndUpdateEntry(map, dump.quantifiedName, - function(newEntry) { - newEntry.importanceRange = new tr.b.Range(); - if (opt_withSharerNameToEntry) - newEntry.sharerNameToEntry = new Map(); - }); - entry.importanceRange.addValue(link.importance || 0); - return entry; - } - }; - - /** @constructor */ - function SizeColumn(name, cellPath, aggregationMode) { - tr.ui.analysis.DetailsNumericMemoryColumn.call( - this, name, cellPath, aggregationMode); - } - - SizeColumn.prototype = { - __proto__: tr.ui.analysis.DetailsNumericMemoryColumn.prototype, - - addInfos: function(numerics, memoryAllocatorDumps, infos) { - if (memoryAllocatorDumps === undefined) - return; - this.addOverlapInfo_(numerics, memoryAllocatorDumps, infos); - this.addProvidedSizeWarningInfos_(numerics, memoryAllocatorDumps, infos); - }, - - addOverlapInfo_: function(numerics, memoryAllocatorDumps, infos) { - // Sibling allocator dump name -> {count, size}. The latter field (size) - // is omitted in multi-selection mode. - var siblingNameToEntry = new Map(); - for (var i = 0; i < numerics.length; i++) { - if (numerics[i] === undefined) - continue; - var dump = memoryAllocatorDumps[i]; - if (dump === SUBALLOCATION_CONTEXT) - return; // No ownership of suballocation internal rows. - var ownedBySiblingSizes = dump.ownedBySiblingSizes; - for (var siblingDump of ownedBySiblingSizes.keys()) { - var siblingName = siblingDump.name; - getAndUpdateEntry(siblingNameToEntry, siblingName, - function(newEntry) { - if (numerics.length === 1 /* single-selection mode */) - newEntry.size = ownedBySiblingSizes.get(siblingDump); - }); - } - } - - // Emit a single info describing all overlaps with siblings (if - // applicable). - if (siblingNameToEntry.size > 0) { - var messageBuilder = new SizeInfoMessageBuilder(); - messageBuilder.append('overlaps with its sibling'); - messageBuilder.appendMap( - siblingNameToEntry, - true /* hasPluralSuffix */, - undefined /* emptyText */, - function(siblingName, siblingEntry) { - messageBuilder.append('\'', siblingName, '\''); - messageBuilder.appendSizeIfDefined(siblingEntry.size); - if (siblingEntry.count < numerics.length) - messageBuilder.appendSomeTimestampsQuantifier(); - }, this); - infos.push({ - message: messageBuilder.build(), - icon: CIRCLED_LATIN_SMALL_LETTER_I, - color: 'blue' - }); - } - }, - - addProvidedSizeWarningInfos_: function(numerics, memoryAllocatorDumps, - infos) { - // Info type (see MemoryAllocatorDumpInfoType) -> {count, providedSize, - // dependencySize}. The latter two fields (providedSize and - // dependencySize) are omitted in multi-selection mode. - var infoTypeToEntry = new Map(); - for (var i = 0; i < numerics.length; i++) { - if (numerics[i] === undefined) - continue; - var dump = memoryAllocatorDumps[i]; - if (dump === SUBALLOCATION_CONTEXT) - return; // Suballocation internal rows have no provided size. - dump.infos.forEach(function(dumpInfo) { - getAndUpdateEntry(infoTypeToEntry, dumpInfo.type, function(newEntry) { - if (numerics.length === 1 /* single-selection mode */) { - newEntry.providedSize = dumpInfo.providedSize; - newEntry.dependencySize = dumpInfo.dependencySize; - } - }); - }); - } - - // Emit a warning info for every info type. - for (var infoType of infoTypeToEntry.keys()) { - var entry = infoTypeToEntry.get(infoType); - var messageBuilder = new SizeInfoMessageBuilder(); - messageBuilder.append('provided size'); - messageBuilder.appendSizeIfDefined(entry.providedSize); - var dependencyName; - switch (infoType) { - case PROVIDED_SIZE_LESS_THAN_AGGREGATED_CHILDREN: - dependencyName = 'the aggregated size of the children'; - break; - case PROVIDED_SIZE_LESS_THAN_LARGEST_OWNER: - dependencyName = 'the size of the largest owner'; - break; - default: - dependencyName = 'an unknown dependency'; - break; - } - messageBuilder.append(' was less than ', dependencyName); - messageBuilder.appendSizeIfDefined(entry.dependencySize); - if (entry.count < numerics.length) - messageBuilder.appendSomeTimestampsQuantifier(); - infos.push(tr.ui.analysis.createWarningInfo(messageBuilder.build())); - } - } - }; - - var NUMERIC_COLUMN_RULES = [ - { - condition: tr.model.MemoryAllocatorDump.EFFECTIVE_SIZE_NUMERIC_NAME, - importance: 10, - columnConstructor: EffectiveSizeColumn - }, - { - condition: tr.model.MemoryAllocatorDump.SIZE_NUMERIC_NAME, - importance: 9, - columnConstructor: SizeColumn - }, - { - condition: 'page_size', - importance: 0, - columnConstructor: tr.ui.analysis.DetailsNumericMemoryColumn - }, - { - condition: /size/, - importance: 5, - columnConstructor: tr.ui.analysis.DetailsNumericMemoryColumn - }, - { - // All other columns. - importance: 0, - columnConstructor: tr.ui.analysis.DetailsNumericMemoryColumn - } - ]; - - var DIAGNOSTIC_COLUMN_RULES = [ - { - importance: 0, - columnConstructor: tr.ui.analysis.StringMemoryColumn - } - ]; - - Polymer('tr-ui-a-memory-dump-allocator-details-pane', { - created: function() { - this.memoryAllocatorDumps_ = undefined; - this.heapDumps_ = undefined; - this.aggregationMode_ = undefined; - }, - - ready: function() { - this.$.table.selectionMode = tr.ui.b.TableFormat.SelectionMode.ROW; - }, - - /** - * Sets the memory allocator dumps and schedules rebuilding the pane. - * - * The provided value should be a chronological list of memory allocator - * dumps. All dumps are assumed to belong to the same process and have - * the same full name. Example: - * - * [ - * tr.model.MemoryAllocatorDump {}, // MAD at timestamp 1. - * undefined, // MAD not provided at timestamp 2. - * tr.model.MemoryAllocatorDump {}, // MAD at timestamp 3. - * ] - */ - set memoryAllocatorDumps(memoryAllocatorDumps) { - this.memoryAllocatorDumps_ = memoryAllocatorDumps; - this.scheduleRebuildPane_(); - }, - - get memoryAllocatorDumps() { - return this.memoryAllocatorDumps_; - }, - - // TODO(petrcermak): Don't plumb the heap dumps through the allocator - // details pane. Maybe add support for multiple child panes to stacked pane - // (view) instead. - set heapDumps(heapDumps) { - this.heapDumps_ = heapDumps; - this.scheduleRebuildPane_(); - }, - - set aggregationMode(aggregationMode) { - this.aggregationMode_ = aggregationMode; - this.scheduleRebuildPane_(); - }, - - get aggregationMode() { - return this.aggregationMode_; - }, - - rebuildPane_: function() { - if (this.memoryAllocatorDumps_ === undefined || - this.memoryAllocatorDumps_.length === 0) { - // Show the info text (hide the table). - this.$.info_text.style.display = 'block'; - this.$.table.style.display = 'none'; - - this.$.table.clear(); - this.$.table.rebuild(); - - // Hide the heap details pane (if applicable). - this.childPaneBuilder = undefined; - return; - } - - // Show the table (hide the info text). - this.$.info_text.style.display = 'none'; - this.$.table.style.display = 'block'; - - var rows = this.createRows_(); - var columns = this.createColumns_(rows); - rows.forEach(function(rootRow) { - tr.ui.analysis.aggregateTableRowCellsRecursively(rootRow, columns, - function(contexts) { - // Only aggregate suballocation rows (numerics of regular rows - // corresponding to MADs have already been aggregated by the - // model in MemoryAllocatorDump.aggregateNumericsRecursively). - return contexts !== undefined && contexts.some(function(context) { - return context === SUBALLOCATION_CONTEXT; - }); - }); - }); - - this.$.table.tableRows = rows; - this.$.table.tableColumns = columns; - this.$.table.rebuild(); - tr.ui.analysis.expandTableRowsRecursively(this.$.table); - - // Show/hide the heap details pane. - if (this.heapDumps_ === undefined) { - this.childPaneBuilder = undefined; - } else { - this.childPaneBuilder = function() { - var pane = - document.createElement('tr-ui-a-memory-dump-heap-details-pane'); - pane.heapDumps = this.heapDumps_; - pane.aggregationMode = this.aggregationMode_; - return pane; - }.bind(this); - } - }, - - createRows_: function() { - return [ - this.createAllocatorRowRecursively_(this.memoryAllocatorDumps_) - ]; - }, - - createAllocatorRowRecursively_: function(dumps) { - // Get the name of the memory allocator dumps. We can use any defined - // dump in dumps since they all have the same name. - var definedDump = tr.b.findFirstInArray(dumps); - var title = definedDump.name; - var fullName = definedDump.fullName; - - // Transform a chronological list of memory allocator dumps into two - // dictionaries of cells (where each cell contains a chronological list - // of the values of one of its numerics or diagnostics). - var numericCells = tr.ui.analysis.createCells(dumps, function(dump) { - return dump.numerics; - }); - var diagnosticCells = tr.ui.analysis.createCells(dumps, function(dump) { - return dump.diagnostics; - }); - - // Determine whether the memory allocator dump is a suballocation. A - // dump is assumed to be a suballocation if (1) its name starts with - // two underscores, (2) it has an owner from within the same process at - // some timestamp, and (3) it is undefined, has no owners, or has the - // same owner (and no other owners) at all other timestamps. - var suballocatedBy = undefined; - if (title.startsWith('__')) { - for (var i = 0; i < dumps.length; i++) { - var dump = dumps[i]; - if (dump === undefined || dump.ownedBy.length === 0) { - // Ignore timestamps where the dump is undefined or doesn't - // have any owner. - continue; - } - var ownerDump = dump.ownedBy[0].source; - if (dump.ownedBy.length > 1 || - dump.children.length > 0 || - ownerDump.containerMemoryDump !== dump.containerMemoryDump) { - // If the dump has (1) any children, (2) multiple owners, or - // (3) its owner is in a different process (otherwise, the - // modified title would be ambiguous), then it's not considered - // to be a suballocation. - suballocatedBy = undefined; - break; - } - if (suballocatedBy === undefined) { - suballocatedBy = ownerDump.fullName; - } else if (suballocatedBy !== ownerDump.fullName) { - // The full name of the owner dump changed over time, so this - // dump is not a suballocation. - suballocatedBy = undefined; - break; - } - } - } - - var row = { - title: title, - fullNames: [fullName], - contexts: dumps, - numericCells: numericCells, - diagnosticCells: diagnosticCells, - suballocatedBy: suballocatedBy - }; - - // Child memory dump name (dict key) -> Timestamp (list index) -> - // Child dump. - var childDumpNameToDumps = tr.b.invertArrayOfDicts(dumps, - function(dump) { - return tr.b.arrayToDict(dump.children, function(child) { - return child.name; - }); - }); - - // Recursively create sub-rows for children (if applicable). - var subRows = []; - var suballocationClassificationRootNode = undefined; - tr.b.iterItems(childDumpNameToDumps, function(childName, childDumps) { - var childRow = this.createAllocatorRowRecursively_(childDumps); - if (childRow.suballocatedBy === undefined) { - // Not a suballocation row: just append it. - subRows.push(childRow); - } else { - // Suballocation row: classify it in a tree of suballocations. - suballocationClassificationRootNode = - this.classifySuballocationRow_( - childRow, suballocationClassificationRootNode); - } - }, this); - - // Build the tree of suballocations (if applicable). - if (suballocationClassificationRootNode !== undefined) { - var suballocationRow = this.createSuballocationRowRecursively_( - 'suballocations', suballocationClassificationRootNode); - subRows.push(suballocationRow); - } - - if (subRows.length > 0) - row.subRows = subRows; - - return row; - }, - - classifySuballocationRow_: function(suballocationRow, rootNode) { - if (rootNode === undefined) { - rootNode = { - children: {}, - row: undefined - }; - } - - var suballocationLevels = suballocationRow.suballocatedBy.split('/'); - var currentNode = rootNode; - for (var i = 0; i < suballocationLevels.length; i++) { - var suballocationLevel = suballocationLevels[i]; - var nextNode = currentNode.children[suballocationLevel]; - if (nextNode === undefined) { - currentNode.children[suballocationLevel] = nextNode = { - children: {}, - row: undefined - }; - } - var currentNode = nextNode; - } - - var existingRow = currentNode.row; - if (existingRow !== undefined) { - // On rare occasions it can happen that one dump (e.g. sqlite) owns - // different suballocations at different timestamps (e.g. - // malloc/allocated_objects/_7d35 and malloc/allocated_objects/_511e). - // When this happens, we merge the two suballocations into a single row - // (malloc/allocated_objects/suballocations/sqlite). - for (var i = 0; i < suballocationRow.contexts.length; i++) { - var newContext = suballocationRow.contexts[i]; - if (newContext === undefined) - continue; - - if (existingRow.contexts[i] !== undefined) - throw new Error('Multiple suballocations with the same owner name'); - - existingRow.contexts[i] = newContext; - ['numericCells', 'diagnosticCells'].forEach(function(cellKey) { - var suballocationCells = suballocationRow[cellKey]; - if (suballocationCells === undefined) - return; - tr.b.iterItems(suballocationCells, function(cellName, cell) { - if (cell === undefined) - return; - var fields = cell.fields; - if (fields === undefined) - return; - var field = fields[i]; - if (field === undefined) - return; - var existingCells = existingRow[cellKey]; - if (existingCells === undefined) { - existingCells = {}; - existingRow[cellKey] = existingCells; - } - var existingCell = existingCells[cellName]; - if (existingCell === undefined) { - existingCell = new tr.ui.analysis.MemoryCell( - new Array(fields.length)); - existingCells[cellName] = existingCell; - } - existingCell.fields[i] = field; - }); - }); - } - existingRow.fullNames.push.apply( - existingRow.fullNames, suballocationRow.fullNames); - } else { - currentNode.row = suballocationRow; - } - - return rootNode; - }, - - createSuballocationRowRecursively_: function(name, node) { - var childCount = Object.keys(node.children).length; - if (childCount === 0) { - if (node.row === undefined) - throw new Error('Suballocation node must have a row or children'); - // Leaf row of the suballocation tree: Change the row's title from - // '__MEANINGLESSHASH' to the name of the suballocation owner. - var row = node.row; - row.title = name; - row.suballocation = true; - return row; - } - - // Internal row of the suballocation tree: Recursively create its - // sub-rows. - var subRows = tr.b.dictionaryValues(tr.b.mapItems( - node.children, this.createSuballocationRowRecursively_, this)); - - if (node.row !== undefined) { - // Very unlikely case: Both an ancestor (e.g. 'skia') and one of its - // descendants (e.g. 'skia/sk_glyph_cache') both suballocate from the - // same MemoryAllocatorDump (e.g. 'malloc/allocated_objects'). In - // this case, the suballocation from the ancestor must be mapped to - // 'malloc/allocated_objects/suballocations/skia/<unspecified>' so - // that 'malloc/allocated_objects/suballocations/skia' could - // aggregate the numerics of the two suballocations properly. - var row = node.row; - row.title = '<unspecified>'; - row.suballocation = true; - subRows.unshift(row); - } - - // An internal row of the suballocation tree is assumed to be defined - // at a given timestamp if at least one of its sub-rows is defined at - // the timestamp. - var contexts = new Array(subRows[0].contexts.length); - for (var i = 0; i < subRows.length; i++) { - subRows[i].contexts.forEach(function(subContext, index) { - if (subContext !== undefined) - contexts[index] = SUBALLOCATION_CONTEXT; - }); - } - - return { - title: name, - suballocation: true, - contexts: contexts, - subRows: subRows - }; - }, - - createColumns_: function(rows) { - var titleColumn = new AllocatorDumpNameColumn(); - titleColumn.width = '200px'; - - var numericColumns = tr.ui.analysis.MemoryColumn.fromRows( - rows, 'numericCells', this.aggregationMode_, NUMERIC_COLUMN_RULES); - var diagnosticColumns = tr.ui.analysis.MemoryColumn.fromRows( - rows, 'diagnosticCells', this.aggregationMode_, - DIAGNOSTIC_COLUMN_RULES); - var fieldColumns = numericColumns.concat(diagnosticColumns); - tr.ui.analysis.MemoryColumn.spaceEqually(fieldColumns); - - var columns = [titleColumn].concat(fieldColumns); - return columns; - } - }); - - return { - // All exports are for testing only. - SUBALLOCATION_CONTEXT: SUBALLOCATION_CONTEXT, - AllocatorDumpNameColumn: AllocatorDumpNameColumn, - EffectiveSizeColumn: EffectiveSizeColumn, - SizeColumn: SizeColumn - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/memory_dump_allocator_details_pane_test.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/memory_dump_allocator_details_pane_test.html deleted file mode 100644 index cc0f99ffc81..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/memory_dump_allocator_details_pane_test.html +++ /dev/null @@ -1,1214 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/iteration_helpers.html"> -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/heap_dump.html"> -<link rel="import" href="/tracing/model/memory_allocator_dump.html"> -<link rel="import" href="/tracing/model/memory_dump_test_utils.html"> -<link rel="import" - href="/tracing/ui/analysis/memory_dump_allocator_details_pane.html"> -<link rel="import" - href="/tracing/ui/analysis/memory_dump_sub_view_test_utils.html"> -<link rel="import" href="/tracing/ui/analysis/memory_dump_sub_view_util.html"> -<link rel="import" href="/tracing/value/numeric.html"> -<link rel="import" href="/tracing/value/unit.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var MemoryAllocatorDump = tr.model.MemoryAllocatorDump; - var ScalarNumeric = tr.v.ScalarNumeric; - var unitlessNumber_smallerIsBetter = - tr.v.Unit.byName.unitlessNumber_smallerIsBetter; - var sizeInBytes_smallerIsBetter = - tr.v.Unit.byName.sizeInBytes_smallerIsBetter; - var HeapDump = tr.model.HeapDump; - var AggregationMode = tr.ui.analysis.MemoryColumn.AggregationMode; - var checkNumericFields = tr.ui.analysis.checkNumericFields; - var checkSizeNumericFields = tr.ui.analysis.checkSizeNumericFields; - var checkStringFields = tr.ui.analysis.checkStringFields; - var checkColumnInfosAndColor = tr.ui.analysis.checkColumnInfosAndColor; - var checkColumns = tr.ui.analysis.checkColumns; - var isElementDisplayed = tr.ui.analysis.isElementDisplayed; - var AllocatorDumpNameColumn = tr.ui.analysis.AllocatorDumpNameColumn; - var EffectiveSizeColumn = tr.ui.analysis.EffectiveSizeColumn; - var SizeColumn = tr.ui.analysis.SizeColumn; - var StringMemoryColumn = tr.ui.analysis.StringMemoryColumn; - var NumericMemoryColumn = tr.ui.analysis.NumericMemoryColumn; - var addGlobalMemoryDump = tr.model.MemoryDumpTestUtils.addGlobalMemoryDump; - var addProcessMemoryDump = tr.model.MemoryDumpTestUtils.addProcessMemoryDump; - var newAllocatorDump = tr.model.MemoryDumpTestUtils.newAllocatorDump; - var addChildDump = tr.model.MemoryDumpTestUtils.addChildDump; - var addOwnershipLink = tr.model.MemoryDumpTestUtils.addOwnershipLink; - - var SUBALLOCATION_CONTEXT = tr.ui.analysis.SUBALLOCATION_CONTEXT; - var MemoryAllocatorDumpInfoType = tr.model.MemoryAllocatorDumpInfoType; - var PROVIDED_SIZE_LESS_THAN_AGGREGATED_CHILDREN = - MemoryAllocatorDumpInfoType.PROVIDED_SIZE_LESS_THAN_AGGREGATED_CHILDREN; - var PROVIDED_SIZE_LESS_THAN_LARGEST_OWNER = - MemoryAllocatorDumpInfoType.PROVIDED_SIZE_LESS_THAN_LARGEST_OWNER; - - function addRootDumps(containerMemoryDump, rootNames, addedCallback) { - // Test sanity check. - assert.isUndefined(containerMemoryDump.memoryAllocatorDumps); - - var rootDumps = rootNames.map(function(rootName) { - return new MemoryAllocatorDump(containerMemoryDump, rootName); - }); - addedCallback.apply(null, rootDumps); - containerMemoryDump.memoryAllocatorDumps = rootDumps; - } - - function newSuballocationDump(ownerDump, parentDump, name, size) { - var suballocationDump = addChildDump(parentDump, name, { size: size }); - if (ownerDump !== undefined) - addOwnershipLink(ownerDump, suballocationDump); - return suballocationDump; - } - - function createProcessMemoryDumps() { - var model = tr.c.TestUtils.newModel(function(model) { - var process = model.getOrCreateProcess(1); - - // First timestamp. - var gmd1 = addGlobalMemoryDump(model, -10); - var pmd1 = addProcessMemoryDump(gmd1, process, -11); - pmd1.memoryAllocatorDumps = (function() { - var v8Dump = newAllocatorDump(pmd1, 'v8', { - size: 1073741824 /* 1 GiB */, - inner_size: 2097152 /* 2 MiB */, - objects_count: new ScalarNumeric(unitlessNumber_smallerIsBetter, 204) - }); - - var v8HeapsDump = addChildDump(v8Dump, 'heaps', - { size: 805306368 /* 768 MiB */ }); - addChildDump(v8HeapsDump, 'heap42', - { size: 804782080 /* 767.5 MiB */ }); - - var v8ObjectsDump = addChildDump(v8Dump, 'objects'); - v8ObjectsDump.addDiagnostic('url', 'http://example.com'); - addChildDump(v8ObjectsDump, 'foo', { size: 1022976 /* 999 KiB */ }); - addChildDump(v8ObjectsDump, 'bar', { size: 1024000 /* 1000 KiB */ }); - - var oilpanDump = newAllocatorDump(pmd1, 'oilpan', - { size: 125829120 /* 120 MiB */ }); - newSuballocationDump( - oilpanDump, v8Dump, '__99BEAD', 150994944 /* 144 MiB */); - - var oilpanSubDump = addChildDump(oilpanDump, 'animals'); - - var oilpanSubDump1 = addChildDump(oilpanSubDump, 'cow', - { size: 33554432 /* 32 MiB */ }); - newSuballocationDump( - oilpanSubDump1, v8Dump, '__42BEEF', 67108864 /* 64 MiB */); - - var oilpanSubDump2 = addChildDump(oilpanSubDump, 'chicken', - { size: 16777216 /* 16 MiB */ }); - newSuballocationDump( - oilpanSubDump2, v8Dump, '__68DEAD', 33554432 /* 32 MiB */); - - var skiaDump = newAllocatorDump(pmd1, 'skia', - { size: 8388608 /* 8 MiB */ }); - var suballocationDump = newSuballocationDump( - skiaDump, v8Dump, '__15FADE', 16777216 /* 16 MiB */); - - var ccDump = newAllocatorDump(pmd1, 'cc', - { size: 4194304 /* 4 MiB */ }); - newSuballocationDump( - ccDump, v8Dump, '__12FEED', 5242880 /* 5 MiB */).addDiagnostic( - 'url', 'localhost:1234'); - - return [v8Dump, oilpanDump, skiaDump, ccDump]; - })(); - - // Second timestamp. - var gmd2 = addGlobalMemoryDump(model, 10); - var pmd2 = addProcessMemoryDump(gmd2, process, 11); - pmd2.memoryAllocatorDumps = (function() { - var v8Dump = newAllocatorDump(pmd2, 'v8', { - size: 1073741824 /* 1 GiB */, - inner_size: 2097152 /* 2 MiB */, - objects_count: new ScalarNumeric(unitlessNumber_smallerIsBetter, 204) - }); - - var v8ObjectsDump = addChildDump(v8Dump, 'objects'); - v8ObjectsDump.addDiagnostic('url', 'http://sample.net'); - addChildDump(v8ObjectsDump, 'foo', { size: 1020928 /* 997 KiB */ }); - addChildDump(v8ObjectsDump, 'bar', { size: 1026048 /* 1002 KiB */ }); - - newSuballocationDump( - undefined, v8Dump, '__99BEAD', 268435456 /* 256 MiB */); - - var ccDump = newAllocatorDump(pmd2, 'cc', - { size: 7340032 /* 7 MiB */ }); - newSuballocationDump( - ccDump, v8Dump, '__13DEED', 11534336 /* 11 MiB */).addDiagnostic( - 'url', 'localhost:5678'); - - return [v8Dump, ccDump]; - })(); - }); - - return model.processes[1].memoryDumps; - } - - function createSizeFields(values) { - return values.map(function(value) { - if (value === undefined) - return undefined; - return new ScalarNumeric(sizeInBytes_smallerIsBetter, value); - }); - } - - var EXPECTED_COLUMNS = [ - { title: 'Component', type: AllocatorDumpNameColumn, noAggregation: true }, - { title: 'effective_size', type: EffectiveSizeColumn }, - { title: 'size', type: SizeColumn }, - { title: 'inner_size', type: NumericMemoryColumn }, - { title: 'objects_count', type: NumericMemoryColumn }, - { title: 'url', type: StringMemoryColumn } - ]; - - function checkRow(columns, row, expectations) { - var formattedTitle = columns[0].formatTitle(row); - var expectedTitle = expectations.title; - if (typeof expectedTitle === 'function') - expectedTitle(formattedTitle); - else - assert.equal(formattedTitle, expectedTitle); - - checkSizeNumericFields(row, columns[1], expectations.size); - checkSizeNumericFields(row, columns[2], expectations.effective_size); - checkSizeNumericFields(row, columns[3], expectations.inner_size); - checkNumericFields(row, columns[4], expectations.objects_count, - unitlessNumber_smallerIsBetter); - checkStringFields(row, columns[5], expectations.url); - - var expectedSubRowCount = expectations.sub_row_count; - if (expectedSubRowCount === undefined) - assert.isUndefined(row.subRows); - else - assert.lengthOf(row.subRows, expectedSubRowCount); - - var expectedContexts = expectations.contexts; - if (expectedContexts === undefined) - assert.isUndefined(row.contexts); - else - assert.deepEqual(tr.b.asArray(row.contexts), expectedContexts); - } - - function buildProcessMemoryDumps(count, preFinalizeDumpsCallback) { - var pmds = new Array(count); - tr.c.TestUtils.newModel(function(model) { - var process = model.getOrCreateProcess(1); - for (var i = 0; i < count; i++) { - var timestamp = 10 + i; - var gmd = addGlobalMemoryDump(model, timestamp); - pmds[i] = addProcessMemoryDump(gmd, process, timestamp); - } - preFinalizeDumpsCallback(pmds); - }); - return pmds; - } - - function getAllocatorDumps(pmds, fullName) { - return pmds.map(function(pmd) { - if (pmd === undefined) - return undefined; - return pmd.getMemoryAllocatorDumpByFullName(fullName); - }); - } - - function checkAllocatorPaneColumnInfosAndColor( - column, dumps, numericName, expectedInfos) { - var numerics = dumps.map(function(dump) { - if (dump === undefined) - return undefined; - return dump.numerics[numericName]; - }); - checkColumnInfosAndColor( - column, numerics, dumps, expectedInfos, undefined /* no color */); - } - - test('instantiate_empty', function() { - tr.ui.analysis.createAndCheckEmptyPanes(this, - 'tr-ui-a-memory-dump-allocator-details-pane', 'memoryAllocatorDumps', - function(viewEl) { - // Check that the info text is shown. - assert.isTrue(isElementDisplayed(viewEl.$.info_text)); - assert.isFalse(isElementDisplayed(viewEl.$.table)); - }); - }); - - test('instantiate_single', function() { - var processMemoryDumps = createProcessMemoryDumps().slice(0, 1); - - var viewEl = tr.ui.analysis.createTestPane( - 'tr-ui-a-memory-dump-allocator-details-pane'); - viewEl.memoryAllocatorDumps = getAllocatorDumps(processMemoryDumps, 'v8'); - viewEl.rebuild(); - assert.deepEqual(viewEl.requestedChildPanes, [undefined]); - this.addHTMLOutput(viewEl); - - // Check that the table is shown. - assert.isTrue(isElementDisplayed(viewEl.$.table)); - assert.isFalse(isElementDisplayed(viewEl.$.info_text)); - - var table = viewEl.$.table; - var columns = table.tableColumns; - checkColumns(columns, EXPECTED_COLUMNS, undefined /* no aggregation */); - var rows = table.tableRows; - assert.lengthOf(rows, 1); - - // Check the rows of the table. - var rootRow = rows[0]; - checkRow(columns, rootRow, { - title: 'v8', - size: [942619648], - effective_size: [1081031680], - inner_size: [2097152], - objects_count: [204], - sub_row_count: 3, - contexts: getAllocatorDumps(processMemoryDumps, 'v8'), - }); - - var heapsSubRow = rootRow.subRows[0]; - checkRow(columns, heapsSubRow, { - title: 'heaps', - size: [805306368], - effective_size: [805306368], - sub_row_count: 2, - contexts: getAllocatorDumps(processMemoryDumps, 'v8/heaps'), - }); - - var heapsUnspecifiedSubRow = heapsSubRow.subRows[0]; - checkRow(columns, heapsUnspecifiedSubRow, { - title: '<unspecified>', - size: [524288], - effective_size: [524288], - contexts: getAllocatorDumps(processMemoryDumps, 'v8/heaps/<unspecified>'), - }); - - var suballocationsSubRow = rootRow.subRows[2]; - checkRow(columns, suballocationsSubRow, { - title: function(formattedTitle) { - assert.equal(formattedTitle.textContent, 'suballocations'); - assert.equal(formattedTitle.title, ''); - }, - size: [135266304], - effective_size: [273678336], - sub_row_count: 3, - contexts: [SUBALLOCATION_CONTEXT], - }); - - var oilpanSuballocationSubRow = suballocationsSubRow.subRows[0]; - checkRow(columns, oilpanSuballocationSubRow, { - title: function(formattedTitle) { - assert.equal(formattedTitle.textContent, 'oilpan'); - assert.equal(formattedTitle.title, ''); - }, - size: [125829120], - effective_size: [251658240], - sub_row_count: 2, - contexts: [SUBALLOCATION_CONTEXT], - }); - - var oilpanUnspecifiedSuballocationSubRow = - oilpanSuballocationSubRow.subRows[0]; - checkRow(columns, oilpanUnspecifiedSuballocationSubRow, { - title: function(formattedTitle) { - assert.equal(formattedTitle.textContent, '<unspecified>'); - assert.equal(formattedTitle.title, 'v8/__99BEAD'); - }, - size: [75497472], - effective_size: [150994944], - contexts: getAllocatorDumps(processMemoryDumps, 'v8/__99BEAD'), - }); - - var oilpanAnimalsSuballocationSubRow = oilpanSuballocationSubRow.subRows[1]; - checkRow(columns, oilpanAnimalsSuballocationSubRow, { - title: function(formattedTitle) { - assert.equal(formattedTitle.textContent, 'animals'); - assert.equal(formattedTitle.title, ''); - }, - size: [50331648], - effective_size: [100663296], - sub_row_count: 2, - contexts: [SUBALLOCATION_CONTEXT], - }); - - var oilpanCowSuballocationSubRow = - oilpanAnimalsSuballocationSubRow.subRows[0]; - checkRow(columns, oilpanCowSuballocationSubRow, { - title: function(formattedTitle) { - assert.equal(formattedTitle.textContent, 'cow'); - assert.equal(formattedTitle.title, 'v8/__42BEEF'); - }, - size: [33554432], - effective_size: [67108864], - contexts: getAllocatorDumps(processMemoryDumps, 'v8/__42BEEF'), - }); - - var skiaSuballocationSubRow = suballocationsSubRow.subRows[1]; - checkRow(columns, skiaSuballocationSubRow, { - title: function(formattedTitle) { - assert.equal(formattedTitle.textContent, 'skia'); - assert.equal(formattedTitle.title, 'v8/__15FADE'); - }, - size: [8388608], - effective_size: [16777216], - contexts: getAllocatorDumps(processMemoryDumps, 'v8/__15FADE'), - }); - - var ccSuballocationSubRow = suballocationsSubRow.subRows[2]; - checkRow(columns, ccSuballocationSubRow, { - title: function(formattedTitle) { - assert.equal(formattedTitle.textContent, 'cc'); - assert.equal(formattedTitle.title, 'v8/__12FEED'); - }, - size: [1048576], - effective_size: [5242880], - url: ['localhost:1234'], - contexts: getAllocatorDumps(processMemoryDumps, 'v8/__12FEED') - }); - }); - - test('instantiate_multipleDiff', function() { - var processMemoryDumps = createProcessMemoryDumps(); - - var viewEl = tr.ui.analysis.createTestPane( - 'tr-ui-a-memory-dump-allocator-details-pane'); - viewEl.memoryAllocatorDumps = getAllocatorDumps(processMemoryDumps, 'v8'); - viewEl.aggregationMode = AggregationMode.DIFF; - viewEl.rebuild(); - assert.deepEqual(viewEl.requestedChildPanes, [undefined]); - this.addHTMLOutput(viewEl); - - // Check that the table is shown. - assert.isTrue(isElementDisplayed(viewEl.$.table)); - assert.isFalse(isElementDisplayed(viewEl.$.info_text)); - - var table = viewEl.$.table; - var columns = table.tableColumns; - checkColumns(columns, EXPECTED_COLUMNS, AggregationMode.DIFF); - var rows = table.tableRows; - assert.lengthOf(rows, 1); - - // Check the rows of the table. - var rootRow = rows[0]; - checkRow(columns, rootRow, { - title: 'v8', - size: [942619648, 1066401792], - effective_size: [1081031680, 1073741824], - inner_size: [2097152, 2097152], - objects_count: [204, 204], - sub_row_count: 4, - contexts: getAllocatorDumps(processMemoryDumps, 'v8'), - }); - - var heapsSubRow = rootRow.subRows[0]; - checkRow(columns, heapsSubRow, { - title: 'heaps', - size: [805306368, undefined], - effective_size: [805306368, undefined], - sub_row_count: 2, - contexts: getAllocatorDumps(processMemoryDumps, 'v8/heaps'), - }); - - var heapsUnspecifiedSubRow = heapsSubRow.subRows[0]; - checkRow(columns, heapsUnspecifiedSubRow, { - title: '<unspecified>', - size: [524288, undefined], - effective_size: [524288, undefined], - contexts: getAllocatorDumps(processMemoryDumps, 'v8/heaps/<unspecified>'), - }); - - var unspecifiedSubRow = rootRow.subRows[2]; - checkRow(columns, unspecifiedSubRow, { - title: '<unspecified>', - size: [undefined, 791725056], - effective_size: [undefined, 791725056], - contexts: getAllocatorDumps(processMemoryDumps, 'v8/<unspecified>'), - }); - - var suballocationsSubRow = rootRow.subRows[3]; - checkRow(columns, suballocationsSubRow, { - title: function(formattedTitle) { - assert.equal(formattedTitle.textContent, 'suballocations'); - assert.equal(formattedTitle.title, ''); - }, - size: [135266304, 272629760], - effective_size: [273678336, 279969792], - sub_row_count: 3, - contexts: [SUBALLOCATION_CONTEXT, SUBALLOCATION_CONTEXT], - }); - - var oilpanSuballocationSubRow = suballocationsSubRow.subRows[0]; - checkRow(columns, oilpanSuballocationSubRow, { - title: function(formattedTitle) { - assert.equal(formattedTitle.textContent, 'oilpan'); - assert.equal(formattedTitle.title, ''); - }, - size: [125829120, 268435456], - effective_size: [251658240, 268435456], - sub_row_count: 2, - contexts: [SUBALLOCATION_CONTEXT, SUBALLOCATION_CONTEXT], - }); - - var oilpanUnspecifiedSuballocationSubRow = - oilpanSuballocationSubRow.subRows[0]; - checkRow(columns, oilpanUnspecifiedSuballocationSubRow, { - title: function(formattedTitle) { - assert.equal(formattedTitle.textContent, '<unspecified>'); - assert.equal(formattedTitle.title, 'v8/__99BEAD'); - }, - size: [75497472, 268435456], - effective_size: [150994944, 268435456], - contexts: getAllocatorDumps(processMemoryDumps, 'v8/__99BEAD'), - }); - - var oilpanAnimalsSuballocationSubRow = oilpanSuballocationSubRow.subRows[1]; - checkRow(columns, oilpanAnimalsSuballocationSubRow, { - title: function(formattedTitle) { - assert.equal(formattedTitle.textContent, 'animals'); - assert.equal(formattedTitle.title, ''); - }, - size: [50331648, undefined], - effective_size: [100663296, undefined], - sub_row_count: 2, - contexts: [SUBALLOCATION_CONTEXT, undefined], - }); - - var oilpanCowSuballocationSubRow = - oilpanAnimalsSuballocationSubRow.subRows[0]; - checkRow(columns, oilpanCowSuballocationSubRow, { - title: function(formattedTitle) { - assert.equal(formattedTitle.textContent, 'cow'); - assert.equal(formattedTitle.title, 'v8/__42BEEF'); - }, - size: [33554432, undefined], - effective_size: [67108864, undefined], - contexts: getAllocatorDumps(processMemoryDumps, 'v8/__42BEEF'), - }); - - var skiaSuballocationSubRow = suballocationsSubRow.subRows[1]; - checkRow(columns, skiaSuballocationSubRow, { - title: function(formattedTitle) { - assert.equal(formattedTitle.textContent, 'skia'); - assert.equal(formattedTitle.title, 'v8/__15FADE'); - }, - size: [8388608, undefined], - effective_size: [16777216, undefined], - contexts: getAllocatorDumps(processMemoryDumps, 'v8/__15FADE'), - }); - - var ccSuballocationSubRow = suballocationsSubRow.subRows[2]; - checkRow(columns, ccSuballocationSubRow, { - title: function(formattedTitle) { - assert.equal(formattedTitle.textContent, 'cc'); - assert.equal(formattedTitle.title, 'v8/__12FEED, v8/__13DEED'); - }, - size: [1048576, 4194304], - effective_size: [5242880, 11534336], - url: ['localhost:1234', 'localhost:5678'], - contexts: [ - processMemoryDumps[0].getMemoryAllocatorDumpByFullName('v8/__12FEED'), - processMemoryDumps[1].getMemoryAllocatorDumpByFullName('v8/__13DEED') - ] - }); - }); - - test('instantiate_multipleMax', function() { - var processMemoryDumps = createProcessMemoryDumps(); - - var viewEl = tr.ui.analysis.createTestPane( - 'tr-ui-a-memory-dump-allocator-details-pane'); - viewEl.memoryAllocatorDumps = getAllocatorDumps(processMemoryDumps, 'v8'); - viewEl.aggregationMode = AggregationMode.MAX; - viewEl.rebuild(); - assert.deepEqual(viewEl.requestedChildPanes, [undefined]); - this.addHTMLOutput(viewEl); - - // Check that the table is shown. - assert.isTrue(isElementDisplayed(viewEl.$.table)); - assert.isFalse(isElementDisplayed(viewEl.$.info_text)); - - // Just check that the aggregation mode was propagated to the columns. - var table = viewEl.$.table; - var columns = table.tableColumns; - checkColumns(columns, EXPECTED_COLUMNS, AggregationMode.MAX); - var rows = table.tableRows; - assert.lengthOf(rows, 1); - }); - - test('instantiate_multipleWithUndefined', function() { - var processMemoryDumps = createProcessMemoryDumps(); - processMemoryDumps.splice(1, 0, undefined); - - var viewEl = tr.ui.analysis.createTestPane( - 'tr-ui-a-memory-dump-allocator-details-pane'); - viewEl.memoryAllocatorDumps = getAllocatorDumps(processMemoryDumps, 'v8'); - viewEl.aggregationMode = AggregationMode.DIFF; - viewEl.rebuild(); - assert.deepEqual(viewEl.requestedChildPanes, [undefined]); - this.addHTMLOutput(viewEl); - - // Check that the table is shown. - assert.isTrue(isElementDisplayed(viewEl.$.table)); - assert.isFalse(isElementDisplayed(viewEl.$.info_text)); - - var table = viewEl.$.table; - var columns = table.tableColumns; - checkColumns(columns, EXPECTED_COLUMNS, AggregationMode.DIFF); - var rows = table.tableRows; - assert.lengthOf(rows, 1); - - // Check only a few rows of the table. - var rootRow = rows[0]; - checkRow(columns, rootRow, { - title: 'v8', - size: [942619648, undefined, 1066401792], - effective_size: [1081031680, undefined, 1073741824], - inner_size: [2097152, undefined, 2097152], - objects_count: [204, undefined, 204], - sub_row_count: 4, - contexts: getAllocatorDumps(processMemoryDumps, 'v8'), - }); - - var unspecifiedSubRow = rootRow.subRows[2]; - checkRow(columns, unspecifiedSubRow, { - title: '<unspecified>', - size: [undefined, undefined, 791725056], - effective_size: [undefined, undefined, 791725056], - contexts: getAllocatorDumps(processMemoryDumps, 'v8/<unspecified>'), - }); - - var suballocationsSubRow = rootRow.subRows[3]; - checkRow(columns, suballocationsSubRow, { - title: function(formattedTitle) { - assert.equal(formattedTitle.textContent, 'suballocations'); - assert.equal(formattedTitle.title, ''); - }, - size: [135266304, undefined, 272629760], - effective_size: [273678336, undefined, 279969792], - sub_row_count: 3, - contexts: [SUBALLOCATION_CONTEXT, undefined, SUBALLOCATION_CONTEXT], - }); - }); - - test('heapDumpsPassThrough', function() { - var processMemoryDumps = createProcessMemoryDumps(); - var heapDumps = processMemoryDumps.map(function(dump) { - if (dump === undefined) - return undefined; - return new HeapDump(dump, 'v8'); - }); - - // Start by creating a component details pane without any heap dumps. - var viewEl = tr.ui.analysis.createTestPane( - 'tr-ui-a-memory-dump-allocator-details-pane'); - viewEl.memoryAllocatorDumps = getAllocatorDumps(processMemoryDumps, 'v8'); - viewEl.aggregationMode = AggregationMode.MAX; - viewEl.rebuild(); - - assert.lengthOf(viewEl.requestedChildPanes, 1); - assert.isUndefined(viewEl.requestedChildPanes[0]); - - // Set the heap dumps. This should trigger creating a heap details pane. - viewEl.heapDumps = heapDumps; - viewEl.aggregationMode = AggregationMode.DIFF; - viewEl.rebuild(); - - assert.lengthOf(viewEl.requestedChildPanes, 2); - assert.strictEqual(viewEl.requestedChildPanes[1].tagName, - 'TR-UI-A-MEMORY-DUMP-HEAP-DETAILS-PANE'); - assert.strictEqual(viewEl.requestedChildPanes[1].heapDumps, heapDumps); - assert.strictEqual(viewEl.requestedChildPanes[1].aggregationMode, - AggregationMode.DIFF); - - // Unset the heap dumps. This should trigger removing the heap details pane. - viewEl.heapDumps = undefined; - viewEl.rebuild(); - - assert.lengthOf(viewEl.requestedChildPanes, 3); - assert.isUndefined(viewEl.requestedChildPanes[2]); - }); - - test('allocatorDumpNameColumn', function() { - var c = new AllocatorDumpNameColumn(); - - // Regular row. - assert.strictEqual(c.formatTitle({title: 'Regular row'}), 'Regular row'); - - // Sub-allocation row. - var row = c.formatTitle({title: 'Suballocation row', suballocation: true}); - assert.strictEqual(row.textContent, 'Suballocation row'); - assert.strictEqual(row.style.fontStyle, 'italic'); - }); - - test('effectiveSizeColumn_noContext', function() { - var c = new EffectiveSizeColumn('Effective Size', 'bytes', tr.b.identity, - AggregationMode.DIFF); - - // Single selection. - checkColumnInfosAndColor(c, - createSizeFields([128]), - undefined /* no context */, - [] /* no infos */, - undefined /* no color */); - - // Multi-selection. - checkColumnInfosAndColor(c, - createSizeFields([128, 256, undefined, 64]), - undefined /* no context */, - [] /* no infos */, - undefined /* no color */); - }); - - test('effectiveSizeColumn_suballocationContext', function() { - var c = new EffectiveSizeColumn('Effective Size', 'bytes', tr.b.identity, - AggregationMode.MAX); - - // Single selection. - checkColumnInfosAndColor(c, - createSizeFields([128]), - [SUBALLOCATION_CONTEXT], - [] /* no infos */, - undefined /* no color */); - - // Multi-selection. - checkColumnInfosAndColor(c, - createSizeFields([undefined, 256, undefined, 64]), - [undefined, SUBALLOCATION_CONTEXT, SUBALLOCATION_CONTEXT, - SUBALLOCATION_CONTEXT], - [] /* no infos */, - undefined /* no color */); - }); - - test('effectiveSizeColumn_dumpContext_noOwnership', function() { - var c = new EffectiveSizeColumn('Effective Size', 'bytes', tr.b.identity, - AggregationMode.DIFF); - var pmds = buildProcessMemoryDumps(4 /* count */, function(pmds) { - addRootDumps(pmds[0], ['v8'], function(v8Dump) { - addChildDump(v8Dump, 'heaps', { size: 64 }); - }); - addRootDumps(pmds[2], ['v8'], function(v8Dump) { - addChildDump(v8Dump, 'heaps', { size: 128 }); - }); - addRootDumps(pmds[3], ['v8'], function(v8Dump) {}); - }); - var v8HeapsDumps = getAllocatorDumps(pmds, 'v8/heaps'); - - // Single selection. - checkAllocatorPaneColumnInfosAndColor(c, - [v8HeapsDumps[0]], - 'effective_size', - [] /* no infos */); - - // Multi-selection, all dumps defined. - checkAllocatorPaneColumnInfosAndColor(c, - [v8HeapsDumps[0], v8HeapsDumps[2]], - 'effective_size', - [] /* no infos */); - - // Multi-selection, some dumps missing. - checkAllocatorPaneColumnInfosAndColor(c, - v8HeapsDumps, - 'effective_size', - [] /* no infos */); - }); - - test('effectiveSizeColumn_dumpContext_singleOwnership', function() { - var c = new EffectiveSizeColumn('Effective Size', 'bytes', tr.b.identity, - AggregationMode.MAX); - var pmds = buildProcessMemoryDumps(5 /* count */, function(pmds) { - addRootDumps(pmds[0], ['v8', 'oilpan'], function(v8Dump, oilpanDump) { - var v8HeapsDump = addChildDump(v8Dump, 'heaps', { size: 32 }); - var oilpanObjectsDump = - addChildDump(oilpanDump, 'objects', { size: 64 }); - addOwnershipLink(v8HeapsDump, oilpanObjectsDump); - }); - addRootDumps(pmds[1], ['v8'], function(v8Dump) { - addChildDump(v8Dump, 'heaps', { size: 32 }); - // Missing oilpan/objects dump. - }); - addRootDumps(pmds[2], ['v8', 'oilpan'], function(v8Dump, oilpanDump) { - addChildDump(oilpanDump, 'objects', { size: 64 }); - // Missing v8/heaps dump. - }); - addRootDumps(pmds[3], ['v8', 'oilpan'], function(v8Dump, oilpanDump) { - addChildDump(v8Dump, 'heaps', { size: 32 }); - addChildDump(oilpanDump, 'objects', { size: 64 }); - // Missing ownership link. - }); - addRootDumps(pmds[4], ['v8', 'oilpan'], function(v8Dump, oilpanDump) { - var v8HeapsDump = addChildDump(v8Dump, 'heaps', { size: 32 }); - var oilpanObjectsDump = - addChildDump(oilpanDump, 'objects', { size: 64 }); - addOwnershipLink(v8HeapsDump, oilpanObjectsDump, 2); - }); - }); - var v8HeapsDump = getAllocatorDumps(pmds, 'v8/heaps'); - var oilpanObjectsDump = getAllocatorDumps(pmds, 'oilpan/objects'); - - // Single selection. - checkAllocatorPaneColumnInfosAndColor(c, - [v8HeapsDump[0]], - 'effective_size', - [ - { - icon: '\u21FE', - message: 'shares \'oilpan/objects\' in Process 1 (importance: 0) ' + - 'with no other dumps', - color: 'green' - } - ]); - checkAllocatorPaneColumnInfosAndColor(c, - [oilpanObjectsDump[4]], - 'effective_size', - [ - { - icon: '\u21FD', - message: 'shared by \'v8/heaps\' in Process 1 (importance: 2)', - color: 'green' - } - ]); - - // Multi-selection, all dumps defined. - checkAllocatorPaneColumnInfosAndColor(c, - [v8HeapsDump[0], v8HeapsDump[4]], - 'effective_size', - [ - { - icon: '\u21FE', - message: 'shares \'oilpan/objects\' in Process 1 (importance: ' + - '0\u20132) with no other dumps', - color: 'green' - } - ]); - checkAllocatorPaneColumnInfosAndColor(c, - [oilpanObjectsDump[0], oilpanObjectsDump[4]], - 'effective_size', - [ - { - icon: '\u21FD', - message: 'shared by \'v8/heaps\' in Process 1 (importance: ' + - '0\u20132)', - color: 'green' - } - ]); - - // Multi-selection, some dumps missing. - checkAllocatorPaneColumnInfosAndColor(c, - v8HeapsDump, - 'effective_size', - [ - { - icon: '\u21FE', - message: 'shares \'oilpan/objects\' in Process 1 at some ' + - 'selected timestamps (importance: 0\u20132) with no other ' + - 'dumps', - color: 'green' - } - ]); - checkAllocatorPaneColumnInfosAndColor(c, - oilpanObjectsDump, - 'effective_size', - [ - { - icon: '\u21FD', - message: 'shared by \'v8/heaps\' in Process 1 at some selected ' + - 'timestamps (importance: 0\u20132)', - color: 'green' - } - ]); - }); - - test('effectiveSizeColumn_dumpContext_multipleOwnerships', function() { - var c = new EffectiveSizeColumn('Effective Size', 'bytes', tr.b.identity, - AggregationMode.DIFF); - var pmds = buildProcessMemoryDumps(6 /* count */, function(pmds) { - addRootDumps(pmds[0], ['v8', 'oilpan'], function(v8Dump, oilpanDump) { - var v8HeapsDump = addChildDump(v8Dump, 'heaps', { size: 32 }); - var v8QueuesDump = addChildDump(v8Dump, 'queues', { size: 8 }); - var oilpanObjectsDump = - addChildDump(oilpanDump, 'objects', { size: 64 }); - addOwnershipLink(v8HeapsDump, oilpanObjectsDump); - addOwnershipLink(v8QueuesDump, oilpanObjectsDump, 1); - }); - addRootDumps(pmds[1], ['v8'], function(v8Dump) {}); - addRootDumps(pmds[2], ['v8', 'oilpan'], function(v8Dump, oilpanDump) { - var v8HeapsDump = addChildDump(v8Dump, 'heaps', { size: 32 }); - var v8QueuesDump = addChildDump(v8Dump, 'queues', { size: 8 }); - var v8PilesDump = addChildDump(v8Dump, 'piles', { size: 48 }); - var oilpanObjectsDump = - addChildDump(oilpanDump, 'objects', { size: 64 }); - addOwnershipLink(v8HeapsDump, oilpanObjectsDump, 2); - addOwnershipLink(v8QueuesDump, oilpanObjectsDump, 1); - addOwnershipLink(v8PilesDump, oilpanObjectsDump); - }); - addRootDumps(pmds[3], ['v8', 'blink'], function(v8Dump, blinkDump) { - var blinkHandlesDump = addChildDump(blinkDump, 'handles', { size: 32 }); - var v8HeapsDump = addChildDump(v8Dump, 'heaps', { size: 64 }); - var blinkObjectsDump = addChildDump(blinkDump, 'objects', { size: 32 }); - addOwnershipLink(blinkHandlesDump, v8HeapsDump, -273); - addOwnershipLink(v8HeapsDump, blinkObjectsDump, 3); - }); - addRootDumps(pmds[4], ['v8', 'gpu'], function(v8Dump, gpuDump) { - var v8HeapsDump = addChildDump(v8Dump, 'heaps', { size: 64 }); - var gpuTile1Dump = addChildDump(gpuDump, 'tile1', { size: 100 }); - var gpuTile2Dump = addChildDump(gpuDump, 'tile2', { size: 99 }); - addOwnershipLink(v8HeapsDump, gpuTile1Dump, 3); - addOwnershipLink(gpuTile2Dump, gpuTile1Dump, -1); - }); - addRootDumps(pmds[5], ['v8', 'oilpan'], function(v8Dump, oilpanDump) { - var v8HeapsDump = addChildDump(v8Dump, 'heaps', { size: 32 }); - var v8QueuesDump = addChildDump(v8Dump, 'queues', { size: 8 }); - var v8PilesDump = addChildDump(v8Dump, 'piles', { size: 48 }); - var oilpanObjectsDump = - addChildDump(oilpanDump, 'objects', { size: 64 }); - addOwnershipLink(v8HeapsDump, oilpanObjectsDump, 1); - addOwnershipLink(v8QueuesDump, oilpanObjectsDump, 1); - addOwnershipLink(v8PilesDump, oilpanObjectsDump, 7); - }); - }); - var v8HeapsDump = getAllocatorDumps(pmds, 'v8/heaps'); - var oilpanObjectsDump = getAllocatorDumps(pmds, 'oilpan/objects'); - var gpuTile1Dump = getAllocatorDumps(pmds, 'gpu/tile1'); - - // Single selection. - checkAllocatorPaneColumnInfosAndColor(c, - [v8HeapsDump[4]], - 'effective_size', - [ - { - icon: '\u21FE', - message: 'shares \'gpu/tile1\' in Process 1 (importance: 3) with ' + - '\'gpu/tile2\' in Process 1 (importance: -1)', - color: 'green' - } - ]); - checkAllocatorPaneColumnInfosAndColor(c, - [gpuTile1Dump[4]], - 'effective_size', - [ - { - icon: '\u21FD', - message: 'shared by:\n' + - ' - \'v8/heaps\' in Process 1 (importance: 3)\n' + - ' - \'gpu/tile2\' in Process 1 (importance: -1)', - color: 'green' - } - ]); - - // Multi-selection, all dumps defined. - checkAllocatorPaneColumnInfosAndColor(c, - [v8HeapsDump[2], v8HeapsDump[5]], - 'effective_size', - [ - { - icon: '\u21FE', - message: 'shares \'oilpan/objects\' in Process 1 (importance: ' + - '1\u20132) with:\n' + - ' - \'v8/queues\' in Process 1 (importance: 1)\n' + - ' - \'v8/piles\' in Process 1 (importance: 0\u20137)', - color: 'green' - } - ]); - checkAllocatorPaneColumnInfosAndColor(c, - [oilpanObjectsDump[2], oilpanObjectsDump[5]], - 'effective_size', - [ - { - icon: '\u21FD', - message: 'shared by:\n' + - ' - \'v8/heaps\' in Process 1 (importance: 1\u20132)\n' + - ' - \'v8/queues\' in Process 1 (importance: 1)\n' + - ' - \'v8/piles\' in Process 1 (importance: 0\u20137)', - color: 'green' - } - ]); - - // Multi-selection, some dumps missing. - checkAllocatorPaneColumnInfosAndColor(c, - v8HeapsDump, - 'effective_size', - [ // v8/objects is both owned (first info) and an owner (second info). - { - icon: '\u21FD', - message: 'shared by \'blink/handles\' in Process 1 at some ' + - 'selected timestamps (importance: -273)', - color: 'green' - }, - { - icon: '\u21FE', - message: 'shares:\n' + - ' - \'oilpan/objects\' in Process 1 at some selected ' + - 'timestamps (importance: 0\u20132) with:\n' + - ' - \'v8/queues\' in Process 1 (importance: 1)\n' + - ' - \'v8/piles\' in Process 1 at some selected ' + - 'timestamps (importance: 0\u20137)\n' + - ' - \'blink/objects\' in Process 1 at some selected ' + - 'timestamps (importance: 3) with no other dumps\n' + - ' - \'gpu/tile1\' in Process 1 at some selected timestamps ' + - '(importance: 3) with \'gpu/tile2\' in Process 1 ' + - '(importance: -1)', - color: 'green' - } - ]); - checkAllocatorPaneColumnInfosAndColor(c, - oilpanObjectsDump, - 'effective_size', - [ - { - icon: '\u21FD', - message: 'shared by:\n' + - ' - \'v8/heaps\' in Process 1 at some selected timestamps ' + - '(importance: 0\u20132)\n' + - ' - \'v8/queues\' in Process 1 at some selected timestamps ' + - '(importance: 1)\n' + - ' - \'v8/piles\' in Process 1 at some selected timestamps ' + - '(importance: 0\u20137)', - color: 'green' - } - ]); - }); - - test('sizeColumn_noContext', function() { - var c = new SizeColumn('Size', 'bytes', tr.b.identity, - AggregationMode.DIFF); - - // Single selection. - checkColumnInfosAndColor(c, - createSizeFields([128]), - undefined /* no context */, - [] /* no infos */, - undefined /* no color */); - - // Multi-selection. - checkColumnInfosAndColor(c, - createSizeFields([128, 256, undefined, 64]), - undefined /* no context */, - [] /* no infos */, - undefined /* no color */); - }); - - test('sizeColumn_suballocationContext', function() { - var c = new SizeColumn('Size', 'bytes', tr.b.identity, AggregationMode.MAX); - - // Single selection. - checkColumnInfosAndColor(c, - createSizeFields([128]), - [SUBALLOCATION_CONTEXT], - [] /* no infos */, - undefined /* no color */); - - // Multi-selection. - checkColumnInfosAndColor(c, - createSizeFields([undefined, 256, undefined, 64]), - [undefined, SUBALLOCATION_CONTEXT, undefined, SUBALLOCATION_CONTEXT], - [] /* no infos */, - undefined /* no color */); - }); - - test('sizeColumn_dumpContext', function() { - var c = new SizeColumn('Size', 'bytes', tr.b.identity, - AggregationMode.DIFF); - var pmds = buildProcessMemoryDumps(7 /* count */, function(pmds) { - addRootDumps(pmds[0], ['v8'], function(v8Dump) { - // Single direct overlap (v8/objects -> v8/heaps). - var v8ObjectsDump = addChildDump(v8Dump, 'objects', { size: 1536 }); - var v8HeapsDump = addChildDump(v8Dump, 'heaps', { size: 2048 }); - addOwnershipLink(v8ObjectsDump, v8HeapsDump); - }); - // pmd[1] intentionally skipped. - addRootDumps(pmds[2], ['v8'], function(v8Dump, oilpanDump) { - // Single direct overlap with inconsistent owned dump size. - var v8ObjectsDump = addChildDump(v8Dump, 'objects', { size: 3072 }); - var v8HeapsDump = addChildDump(v8Dump, 'heaps', { size: 2048 }); - addOwnershipLink(v8ObjectsDump, v8HeapsDump); - }); - addRootDumps(pmds[3], ['v8'], function(v8Dump) { - // Single indirect overlap (v8/objects/X -> v8/heaps/42). - var v8ObjectsDump = addChildDump(v8Dump, 'objects', { size: 1536 }); - var v8ObjectsXDump = addChildDump(v8ObjectsDump, 'X', { size: 512 }); - var v8HeapsDump = addChildDump(v8Dump, 'heaps', { size: 2048 }); - var v8Heaps42Dump = addChildDump(v8HeapsDump, '42', { size: 1024 }); - addOwnershipLink(v8ObjectsXDump, v8Heaps42Dump); - }); - addRootDumps(pmds[4], ['v8'], function(v8Dump) { - // Multiple overlaps. - var v8ObjectsDump = addChildDump(v8Dump, 'objects', { size: 1024 }); - var v8HeapsDump = addChildDump(v8Dump, 'heaps', { size: 2048 }); - - var v8ObjectsXDump = addChildDump(v8ObjectsDump, 'X', { size: 512 }); - var v8Heaps42Dump = addChildDump(v8HeapsDump, '42', { size: 1280 }); - addOwnershipLink(v8ObjectsXDump, v8Heaps42Dump); - - var v8ObjectsYDump = addChildDump(v8ObjectsDump, 'Y', { size: 128 }); - var v8Heaps90Dump = addChildDump(v8HeapsDump, '90', { size: 256 }); - addOwnershipLink(v8ObjectsYDump, v8Heaps90Dump); - - var v8BlocksDump = addChildDump(v8Dump, 'blocks', { size: 768 }); - addOwnershipLink(v8BlocksDump, v8Heaps42Dump); - }); - addRootDumps(pmds[5], ['v8'], function(v8Dump) { - // No overlaps, inconsistent parent size. - var v8HeapsDump = addChildDump(v8Dump, 'heaps', { size: 2048 }); - addChildDump(v8HeapsDump, '42', { size: 1536 }); - addChildDump(v8HeapsDump, '90', { size: 615 }); - }); - addRootDumps(pmds[6], ['v8', 'oilpan'], function(v8Dump, oilpanDump) { - // No overlaps, inconsistent parent and owned dump size. - var v8HeapsDump = addChildDump(v8Dump, 'heaps', { size: 2048 }); - addChildDump(v8HeapsDump, '42', { size: 1536 }); - addChildDump(v8HeapsDump, '90', { size: 615 }); - var oilpanObjectsDump = - addChildDump(oilpanDump, 'objects', { size: 3072 }); - addOwnershipLink(oilpanObjectsDump, v8HeapsDump); - }); - }); - var v8HeapDumps = getAllocatorDumps(pmds, 'v8/heaps'); - - // Single selection, single overlap. - checkAllocatorPaneColumnInfosAndColor(c, - [v8HeapDumps[0]], - 'size', - [ - { - icon: '\u24D8', - message: 'overlaps with its sibling \'objects\' (1.5 KiB)', - color: 'blue' - } - ]); - - // Single selection, multiple overlaps. - checkAllocatorPaneColumnInfosAndColor(c, - [v8HeapDumps[4]], - 'size', - [ - { - icon: '\u24D8', - message: 'overlaps with its siblings:\n' + - ' - \'objects\' (640.0 B)\n' + - ' - \'blocks\' (768.0 B)', - color: 'blue' - } - ]); - - // Single selection, warnings with no overlaps. - checkAllocatorPaneColumnInfosAndColor(c, - [v8HeapDumps[6]], - 'size', - [ - { - icon: '\u26A0', - message: 'provided size (2.0 KiB) was less than the aggregated ' + - 'size of the children (2.1 KiB)', - color: 'red' - }, - { - icon: '\u26A0', - message: 'provided size (2.0 KiB) was less than the size of the ' + - 'largest owner (3.0 KiB)', - color: 'red' - } - ]); - - // Single selection, single overlap with a warning. - checkAllocatorPaneColumnInfosAndColor(c, - [v8HeapDumps[2]], - 'size', - [ - { - icon: '\u24D8', - message: 'overlaps with its sibling \'objects\' (3.0 KiB)', - color: 'blue' - }, - { - icon: '\u26A0', - message: 'provided size (2.0 KiB) was less than the size of the ' + - 'largest owner (3.0 KiB)', - color: 'red' - } - ]); - - // Multi-selection, single overlap. - checkAllocatorPaneColumnInfosAndColor(c, - [v8HeapDumps[0], v8HeapDumps[3]], - 'size', - [ - { - icon: '\u24D8', - message: 'overlaps with its sibling \'objects\'', - color: 'blue' - } - ]); - - // Multi-selection, multiple overlaps. - checkAllocatorPaneColumnInfosAndColor(c, - [v8HeapDumps[0], v8HeapDumps[4]], - 'size', - [ - { - icon: '\u24D8', - message: 'overlaps with its siblings:\n' + - ' - \'objects\'\n' + - ' - \'blocks\' at some selected timestamps', - color: 'blue' - } - ]); - - // Multi-selection, warnings with no overlaps. - checkAllocatorPaneColumnInfosAndColor(c, - [v8HeapDumps[5], v8HeapDumps[6]], - 'size', - [ - { - icon: '\u26A0', - message: 'provided size was less than the aggregated ' + - 'size of the children', - color: 'red' - }, - { - icon: '\u26A0', - message: 'provided size was less than the size of the largest ' + - 'owner at some selected timestamps', - color: 'red' - } - ]); - - // Multi-selection, multiple overlaps with warnings. - checkAllocatorPaneColumnInfosAndColor(c, - v8HeapDumps, - 'size', - [ - { - icon: '\u24D8', - message: 'overlaps with its siblings:\n' + - ' - \'objects\' at some selected timestamps\n' + - ' - \'blocks\' at some selected timestamps', - color: 'blue' - }, - { - icon: '\u26A0', - message: 'provided size was less than the size of the largest ' + - 'owner at some selected timestamps', - color: 'red' - }, - { - icon: '\u26A0', - message: 'provided size was less than the aggregated size of ' + - 'the children at some selected timestamps', - color: 'red' - } - ]); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/memory_dump_header_pane.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/memory_dump_header_pane.html deleted file mode 100644 index 7b9ea7ce06e..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/memory_dump_header_pane.html +++ /dev/null @@ -1,174 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/analysis/memory_dump_overview_pane.html"> -<link rel="import" href="/tracing/ui/analysis/memory_dump_sub_view_util.html"> -<link rel="import" href="/tracing/ui/analysis/stacked_pane.html"> -<link rel="import" href="/tracing/ui/base/dom_helpers.html"> -<link rel="import" href="/tracing/value/unit.html"> - -<polymer-element name="tr-ui-a-memory-dump-header-pane" - extends="tr-ui-a-stacked-pane"> - <template> - <style> - :host { - display: flex; - flex-direction: row; - align-items: center; - - background-color: #d0d0d0; - border-bottom: 1px solid #8e8e8e; - border-top: 1px solid white; - } - - #label { - flex: 1 1 auto; - padding: 6px; - font-size: 15px; - } - - #aggregation_mode_container { - display: none; - flex: 0 0 auto; - padding: 5px; - font-size: 15px; - } - </style> - </tr-ui-b-view-specific-brushing-state> - <div id="label"></div> - <div id="aggregation_mode_container"> - <span>Metric aggregation:</span> - <!-- Aggregation mode selector (added in Polymer.ready()) --> - </div> - </template> -</polymer-element> -<script> -'use strict'; - -tr.exportTo('tr.ui.analysis', function() { - - Polymer('tr-ui-a-memory-dump-header-pane', { - created: function() { - this.containerMemoryDumps_ = undefined; - }, - - ready: function() { - this.$.aggregation_mode_container.appendChild(tr.ui.b.createSelector( - this, 'aggregationMode', 'memoryDumpHeaderPane.aggregationMode', - tr.ui.analysis.MemoryColumn.AggregationMode.DIFF, - [ - { - label: 'Diff', - value: tr.ui.analysis.MemoryColumn.AggregationMode.DIFF - }, - { - label: 'Max', - value: tr.ui.analysis.MemoryColumn.AggregationMode.MAX - } - ])); - }, - - /** - * Sets the container memory dumps and schedules rebuilding the pane. - * - * The provided value should be a chronologically sorted list of - * ContainerMemoryDump objects. All of the dumps must be associated with - * the same container (i.e. containerMemoryDumps must be either a list of - * ProcessMemoryDump(s) belonging to the same process, or a list of - * GlobalMemoryDump(s)). Example: - * - * [ - * tr.model.ProcessMemoryDump {}, // PMD at timestamp 1. - * tr.model.ProcessMemoryDump {}, // PMD at timestamp 2. - * tr.model.ProcessMemoryDump {} // PMD at timestamp 3. - * ] - */ - set containerMemoryDumps(containerMemoryDumps) { - this.containerMemoryDumps_ = containerMemoryDumps; - this.scheduleRebuildPane_(); - }, - - get containerMemoryDumps() { - return this.containerMemoryDumps_; - }, - - set aggregationMode(aggregationMode) { - this.aggregationMode_ = aggregationMode; - this.scheduleRebuildPane_(); - }, - - get aggregationMode() { - return this.aggregationMode_; - }, - - rebuildPane_: function() { - this.updateLabel_(); - this.updateAggregationModeSelector_(); - this.changeChildPane_(); - }, - - updateLabel_: function() { - this.$.label.textContent = ''; - - if (this.containerMemoryDumps_ === undefined || - this.containerMemoryDumps_.length <= 0) { - this.$.label.textContent = 'No memory dumps selected'; - return; - } - - var containerDumpCount = this.containerMemoryDumps_.length; - var isMultiSelection = containerDumpCount > 1; - - this.$.label.appendChild(document.createTextNode( - 'Selected ' + containerDumpCount + ' memory dump' + - (isMultiSelection ? 's' : '') + - ' in ' + this.containerMemoryDumps_[0].containerName + ' at ')); - // TODO(petrcermak): Use <tr-v-ui-scalar-span> once it can be displayed - // inline. See https://github.com/catapult-project/catapult/issues/1371. - this.$.label.appendChild(document.createTextNode( - tr.v.Unit.byName.timeStampInMs.format( - this.containerMemoryDumps_[0].start))); - if (isMultiSelection) { - var ELLIPSIS = String.fromCharCode(8230); - this.$.label.appendChild(document.createTextNode(ELLIPSIS)); - this.$.label.appendChild(document.createTextNode( - tr.v.Unit.byName.timeStampInMs.format( - this.containerMemoryDumps_[containerDumpCount - 1].start))); - } - }, - - updateAggregationModeSelector_: function() { - var displayStyle; - if (this.containerMemoryDumps_ === undefined || - this.containerMemoryDumps_.length <= 1) - displayStyle = 'none'; - else - displayStyle = 'initial'; - this.$.aggregation_mode_container.style.display = displayStyle; - }, - - changeChildPane_: function() { - this.childPaneBuilder = function() { - if (this.containerMemoryDumps_ === undefined || - this.containerMemoryDumps_.length <= 0) - return undefined; - - var overviewPane = document.createElement( - 'tr-ui-a-memory-dump-overview-pane'); - overviewPane.processMemoryDumps = this.containerMemoryDumps_.map( - function(containerDump) { - return containerDump.processMemoryDumps; - }); - overviewPane.aggregationMode = this.aggregationMode; - return overviewPane; - }.bind(this); - } - }); - - return {}; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/memory_dump_header_pane_test.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/memory_dump_header_pane_test.html deleted file mode 100644 index f3e220605e8..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/memory_dump_header_pane_test.html +++ /dev/null @@ -1,132 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/analysis/memory_dump_header_pane.html"> -<link rel="import" - href="/tracing/ui/analysis/memory_dump_sub_view_test_utils.html"> -<link rel="import" href="/tracing/ui/analysis/memory_dump_sub_view_util.html"> -<link rel="import" href="/tracing/ui/base/deep_utils.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var AggregationMode = tr.ui.analysis.MemoryColumn.AggregationMode; - var isElementDisplayed = tr.ui.analysis.isElementDisplayed; - - function createAndCheckMemoryDumpHeaderPane(test, containerMemoryDumps, - expectedLabelText, expectedChildPaneRequested, expectedSelectorVisible) { - var viewEl = - tr.ui.analysis.createTestPane('tr-ui-a-memory-dump-header-pane'); - viewEl.containerMemoryDumps = containerMemoryDumps; - viewEl.rebuild(); - test.addHTMLOutput(viewEl); - checkMemoryDumpHeaderPane(viewEl, containerMemoryDumps, expectedLabelText, - expectedChildPaneRequested, expectedSelectorVisible); - } - - function checkMemoryDumpHeaderPane(viewEl, containerMemoryDumps, - expectedLabelText, expectedChildPaneRequested, expectedSelectorVisible) { - // The default aggregation mode is DIFF. - assert.equal(viewEl.aggregationMode, AggregationMode.DIFF); - - // Check the text in the label. - assert.equal(viewEl.$.label.textContent, expectedLabelText); - - // Check the visibility of aggregation mode selector. - var aggregationModeContainerVisible = - isElementDisplayed(viewEl.$.aggregation_mode_container); - var childPanes = viewEl.requestedChildPanes; - - // Check the requested child panes. - if (containerMemoryDumps === undefined || - containerMemoryDumps.length === 0) { - assert.isTrue(!expectedSelectorVisible); // Test sanity check. - assert.isFalse(aggregationModeContainerVisible); - assert.lengthOf(childPanes, 1); - assert.isUndefined(childPanes[0]); - return; - } - - var expectedProcessMemoryDumps = containerMemoryDumps.map( - function(containerMemoryDump) { - return containerMemoryDump.processMemoryDumps; - }); - function checkLastChildPane(expectedChildPaneCount) { - assert.lengthOf(childPanes, expectedChildPaneCount); - var lastChildPane = childPanes[expectedChildPaneCount - 1]; - assert.equal(lastChildPane.tagName, 'TR-UI-A-MEMORY-DUMP-OVERVIEW-PANE'); - assert.deepEqual(lastChildPane.processMemoryDumps, - expectedProcessMemoryDumps); - assert.equal(lastChildPane.aggregationMode, viewEl.aggregationMode); - } - - checkLastChildPane(1); - - // Check the behavior of aggregation mode selector (if visible). - if (!expectedSelectorVisible) { - assert.isFalse(aggregationModeContainerVisible); - return; - } - - assert.isTrue(aggregationModeContainerVisible); - var selector = tr.b.findDeepElementMatching(viewEl, 'select'); - - selector.selectedValue = AggregationMode.MAX; - viewEl.rebuild(); - assert.equal(viewEl.aggregationMode, AggregationMode.MAX); - checkLastChildPane(2); - - selector.selectedValue = AggregationMode.DIFF; - viewEl.rebuild(); - assert.equal(viewEl.aggregationMode, AggregationMode.DIFF); - checkLastChildPane(3); - } - - test('instantiate_empty', function() { - tr.ui.analysis.createAndCheckEmptyPanes(this, - 'tr-ui-a-memory-dump-header-pane', 'containerMemoryDumps', - function(viewEl) { - checkMemoryDumpHeaderPane(viewEl, [], 'No memory dumps selected', - false /* no child pane requested */, - false /* aggregation mode selector hidden */); - }); - }); - - test('instantiate_singleGlobalMemoryDump', function() { - createAndCheckMemoryDumpHeaderPane(this, - [tr.ui.analysis.createSingleTestGlobalMemoryDump()], - 'Selected 1 memory dump in global space at 68.000 ms', - true /* child pane requested */, - false /* aggregation mode selector hidden */); - }); - - test('instantiate_multipleGlobalMemoryDumps', function() { - createAndCheckMemoryDumpHeaderPane(this, - tr.ui.analysis.createMultipleTestGlobalMemoryDumps(), - 'Selected 3 memory dumps in global space at 42.000 ms\u2026100.000 ms', - true /* child pane requested */, - true /* aggregation selector visible */); - }); - - test('instantiate_singleProcessMemoryDump', function() { - createAndCheckMemoryDumpHeaderPane(this, - [tr.ui.analysis.createSingleTestProcessMemoryDump()], - 'Selected 1 memory dump in Process 2 at 69.000 ms', - true /* child pane requested */, - false /* aggregation mode selector hidden */); - }); - - test('instantiate_multipleProcessMemoryDumps', function() { - createAndCheckMemoryDumpHeaderPane(this, - tr.ui.analysis.createMultipleTestProcessMemoryDumps(), - 'Selected 3 memory dumps in Process 2 at 42.000 ms\u2026102.000 ms', - true /* child pane requested */, - true /* aggregation selector visible */); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/memory_dump_heap_details_pane.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/memory_dump_heap_details_pane.html deleted file mode 100644 index 05d4ad5d689..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/memory_dump_heap_details_pane.html +++ /dev/null @@ -1,488 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/color_scheme.html"> -<link rel="import" href="/tracing/base/iteration_helpers.html"> -<link rel="import" href="/tracing/base/multi_dimensional_view.html"> -<link rel="import" href="/tracing/ui/analysis/memory_dump_sub_view_util.html"> -<link rel="import" href="/tracing/ui/analysis/stacked_pane.html"> -<link rel="import" href="/tracing/ui/base/dom_helpers.html"> -<link rel='import' href='/tracing/ui/base/info_bar.html'> -<link rel="import" href="/tracing/ui/base/table.html"> -<link rel="import" href="/tracing/value/numeric.html"> -<link rel="import" href="/tracing/value/unit.html"> - -<polymer-element name="tr-ui-a-memory-dump-heap-details-pane" - extends="tr-ui-a-stacked-pane"> - <template> - <style> - :host { - display: flex; - flex-direction: column; - } - - #header { - flex: 0 0 auto; - display: flex; - flex-direction: row; - align-items: center; - - background-color: #eee; - border-bottom: 1px solid #8e8e8e; - border-top: 1px solid white; - } - - #label { - flex: 1 1 auto; - padding: 8px; - font-size: 15px; - font-weight: bold; - } - - #view_mode_container { - display: none; - flex: 0 0 auto; - padding: 5px; - font-size: 15px; - } - - #contents { - flex: 1 0 auto; - align-self: stretch; - font-size: 12px; - } - - #info_text { - padding: 8px; - color: #666; - font-style: italic; - text-align: center; - } - - #table { - display: none; /* Hide until memory allocator dumps are set. */ - flex: 1 0 auto; - align-self: stretch; - } - </style> - <div id="header"> - <div id="label">Heap details</div> - <div id="view_mode_container"> - <span>View mode:</span> - <!-- View mode selector (added in Polymer.ready()) --> - </div> - </div> - <div id="contents"> - <tr-ui-b-info-bar id="info_bar" class="info-bar-hidden"> - </tr-ui-b-info-bar> - <div id="info_text">No heap dump selected</div> - <tr-ui-b-table id="table"></tr-ui-b-table> - </div> - </template> -</polymer-element> -<script> -'use strict'; - -tr.exportTo('tr.ui.analysis', function() { - - var ScalarNumeric = tr.v.ScalarNumeric; - var sizeInBytes_smallerIsBetter = - tr.v.Unit.byName.sizeInBytes_smallerIsBetter; - var unitlessNumber_smallerIsBetter = - tr.v.Unit.byName.unitlessNumber_smallerIsBetter; - var MultiDimensionalViewBuilder = tr.b.MultiDimensionalViewBuilder; - var TotalState = tr.b.MultiDimensionalViewNode.TotalState; - - /** @{enum} */ - var RowDimension = { - ROOT: -1, - STACK_FRAME: 0, - OBJECT_TYPE: 1 - }; - - var LATIN_SMALL_LETTER_F_WITH_HOOK = String.fromCharCode(0x0192); - var CIRCLED_LATIN_CAPITAL_LETTER_T = String.fromCharCode(0x24C9); - - /** @{constructor} */ - function HeapDumpNodeTitleColumn(title) { - tr.ui.analysis.TitleColumn.call(this, title); - } - - HeapDumpNodeTitleColumn.prototype = { - __proto__: tr.ui.analysis.TitleColumn.prototype, - - formatTitle: function(row) { - var title = row.title; - var dimension = row.dimension; - switch (dimension) { - case RowDimension.ROOT: - return title; - - case RowDimension.STACK_FRAME: - case RowDimension.OBJECT_TYPE: - return this.formatSubRow_(title, dimension); - - default: - throw new Error('Invalid row dimension: ' + row.dimension); - } - }, - - cmp: function(rowA, rowB) { - if (rowA.dimension !== rowB.dimension) - return rowA.dimension - rowB.dimension; - return tr.ui.analysis.TitleColumn.prototype.cmp.call(this, rowA, rowB); - }, - - formatSubRow_: function(title, dimension) { - var titleEl = document.createElement('span'); - - var symbolEl = document.createElement('span'); - var symbolColorName; - if (dimension === RowDimension.STACK_FRAME) { - symbolEl.textContent = LATIN_SMALL_LETTER_F_WITH_HOOK; - symbolEl.title = 'Stack frame'; - symbolColorName = 'heap_dump_stack_frame'; - } else { - symbolEl.textContent = CIRCLED_LATIN_CAPITAL_LETTER_T; - symbolEl.title = 'Object type'; - symbolColorName = 'heap_dump_object_type'; - } - symbolEl.style.color = - tr.b.ColorScheme.getColorForReservedNameAsString(symbolColorName); - symbolEl.style.paddingRight = '4px'; - symbolEl.style.cursor = 'help'; - symbolEl.style.weight = 'bold'; - titleEl.appendChild(symbolEl); - - titleEl.appendChild(document.createTextNode(title)); - - return titleEl; - } - }; - - /** @constructor */ - function AllocationCountColumn(name, cellPath, aggregationMode) { - tr.ui.analysis.DetailsNumericMemoryColumn.call( - this, name, cellPath, aggregationMode); - } - - AllocationCountColumn.prototype = { - __proto__: tr.ui.analysis.DetailsNumericMemoryColumn.prototype, - - getFormattingContext: function(unit) { - return { minimumFractionDigits: 0 }; - } - }; - - var COLUMN_RULES = [ - { - condition: 'Size', - importance: 3, - columnConstructor: tr.ui.analysis.DetailsNumericMemoryColumn - }, - { - condition: 'Count', - importance: 2, - columnConstructor: AllocationCountColumn - }, - { - condition: 'Average size per allocation', - importance: 1, - columnConstructor: tr.ui.analysis.DetailsNumericMemoryColumn - }, - { - importance: 0, - columnConstructor: tr.ui.analysis.DetailsNumericMemoryColumn - } - ]; - - Polymer('tr-ui-a-memory-dump-heap-details-pane', { - created: function() { - this.heapDumps_ = undefined; - this.aggregationMode_ = undefined; - this.viewMode_ = undefined; - }, - - ready: function() { - this.$.table.selectionMode = tr.ui.b.TableFormat.SelectionMode.ROW; - this.$.info_bar.message = 'Note: Values displayed in the heavy view ' + - 'are lower bounds (except for the root).'; - - this.$.view_mode_container.appendChild(tr.ui.b.createSelector( - this, 'viewMode', 'memoryDumpHeapDetailsPane.viewMode', - MultiDimensionalViewBuilder.ViewType.TOP_DOWN_TREE_VIEW, - [ - { - label: 'Top-down (Tree)', - value: MultiDimensionalViewBuilder.ViewType.TOP_DOWN_TREE_VIEW - }, - { - label: 'Top-down (Heavy)', - value: MultiDimensionalViewBuilder.ViewType.TOP_DOWN_HEAVY_VIEW - }, - { - label: 'Bottom-up (Heavy)', - value: MultiDimensionalViewBuilder.ViewType.BOTTOM_UP_HEAVY_VIEW - } - ])); - }, - - /** - * Sets the heap dumps and schedules rebuilding the pane. - * - * The provided value should be a chronological list of heap dumps. All - * dumps are assumed to belong to the same process and belong to the same - * allocator. Example: - * - * [ - * tr.model.HeapDump {}, // Heap dump at timestamp 1. - * undefined, // Heap dump not provided at timestamp 2. - * tr.model.HeapDump {}, // Heap dump at timestamp 3. - * ] - */ - set heapDumps(heapDumps) { - this.heapDumps_ = heapDumps; - this.scheduleRebuildPane_(); - }, - - get heapDumps() { - return this.heapDumps_; - }, - - set aggregationMode(aggregationMode) { - this.aggregationMode_ = aggregationMode; - this.scheduleRebuildPane_(); - }, - - get aggregationMode() { - return this.aggregationMode_; - }, - - set viewMode(viewMode) { - this.viewMode_ = viewMode; - this.scheduleRebuildPane_(); - }, - - get viewMode() { - return this.viewMode_; - }, - - get heavyView() { - switch (this.viewMode) { - case MultiDimensionalViewBuilder.ViewType.TOP_DOWN_HEAVY_VIEW: - case MultiDimensionalViewBuilder.ViewType.BOTTOM_UP_HEAVY_VIEW: - return true; - default: - return false; - } - }, - - rebuildPane_: function() { - if (this.heapDumps_ === undefined || - this.heapDumps_.length === 0) { - // Show the info text (hide the table and the view mode selector). - this.$.info_text.style.display = 'block'; - this.$.table.style.display = 'none'; - this.$.view_mode_container.style.display = 'none'; - this.$.info_bar.visible = false; - - this.$.table.clear(); - this.$.table.rebuild(); - return; - } - - // Show the table and the view mode selector (hide the info text). - this.$.info_text.style.display = 'none'; - this.$.table.style.display = 'block'; - this.$.view_mode_container.style.display = 'block'; - - // Show the info bar if in heavy view mode. - this.$.info_bar.visible = this.heavyView; - - var stackFrameTrees = this.createStackFrameTrees_(this.heapDumps_); - var rows = this.createRows_(stackFrameTrees); - var columns = this.createColumns_(rows); - - this.$.table.tableRows = rows; - this.$.table.tableColumns = columns; - this.$.table.rebuild(); - tr.ui.analysis.expandTableRowsRecursively(this.$.table); - }, - - createStackFrameTrees_: function(heapDumps) { - return heapDumps.map(function(heapDump) { - if (heapDump === undefined) - return undefined; - - var builder = new MultiDimensionalViewBuilder( - 2 /* dimensions (stack frames, object type) */, - 2 /* valueCount (size, count) */); - - // Build the heap tree. - heapDump.entries.forEach(function(entry) { - var leafStackFrame = entry.leafStackFrame; - var stackTracePath = leafStackFrame === undefined ? - [] : leafStackFrame.getUserFriendlyStackTrace().reverse(); - - var objectTypeName = entry.objectTypeName; - var objectTypeNamePath = objectTypeName === undefined ? - [] : [objectTypeName]; - - builder.addPath([stackTracePath, objectTypeNamePath], - [entry.size, entry.count], - MultiDimensionalViewBuilder.ValueKind.TOTAL); - }, this); - - return builder.buildView(this.viewMode); - }, this); - }, - - createRows_: function(stackFrameTrees) { - var definedHeapDump = tr.b.findFirstInArray(this.heapDumps); - if (definedHeapDump === undefined) - return []; - - // The title of the root row is the name of the allocator. - var rootRowTitle = definedHeapDump.allocatorName; - return [this.createHeapRowRecursively_( - stackFrameTrees, RowDimension.ROOT, rootRowTitle)]; - }, - - createHeapRowRecursively_: function(nodes, dimension, title) { - // Transform a chronological list of stack frame tree nodes into a - // dictionary of cells (where each cell contains a chronological list - // of the values of its numeric). - var cells = tr.ui.analysis.createCells(nodes, function(node) { - var size = node.values[0].total; - var row = { - 'Size': new ScalarNumeric(sizeInBytes_smallerIsBetter, size) - }; - var countValue = node.values[1]; - if (countValue.totalState >= this.minDisplayedTotalState_) { - var count = countValue.total; - row['Count'] = new ScalarNumeric(unitlessNumber_smallerIsBetter, - count); - row['Average size per allocation'] = new ScalarNumeric( - sizeInBytes_smallerIsBetter, count === 0 ? 0 : size / count); - } - return row; - }, this); - - var row = { - dimension: dimension, - title: title, - contexts: nodes, - cells: cells - }; - - // Recursively create sub-rows for children (if applicable). - var stackFrameSubRows = this.createHeapDimensionSubRowsRecursively_( - nodes, RowDimension.STACK_FRAME); - var objectTypeSubRows = this.createHeapDimensionSubRowsRecursively_( - nodes, RowDimension.OBJECT_TYPE); - var subRows = stackFrameSubRows.concat(objectTypeSubRows); - if (subRows.length > 0) - row.subRows = subRows; - - return row; - }, - - get minDisplayedTotalState_() { - if (this.heavyView) { - // Show lower-bound and exact values in heavy views. - return TotalState.LOWER_BOUND; - } else { - // Show only exact values in tree view. - return TotalState.EXACT; - } - }, - - createHeapDimensionSubRowsRecursively_: function(nodes, dimension) { - // Sub-row name (list index) -> Timestamp (list index) -> Child - // MultiDimensionalViewNode. - var dimensionGroupedChildNodes = tr.b.dictionaryValues( - tr.b.invertArrayOfDicts(nodes, function(node) { - var childDict = {}; - var displayedChildrenTotalSize = 0; - var displayedChildrenTotalCount = 0; - var hasDisplayedChildren = false; - var allDisplayedChildrenHaveDisplayedCounts = true; - for (var child of node.children[dimension].values()) { - if (child.values[0].totalState < this.minDisplayedTotalState_) - continue; - if (child.values[1].totalState < this.minDisplayedTotalState_) - allDisplayedChildrenHaveDisplayedCounts = false; - childDict[child.title[dimension]] = child; - displayedChildrenTotalSize += child.values[0].total; - displayedChildrenTotalCount += child.values[1].total; - hasDisplayedChildren = true; - } - - var nodeTotalSize = node.values[0].total; - var nodeTotalCount = node.values[1].total; - - // Add '<other>' node if necessary in tree-view. - var hasUnclassifiedSizeOrCount = - displayedChildrenTotalSize < nodeTotalSize || - displayedChildrenTotalCount < nodeTotalCount; - if (!this.heavyView && hasUnclassifiedSizeOrCount && - hasDisplayedChildren) { - var otherTitle = node.title.slice(); - otherTitle[dimension] = '<other>'; - childDict['<other>'] = { - title: otherTitle, - values: [ - { - self: 0, - total: nodeTotalSize - displayedChildrenTotalSize, - totalState: this.minDisplayedTotalState_ - }, - { - self: 0, - total: nodeTotalCount - displayedChildrenTotalCount, - // Don't show allocation count of the '<other>' node if - // there is a displayed child node that did NOT display - // allocation count. - totalState: allDisplayedChildrenHaveDisplayedCounts ? - this.minDisplayedTotalState_ : TotalState.NOT_PROVIDED - } - ], - children: [new Map(), new Map()] - }; - } - - return childDict; - }, this)); - - // Sub-row name (list index) -> Sub-row. - return dimensionGroupedChildNodes.map(function(subRowNodes) { - var subRowTitle = tr.b.findFirstInArray(subRowNodes).title[dimension]; - return this.createHeapRowRecursively_( - subRowNodes, dimension, subRowTitle); - }, this); - }, - - createColumns_: function(rows) { - var titleColumn = new HeapDumpNodeTitleColumn('Stack frame'); - titleColumn.width = '500px'; - - var numericColumns = tr.ui.analysis.MemoryColumn.fromRows( - rows, 'cells', this.aggregationMode_, COLUMN_RULES); - tr.ui.analysis.MemoryColumn.spaceEqually(numericColumns); - - var columns = [titleColumn].concat(numericColumns); - return columns; - } - }); - - return { - // Exported for testing. - RowDimension: RowDimension, - AllocationCountColumn: AllocationCountColumn - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/memory_dump_heap_details_pane_test.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/memory_dump_heap_details_pane_test.html deleted file mode 100644 index 1d1425dfb88..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/memory_dump_heap_details_pane_test.html +++ /dev/null @@ -1,4091 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel='import' href='/tracing/base/iteration_helpers.html'> -<link rel='import' href='/tracing/base/multi_dimensional_view.html'> -<link rel='import' href='/tracing/core/test_utils.html'> -<link rel='import' href='/tracing/model/heap_dump.html'> -<link rel='import' href='/tracing/model/memory_dump_test_utils.html'> -<link rel='import' - href='/tracing/ui/analysis/memory_dump_heap_details_pane.html'> -<link rel='import' - href='/tracing/ui/analysis/memory_dump_sub_view_test_utils.html'> -<link rel='import' href='/tracing/ui/analysis/memory_dump_sub_view_util.html'> -<link rel="import" href="/tracing/value/unit.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var ViewType = tr.b.MultiDimensionalViewBuilder.ViewType; - var TOP_DOWN_TREE_VIEW = ViewType.TOP_DOWN_TREE_VIEW; - var TOP_DOWN_HEAVY_VIEW = ViewType.TOP_DOWN_HEAVY_VIEW; - var BOTTOM_UP_HEAVY_VIEW = ViewType.BOTTOM_UP_HEAVY_VIEW; - var HeapDump = tr.model.HeapDump; - var RowDimension = tr.ui.analysis.RowDimension; - var ROOT = RowDimension.ROOT; - var STACK_FRAME = RowDimension.STACK_FRAME; - var OBJECT_TYPE = RowDimension.OBJECT_TYPE; - var TitleColumn = tr.ui.analysis.TitleColumn; - var NumericMemoryColumn = tr.ui.analysis.NumericMemoryColumn; - var AllocationCountColumn = tr.ui.analysis.AllocationCountColumn; - var AggregationMode = tr.ui.analysis.MemoryColumn.AggregationMode; - var addGlobalMemoryDump = tr.model.MemoryDumpTestUtils.addGlobalMemoryDump; - var addProcessMemoryDump = tr.model.MemoryDumpTestUtils.addProcessMemoryDump; - var checkColumns = tr.ui.analysis.checkColumns; - var checkNumericFields = tr.ui.analysis.checkNumericFields; - var checkSizeNumericFields = tr.ui.analysis.checkSizeNumericFields; - var isElementDisplayed = tr.ui.analysis.isElementDisplayed; - var unitlessNumber_smallerIsBetter = - tr.v.Unit.byName.unitlessNumber_smallerIsBetter; - - function createHeapDumps(withCount) { - var model = new tr.Model(); - var process = model.getOrCreateProcess(1); - - function addHeapEntry(heapDump, stackFrames, objectTypeName, size, count) { - var leafStackFrame = stackFrames === undefined ? undefined : - tr.c.TestUtils.newStackTrace(model, stackFrames); - heapDump.addEntry(leafStackFrame, objectTypeName, size, - withCount ? count : undefined); - } - - // First timestamp. - var gmd1 = addGlobalMemoryDump(model, -10); - var pmd1 = addProcessMemoryDump(gmd1, process, -11); - var hd1 = new HeapDump(pmd1, 'partition_alloc'); - - addHeapEntry(hd1, undefined /* sum over all traces */, - undefined /* sum over all types */, 4194304 /* 4 MiB */, 1000); - addHeapEntry(hd1, undefined /* sum over all traces */, 'v8::Context', - 1048576 /* 1 MiB */, 200); - addHeapEntry(hd1, undefined /* sum over all traces */, 'blink::Node', - 331776 /* 324 KiB */, 10); - addHeapEntry(hd1, ['MessageLoop::RunTask'], - undefined /* sum over all types */, 4194304 /* 4 MiB */, 1000); - addHeapEntry(hd1, ['MessageLoop::RunTask'], 'v8::Context', - 1048576 /* 1 MiB */, 200); - - addHeapEntry(hd1, ['MessageLoop::RunTask', 'FunctionCall'], - undefined /* sum over all types */, 1406976 /* 1.3 MiB */, 299); - addHeapEntry(hd1, ['MessageLoop::RunTask', 'FunctionCall'], - 'blink::Node', 331776 /* 324 KiB */, 10); - addHeapEntry(hd1, ['MessageLoop::RunTask', 'FunctionCall'], 'v8::Context', - 1024000 /* 1000 KiB */, 176); - addHeapEntry(hd1, ['MessageLoop::RunTask', 'FunctionCall', '<self>'], - undefined /* sum over all types */, 102400 /* 100 KiB */, 30); - addHeapEntry(hd1, ['MessageLoop::RunTask', 'FunctionCall', 'V8.Execute'], - 'v8::Context', 716800 /* 700 KiB */, 100); - addHeapEntry(hd1, ['MessageLoop::RunTask', 'FunctionCall', 'V8.Execute'], - undefined /* sum over all types */, 1048576 /* 1 MiB */, 101); - addHeapEntry(hd1, ['MessageLoop::RunTask', 'FunctionCall', 'FunctionCall'], - undefined /* sum over all types */, - 153600 /* 150 KiB, lower than the actual sum (should be ignored) */, - 25 /* the allocation count should, however, NOT be ignored */); - addHeapEntry(hd1, ['MessageLoop::RunTask', 'FunctionCall', 'FunctionCall'], - 'v8::Context', 153600 /* 150 KiB */, 15); - - // The following entry should not appear in the tree-view because there is - // no entry for its parent stack frame. - addHeapEntry(hd1, ['MessageLoop::RunTask', 'MissingParent', 'FunctionCall'], - undefined /* sum over all types */, 10 /* 10 B */, 2); - - // The following entry should not appear in the tree-view because there is - // no sum over all types (for the given stack trace). However, it will lead - // to a visible increase of the (incorrectly provided) sum over all types - // of MessageLoop::RunTask -> FunctionCall -> FunctionCall by 50 KiB. - addHeapEntry(hd1, - ['MessageLoop::RunTask', 'FunctionCall', 'FunctionCall', - 'FunctionCall'], - 'MissingSumOverAllTypes', 51200 /* 50 KiB */, 9); - - addHeapEntry(hd1, ['MessageLoop::RunTask', 'V8.Execute'], - undefined /* sum over all types */, 2404352 /* 2.3 MiB */, 399); - addHeapEntry(hd1, ['MessageLoop::RunTask', 'V8.Execute', 'FunctionCall'], - undefined /* sum over all types */, 2404352 /* 2.3 MiB */, 399); - addHeapEntry(hd1, ['MessageLoop::RunTask', 'V8.Execute', 'FunctionCall'], - 'v8::Context', 20480 /* 20 KiB */, 6); - addHeapEntry(hd1, - ['MessageLoop::RunTask', 'V8.Execute', 'FunctionCall', '<self>'], - 'v8::Context', 15360 /* 15 KiB */, 5); - addHeapEntry(hd1, - ['MessageLoop::RunTask', 'V8.Execute', 'FunctionCall', 'V8.Execute'], - undefined /* sum over all types */, 2097152 /* 2 MiB */, 99); - addHeapEntry(hd1, - ['MessageLoop::RunTask', 'V8.Execute', 'FunctionCall', 'V8.Execute', - 'V8.Execute'], - undefined /* sum over all types */, 2097152 /* 2 MiB */, 99); - addHeapEntry(hd1, - ['MessageLoop::RunTask', 'V8.Execute', 'FunctionCall', '<self>'], - undefined /* sum over all types */, 307200 /* 300 KiB */, 300); - - // Second timestamp. - var gmd2 = addGlobalMemoryDump(model, 10); - var pmd2 = addProcessMemoryDump(gmd2, process, 11); - var hd2 = new HeapDump(pmd2, 'partition_alloc'); - - addHeapEntry(hd2, undefined /* sum over all traces */, - undefined /* sum over all types */, - 3145728 /* 3 MiB, lower than the actual sum (should be ignored) */, - 900 /* the allocation count should, however, NOT be ignored */); - addHeapEntry(hd2, undefined /* sum over all traces */, - 'v8::Context', 1258291 /* 1.2 MiB */, 520); - addHeapEntry(hd2, undefined /* sum over all traces */, - 'blink::Node', 1048576 /* 1 MiB */, 5); - addHeapEntry(hd2, ['<self>'], undefined /* sum over all types */, - 131072 /* 128 KiB */, 16); - addHeapEntry(hd2, ['<self>'], 'v8::Context', 131072 /* 128 KiB */, 16); - addHeapEntry(hd2, ['MessageLoop::RunTask'], - undefined /* sum over all types */, 4823449 /* 4.6 MiB */, 884); - addHeapEntry(hd2, ['MessageLoop::RunTask'], 'v8::Context', - 1127219 /* 1.1 MiB */, 317); - - addHeapEntry(hd2, ['MessageLoop::RunTask', 'FunctionCall'], - undefined /* sum over all types */, 2170880 /* 2.1 MiB */, 600); - addHeapEntry(hd2, ['MessageLoop::RunTask', 'FunctionCall'], 'v8::Context', - 1024000 /* 1000 KiB */, 500); - addHeapEntry(hd2, ['MessageLoop::RunTask', 'FunctionCall'], 'blink::Node', - 819200 /* 800 KiB */, 4); - addHeapEntry(hd2, ['MessageLoop::RunTask', 'FunctionCall', 'V8.Execute'], - undefined /* sum over all types */, 1572864 /* 1.5 MiB */, 270); - addHeapEntry(hd2, ['MessageLoop::RunTask', 'FunctionCall', 'V8.Execute'], - 'v8::Context', 614400 /* 600 KiB */, 123); - addHeapEntry(hd2, ['MessageLoop::RunTask', 'FunctionCall', 'V8.Execute'], - 'blink::Node', 819200 /* 800 KiB */, 4); - addHeapEntry(hd2, ['MessageLoop::RunTask', 'FunctionCall', 'FunctionCall'], - undefined /* sum over all types */, 204800 /* 200 KiB */, 313); - addHeapEntry(hd2, ['MessageLoop::RunTask', 'FunctionCall', 'FunctionCall'], - 'v8::Context', 122880 /* 120 KiB */, 270); - addHeapEntry(hd2, - ['MessageLoop::RunTask', 'FunctionCall', 'FunctionCall', - 'FunctionCall'], - undefined /* sum over all types */, 204800 /* 200 KiB */, 313); - addHeapEntry(hd2, ['MessageLoop::RunTask', 'FunctionCall', '<self>'], - undefined /* sum over all types */, 393216 /* 384 KiB */, 17); - - addHeapEntry(hd2, ['MessageLoop::RunTask', 'V8.Execute'], - undefined /* sum over all types */, 2621440 /* 2.5 MiB */, 199); - addHeapEntry(hd2, ['MessageLoop::RunTask', 'V8.Execute', 'FunctionCall'], - undefined /* sum over all types */, 2621440 /* 2.5 MiB */, 199); - addHeapEntry(hd2, ['MessageLoop::RunTask', 'V8.Execute', 'FunctionCall'], - 'v8::Context', 20480 /* 20 KiB */, 4); - addHeapEntry(hd2, ['MessageLoop::RunTask', 'V8.Execute', 'FunctionCall'], - 'WTF::StringImpl', 126362 /* 123.4 KiB */, 56); - addHeapEntry(hd2, - ['MessageLoop::RunTask', 'V8.Execute', 'FunctionCall', 'V8.Execute'], - undefined /* sum over all types */, 2516582 /* 2.4 MiB */, 158); - - return [hd1, hd2]; - } - - function checkDisplayedElements(viewEl, displayExpectations) { - assert.strictEqual(isElementDisplayed(viewEl.$.info_text), - displayExpectations.infoText); - assert.strictEqual(isElementDisplayed(viewEl.$.info_bar), - displayExpectations.infoBar); - assert.strictEqual(isElementDisplayed(viewEl.$.table), - displayExpectations.tableAndSelector); - assert.strictEqual(isElementDisplayed(viewEl.$.view_mode_container), - displayExpectations.tableAndSelector); - } - - var EXPECTED_COLUMNS_WITHOUT_COUNT = [ - { title: 'Stack frame', type: TitleColumn, noAggregation: true }, - { title: 'Size', type: NumericMemoryColumn } - ]; - - var EXPECTED_COLUMNS_WITH_COUNT = EXPECTED_COLUMNS_WITHOUT_COUNT.concat([ - { title: 'Count', type: AllocationCountColumn }, - { title: 'Average size per allocation', type: NumericMemoryColumn } - ]); - - function checkRow(columns, row, expectedDimension, expectedTitle, - expectedSizes, expectedCounts, expectedAverageSizes, - expectedDefinedValues) { - var formattedTitle = columns[0].formatTitle(row); - switch (expectedDimension) { - case ROOT: - assert.equal(formattedTitle, expectedTitle); - break; - - case STACK_FRAME: - case OBJECT_TYPE: - assert.lengthOf(formattedTitle.childNodes, 2); - assert.strictEqual(formattedTitle.childNodes[0].textContent, - expectedDimension === STACK_FRAME ? '\u0192' : '\u24C9'); - assert.strictEqual( - formattedTitle.childNodes[1].textContent, expectedTitle); - break; - - default: - throw new Error('Invalid expected dimension: ' + expectedDimension); - } - - checkSizeNumericFields(row, columns[1], expectedSizes); - if (expectedCounts !== undefined) { - // Test sanity check. - assert.lengthOf(expectedCounts, expectedSizes.length); - assert.lengthOf(expectedAverageSizes, expectedSizes.length); - - checkNumericFields(row, columns[2], expectedCounts, - unitlessNumber_smallerIsBetter); - checkSizeNumericFields(row, columns[3], expectedAverageSizes); - } else { - // Test sanity check. - assert.lengthOf(columns, EXPECTED_COLUMNS_WITHOUT_COUNT.length); - assert.isUndefined(expectedAverageSizes); - } - - var actualDefinedValues = new Array(row.contexts.length); - for (var i = 0; i < row.contexts.length; i++) - actualDefinedValues[i] = row.contexts[i] !== undefined; - assert.deepEqual(actualDefinedValues, expectedDefinedValues); - } - - function checkRows(columns, rows, expectedStructure) { - if (expectedStructure === undefined) { - assert.isUndefined(rows); - return; - } - - if (typeof expectedStructure === 'number') { - assert.lengthOf(rows, expectedStructure); - return; - } - - assert.lengthOf(rows, expectedStructure.length); - for (var i = 0; i < expectedStructure.length; i++) { - var row = rows[i]; - var expectedRowStructure = expectedStructure[i]; - checkRow(columns, row, expectedRowStructure.dimension, - expectedRowStructure.title, expectedRowStructure.size, - expectedRowStructure.count, expectedRowStructure.averageSize, - expectedRowStructure.defined); - checkRows(columns, row.subRows, expectedRowStructure.children); - } - } - - function checkTable(viewEl, expectedConfig, expectedStructure) { - checkDisplayedElements(viewEl, { - infoText: false, - tableAndSelector: true, - infoBar: !!expectedConfig.expectedInfoBarDisplayed - }); - var table = viewEl.$.table; - var columns = table.tableColumns; - var rows = table.tableRows; - var expectedColumns = expectedConfig.expectedCountColumns ? - EXPECTED_COLUMNS_WITH_COUNT : EXPECTED_COLUMNS_WITHOUT_COUNT; - checkColumns(columns, expectedColumns, - expectedConfig.expectedAggregationMode); - checkRows(columns, rows, expectedStructure); - } - - function changeView(viewEl, viewType) { - tr.b.findDeepElementMatching(viewEl, 'select').selectedValue = viewType; - viewEl.rebuild(); - } - - /** - * Helper function for generating the expected structures of heap details - * pane tables. Given a table, this function generates its structure. - * - * This avoids the need to write such structures manually, which is very - * tedious. However, the correctness of the generated structures needs to be - * verified by the developer! Maximum line length must also be enforced - * manually. - */ - function printTable(test, viewEl) { - var generator = new tr.c.TestUtils.SourceGenerator(); - - function formatRows(rows) { - generator.formatMultiLineList(rows, function(row) { - generator.push('{'); - generator.indentBlock(2, true /* break line */, function() { - generator.push('dimension: '); - for (var dimensionTitle in RowDimension) { - if (row.dimension === RowDimension[dimensionTitle]) { - generator.push(dimensionTitle); - break; - } - } - generator.push(','); - generator.breakLine(); - - generator.push('title: \'', row.title, '\','); - generator.breakLine(); - - - var sizeFields = row.cells['Size'].fields; - generator.push('size: '); - generator.formatSingleLineList(sizeFields, function(field) { - generator.push( - field === undefined ? 'undefined' : String(field.value)); - }); - generator.push(','); - generator.breakLine(); - - if (row.cells['Count'] !== undefined) { - var countFields = row.cells['Count'].fields; - generator.push('count: '); - generator.formatSingleLineList(countFields, function(field) { - generator.push( - field === undefined ? 'undefined' : String(field.value)); - }); - generator.push(','); - generator.breakLine(); - - generator.push('averageSize: '); - generator.formatSingleLineList(row.cells['Average size'].fields, - function(field, index) { - if (field === undefined) { - generator.push('undefined'); - } else if (field.value === 0) { - generator.push('0'); - } else { - generator.push(String(sizeFields[index].value) + ' / ' + - String(countFields[index].value)); - } - }); - generator.push(','); - generator.breakLine(); - } - - generator.push('defined: '); - generator.formatSingleLineList(sizeFields, function(field) { - generator.push(String(field !== undefined)); - }); - - if (row.subRows && row.subRows.length > 0) { - generator.push(','); - generator.breakLine(); - generator.push('children: '); - formatRows(row.subRows); - } - }); - generator.breakLine(); - generator.push('}'); - }); - } - - generator.indentBlock(8, false /* don't break line */, - formatRows.bind(null, viewEl.$.table.tableRows)); - - tr.c.TestUtils.addSourceListing(test, generator.build()); - - throw new Error('This error is thrown to prevent accidentally ' + - 'checking in a test which calls this function.'); - } - - test('instantiate_empty', function() { - tr.ui.analysis.createAndCheckEmptyPanes(this, - 'tr-ui-a-memory-dump-heap-details-pane', 'heapDumps', - function(viewEl) { - // Check that the info text is shown. - checkDisplayedElements(viewEl, { - infoText: true, - tableAndSelector: false, - infoBar: false - }); - }); - }); - - test('instantiate_noEntries', function() { - var heapDumps = createHeapDumps(false).slice(0, 1); - heapDumps[0].entries = []; - - var viewEl = tr.ui.analysis.createTestPane( - 'tr-ui-a-memory-dump-heap-details-pane'); - viewEl.heapDumps = heapDumps; - viewEl.rebuild(); - this.addHTMLOutput(viewEl); - - // Top-down tree view (default). - checkTable(viewEl, - { /* empty expectedConfig */ }, - [ - { - dimension: ROOT, - title: 'partition_alloc', - size: [0], - defined: [true] - } - ]); - - changeView(viewEl, TOP_DOWN_HEAVY_VIEW); - checkTable(viewEl, - { expectedInfoBarDisplayed: true }, - [ - { - dimension: ROOT, - title: 'partition_alloc', - size: [0], - defined: [true] - } - ]); - - changeView(viewEl, BOTTOM_UP_HEAVY_VIEW); - checkTable(viewEl, - { expectedInfoBarDisplayed: true }, - [ - { - dimension: ROOT, - title: 'partition_alloc', - size: [0], - defined: [true] - } - ]); - - changeView(viewEl, TOP_DOWN_TREE_VIEW); - }); - - test('instantiate_single', function() { - var heapDumps = createHeapDumps(false).slice(0, 1); - - var viewEl = tr.ui.analysis.createTestPane( - 'tr-ui-a-memory-dump-heap-details-pane'); - viewEl.heapDumps = heapDumps; - viewEl.rebuild(); - this.addHTMLOutput(viewEl); - - // Top-down tree view (default). - checkTable(viewEl, - { /* empty expectedConfig */ }, - [ - { - dimension: ROOT, - title: 'partition_alloc', - size: [4194304], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'MessageLoop::RunTask', - size: [4194304], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [1406976], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: '<self>', - size: [102400], - defined: [true], - }, - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [1048576], - defined: [true], - children: [ - { - dimension: OBJECT_TYPE, - title: 'v8::Context', - size: [716800], - defined: [true], - }, - { - dimension: OBJECT_TYPE, - title: '<other>', - size: [331776], - defined: [true], - } - ] - }, - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [153600 + 51200], - defined: [true], - children: [ - { - dimension: OBJECT_TYPE, - title: 'v8::Context', - size: [153600], - defined: [true], - }, - { - dimension: OBJECT_TYPE, - title: '<other>', - size: [51200], - defined: [true], - } - ] - }, - { - dimension: STACK_FRAME, - title: '<other>', - size: [51200], - defined: [true], - }, - { - dimension: OBJECT_TYPE, - title: 'blink::Node', - size: [331776], - defined: [true], - }, - { - dimension: OBJECT_TYPE, - title: 'v8::Context', - size: [1024000], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [716800], - defined: [true], - }, - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [153600], - defined: [true], - }, - { - dimension: STACK_FRAME, - title: '<other>', - size: [153600], - defined: [true], - } - ] - }, - { - dimension: OBJECT_TYPE, - title: '<other>', - size: [51200], - defined: [true], - } - ] - }, - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [2404352], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [2404352], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: '<self>', - size: [307200], - defined: [true], - children: [ - { - dimension: OBJECT_TYPE, - title: 'v8::Context', - size: [15360], - defined: [true], - }, - { - dimension: OBJECT_TYPE, - title: '<other>', - size: [291840], - defined: [true], - } - ] - }, - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [2097152], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [2097152], - defined: [true], - } - ] - }, - { - dimension: OBJECT_TYPE, - title: 'v8::Context', - size: [20480], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: '<self>', - size: [15360], - defined: [true], - }, - { - dimension: STACK_FRAME, - title: '<other>', - size: [5120], - defined: [true], - } - ] - }, - { - dimension: OBJECT_TYPE, - title: '<other>', - size: [2383872], - defined: [true], - } - ] - } - ] - }, - { - dimension: STACK_FRAME, - title: '<other>', - size: [382976], - defined: [true], - }, - { - dimension: OBJECT_TYPE, - title: 'v8::Context', - size: [1048576], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [1024000], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [716800], - defined: [true], - }, - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [153600], - defined: [true], - }, - { - dimension: STACK_FRAME, - title: '<other>', - size: [153600], - defined: [true], - } - ] - }, - { - dimension: STACK_FRAME, - title: '<other>', - size: [24576], - defined: [true], - } - ] - }, - { - dimension: OBJECT_TYPE, - title: '<other>', - size: [3145728], - defined: [true], - } - ] - }, - { - dimension: OBJECT_TYPE, - title: 'v8::Context', - size: [1048576], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'MessageLoop::RunTask', - size: [1048576], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [1024000], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [716800], - defined: [true], - }, - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [153600], - defined: [true], - }, - { - dimension: STACK_FRAME, - title: '<other>', - size: [153600], - defined: [true], - } - ] - }, - { - dimension: STACK_FRAME, - title: '<other>', - size: [24576], - defined: [true], - } - ] - } - ] - }, - { - dimension: OBJECT_TYPE, - title: 'blink::Node', - size: [331776], - defined: [true], - }, - { - dimension: OBJECT_TYPE, - title: '<other>', - size: [2813952], - defined: [true], - } - ] - } - ]); - - changeView(viewEl, BOTTOM_UP_HEAVY_VIEW); - checkTable(viewEl, - { expectedInfoBarDisplayed: true }, - [ - { - dimension: ROOT, - title: 'partition_alloc', - size: [4194304], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'MessageLoop::RunTask', - size: [4194304], - defined: [true], - children: [ - { - dimension: OBJECT_TYPE, - title: 'v8::Context', - size: [1048576], - defined: [true] - }, - { - dimension: OBJECT_TYPE, - title: 'blink::Node', - size: [331776], - defined: [true] - }, - { - dimension: OBJECT_TYPE, - title: 'MissingSumOverAllTypes', - size: [51200], - defined: [true] - } - ] - }, - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [3811338], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'MessageLoop::RunTask', - size: [1406976], - defined: [true], - children: [ - { - dimension: OBJECT_TYPE, - title: 'blink::Node', - size: [331776], - defined: [true] - }, - { - dimension: OBJECT_TYPE, - title: 'v8::Context', - size: [1024000], - defined: [true] - }, - { - dimension: OBJECT_TYPE, - title: 'MissingSumOverAllTypes', - size: [51200], - defined: [true] - } - ] - }, - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [204800], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'MessageLoop::RunTask', - size: [204800], - defined: [true], - children: [ - { - dimension: OBJECT_TYPE, - title: 'v8::Context', - size: [153600], - defined: [true] - }, - { - dimension: OBJECT_TYPE, - title: 'MissingSumOverAllTypes', - size: [51200], - defined: [true] - } - ] - }, - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [51200], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'MessageLoop::RunTask', - size: [51200], - defined: [true], - children: [ - { - dimension: OBJECT_TYPE, - title: 'MissingSumOverAllTypes', - size: [51200], - defined: [true] - } - ] - }, - { - dimension: OBJECT_TYPE, - title: 'MissingSumOverAllTypes', - size: [51200], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'MessageLoop::RunTask', - size: [51200], - defined: [true] - } - ] - } - ] - }, - { - dimension: OBJECT_TYPE, - title: 'v8::Context', - size: [153600], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'MessageLoop::RunTask', - size: [153600], - defined: [true] - } - ] - }, - { - dimension: OBJECT_TYPE, - title: 'MissingSumOverAllTypes', - size: [51200], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'MessageLoop::RunTask', - size: [51200], - defined: [true] - }, - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [51200], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'MessageLoop::RunTask', - size: [51200], - defined: [true] - } - ] - } - ] - } - ] - }, - { - dimension: STACK_FRAME, - title: 'MissingParent', - size: [10], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'MessageLoop::RunTask', - size: [10], - defined: [true] - } - ] - }, - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [2404352], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'MessageLoop::RunTask', - size: [2404352], - defined: [true], - children: [ - { - dimension: OBJECT_TYPE, - title: 'v8::Context', - size: [20480], - defined: [true] - } - ] - }, - { - dimension: OBJECT_TYPE, - title: 'v8::Context', - size: [20480], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'MessageLoop::RunTask', - size: [20480], - defined: [true] - } - ] - } - ] - }, - { - dimension: OBJECT_TYPE, - title: 'blink::Node', - size: [331776], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'MessageLoop::RunTask', - size: [331776], - defined: [true] - } - ] - }, - { - dimension: OBJECT_TYPE, - title: 'v8::Context', - size: [1044480], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'MessageLoop::RunTask', - size: [1024000], - defined: [true] - }, - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [153600], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'MessageLoop::RunTask', - size: [153600], - defined: [true] - } - ] - }, - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [20480], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'MessageLoop::RunTask', - size: [20480], - defined: [true] - } - ] - } - ] - }, - { - dimension: OBJECT_TYPE, - title: 'MissingSumOverAllTypes', - size: [51200], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'MessageLoop::RunTask', - size: [51200], - defined: [true] - }, - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [51200], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'MessageLoop::RunTask', - size: [51200], - defined: [true] - }, - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [51200], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'MessageLoop::RunTask', - size: [51200], - defined: [true] - } - ] - } - ] - } - ] - } - ] - }, - { - dimension: STACK_FRAME, - title: '<self>', - size: [409600], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [409600], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'MessageLoop::RunTask', - size: [102400], - defined: [true] - }, - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [307200], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'MessageLoop::RunTask', - size: [307200], - defined: [true], - children: [ - { - dimension: OBJECT_TYPE, - title: 'v8::Context', - size: [15360], - defined: [true] - } - ] - }, - { - dimension: OBJECT_TYPE, - title: 'v8::Context', - size: [15360], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'MessageLoop::RunTask', - size: [15360], - defined: [true] - } - ] - } - ] - }, - { - dimension: OBJECT_TYPE, - title: 'v8::Context', - size: [15360], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [15360], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'MessageLoop::RunTask', - size: [15360], - defined: [true] - } - ] - } - ] - } - ] - }, - { - dimension: OBJECT_TYPE, - title: 'v8::Context', - size: [15360], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [15360], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [15360], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'MessageLoop::RunTask', - size: [15360], - defined: [true] - } - ] - } - ] - } - ] - } - ] - }, - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [3452928], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [3145728], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'MessageLoop::RunTask', - size: [1048576], - defined: [true], - children: [ - { - dimension: OBJECT_TYPE, - title: 'v8::Context', - size: [716800], - defined: [true] - } - ] - }, - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [2097152], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'MessageLoop::RunTask', - size: [2097152], - defined: [true] - } - ] - }, - { - dimension: OBJECT_TYPE, - title: 'v8::Context', - size: [716800], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'MessageLoop::RunTask', - size: [716800], - defined: [true] - } - ] - } - ] - }, - { - dimension: STACK_FRAME, - title: 'MessageLoop::RunTask', - size: [2404352], - defined: [true], - children: [ - { - dimension: OBJECT_TYPE, - title: 'v8::Context', - size: [20480], - defined: [true] - } - ] - }, - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [2097152], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [2097152], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [2097152], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'MessageLoop::RunTask', - size: [2097152], - defined: [true] - } - ] - } - ] - } - ] - }, - { - dimension: OBJECT_TYPE, - title: 'v8::Context', - size: [737280], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [716800], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'MessageLoop::RunTask', - size: [716800], - defined: [true] - } - ] - }, - { - dimension: STACK_FRAME, - title: 'MessageLoop::RunTask', - size: [20480], - defined: [true] - } - ] - } - ] - }, - { - dimension: STACK_FRAME, - title: 'MissingParent', - size: [10], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'MessageLoop::RunTask', - size: [10], - defined: [true] - } - ] - }, - { - dimension: OBJECT_TYPE, - title: 'v8::Context', - size: [1048576], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'MessageLoop::RunTask', - size: [1048576], - defined: [true] - }, - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [1044480], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'MessageLoop::RunTask', - size: [1024000], - defined: [true] - }, - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [153600], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'MessageLoop::RunTask', - size: [153600], - defined: [true] - } - ] - }, - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [20480], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'MessageLoop::RunTask', - size: [20480], - defined: [true] - } - ] - } - ] - }, - { - dimension: STACK_FRAME, - title: '<self>', - size: [15360], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [15360], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [15360], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'MessageLoop::RunTask', - size: [15360], - defined: [true] - } - ] - } - ] - } - ] - }, - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [737280], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [716800], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'MessageLoop::RunTask', - size: [716800], - defined: [true] - } - ] - }, - { - dimension: STACK_FRAME, - title: 'MessageLoop::RunTask', - size: [20480], - defined: [true] - } - ] - } - ] - }, - { - dimension: OBJECT_TYPE, - title: 'blink::Node', - size: [331776], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'MessageLoop::RunTask', - size: [331776], - defined: [true] - }, - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [331776], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'MessageLoop::RunTask', - size: [331776], - defined: [true] - } - ] - } - ] - }, - { - dimension: OBJECT_TYPE, - title: 'MissingSumOverAllTypes', - size: [51200], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'MessageLoop::RunTask', - size: [51200], - defined: [true] - }, - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [51200], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'MessageLoop::RunTask', - size: [51200], - defined: [true] - }, - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [51200], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'MessageLoop::RunTask', - size: [51200], - defined: [true] - }, - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [51200], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'MessageLoop::RunTask', - size: [51200], - defined: [true] - } - ] - } - ] - } - ] - } - ] - } - ] - } - ]); - - changeView(viewEl, TOP_DOWN_HEAVY_VIEW); - checkTable(viewEl, - { expectedInfoBarDisplayed: true }, [ - { - dimension: ROOT, - title: 'partition_alloc', - size: [4194304], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'MessageLoop::RunTask', - size: [4194304], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [1406976], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: '<self>', - size: [102400], - defined: [true], - }, - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [1048576], - defined: [true], - children: [ - { - dimension: OBJECT_TYPE, - title: 'v8::Context', - size: [716800], - defined: [true], - } - ] - }, - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [153600 + 51200], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [51200], - defined: [true], - children: [ - { - dimension: OBJECT_TYPE, - title: 'MissingSumOverAllTypes', - size: [51200], - defined: [true], - } - ] - }, - { - dimension: OBJECT_TYPE, - title: 'v8::Context', - size: [153600], - defined: [true], - }, - { - dimension: OBJECT_TYPE, - title: 'MissingSumOverAllTypes', - size: [51200], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [51200], - defined: [true], - } - ] - } - ] - }, - { - dimension: OBJECT_TYPE, - title: 'blink::Node', - size: [331776], - defined: [true], - }, - { - dimension: OBJECT_TYPE, - title: 'v8::Context', - size: [1024000], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [716800], - defined: [true], - }, - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [153600], - defined: [true], - } - ] - }, - { - dimension: OBJECT_TYPE, - title: 'MissingSumOverAllTypes', - size: [51200], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [51200], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [51200], - defined: [true], - } - ] - } - ] - } - ] - }, - { - dimension: STACK_FRAME, - title: 'MissingParent', - size: [10], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [10], - defined: [true], - } - ] - }, - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [2404352], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [2404352], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: '<self>', - size: [307200], - defined: [true], - children: [ - { - dimension: OBJECT_TYPE, - title: 'v8::Context', - size: [15360], - defined: [true], - } - ] - }, - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [2097152], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [2097152], - defined: [true], - } - ] - }, - { - dimension: OBJECT_TYPE, - title: 'v8::Context', - size: [20480], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: '<self>', - size: [15360], - defined: [true], - } - ] - } - ] - }, - { - dimension: OBJECT_TYPE, - title: 'v8::Context', - size: [20480], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [20480], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: '<self>', - size: [15360], - defined: [true], - } - ] - } - ] - } - ] - }, - { - dimension: OBJECT_TYPE, - title: 'v8::Context', - size: [1048576], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [1024000], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [716800], - defined: [true], - }, - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [153600], - defined: [true], - } - ] - }, - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [20480], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [20480], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: '<self>', - size: [15360], - defined: [true], - } - ] - } - ] - } - ] - }, - { - dimension: OBJECT_TYPE, - title: 'blink::Node', - size: [331776], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [331776], - defined: [true], - } - ] - }, - { - dimension: OBJECT_TYPE, - title: 'MissingSumOverAllTypes', - size: [51200], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [51200], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [51200], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [51200], - defined: [true], - } - ] - } - ] - } - ] - } - ] - }, - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [1406976 + 10 + 2404352], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: '<self>', - size: [102400 + 307200], - defined: [true], - children: [ - { - dimension: OBJECT_TYPE, - title: 'v8::Context', - size: [15360], - defined: [true], - } - ] - }, - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [1048576 + 2097152], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [2097152], - defined: [true], - }, - { - dimension: OBJECT_TYPE, - title: 'v8::Context', - size: [716800], - defined: [true], - } - ] - }, - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [153600 + 51200], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [51200], - defined: [true], - children: [ - { - dimension: OBJECT_TYPE, - title: 'MissingSumOverAllTypes', - size: [51200], - defined: [true], - } - ] - }, - { - dimension: OBJECT_TYPE, - title: 'v8::Context', - size: [153600], - defined: [true], - }, - { - dimension: OBJECT_TYPE, - title: 'MissingSumOverAllTypes', - size: [51200], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [51200], - defined: [true], - } - ] - } - ] - }, - { - dimension: OBJECT_TYPE, - title: 'blink::Node', - size: [331776], - defined: [true], - }, - { - dimension: OBJECT_TYPE, - title: 'v8::Context', - size: [1024000 + 20480], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: '<self>', - size: [15360], - defined: [true], - }, - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [716800], - defined: [true], - }, - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [153600], - defined: [true], - } - ] - }, - { - dimension: OBJECT_TYPE, - title: 'MissingSumOverAllTypes', - size: [51200], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [51200], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [51200], - defined: [true], - } - ] - } - ] - } - ] - }, - { - dimension: STACK_FRAME, - title: '<self>', - size: [102400 + 307200], - defined: [true], - children: [ - { - dimension: OBJECT_TYPE, - title: 'v8::Context', - size: [15360], - defined: [true], - } - ] - }, - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [1048576 + 2404352], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [2404352], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: '<self>', - size: [307200], - defined: [true], - children: [ - { - dimension: OBJECT_TYPE, - title: 'v8::Context', - size: [15360], - defined: [true], - } - ] - }, - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [2097152], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [2097152], - defined: [true], - } - ] - }, - { - dimension: OBJECT_TYPE, - title: 'v8::Context', - size: [20480], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: '<self>', - size: [15360], - defined: [true], - } - ] - } - ] - }, - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [2097152], - defined: [true], - }, - { - dimension: OBJECT_TYPE, - title: 'v8::Context', - size: [716800 + 20480], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [20480], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: '<self>', - size: [15360], - defined: [true], - } - ] - } - ] - } - ] - }, - { - dimension: STACK_FRAME, - title: 'MissingParent', - size: [10], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [10], - defined: [true], - } - ] - }, - { - dimension: OBJECT_TYPE, - title: 'v8::Context', - size: [1048576], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'MessageLoop::RunTask', - size: [1048576], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [1024000], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [716800], - defined: [true], - }, - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [153600], - defined: [true], - } - ] - }, - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [20480], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [20480], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: '<self>', - size: [15360], - defined: [true], - } - ] - } - ] - } - ] - }, - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [1024000 + 20480], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: '<self>', - size: [15360], - defined: [true], - }, - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [716800], - defined: [true], - }, - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [153600], - defined: [true], - } - ] - }, - { - dimension: STACK_FRAME, - title: '<self>', - size: [15360], - defined: [true], - }, - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [716800 + 20480], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [20480], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: '<self>', - size: [15360], - defined: [true], - } - ] - } - ] - } - ] - }, - { - dimension: OBJECT_TYPE, - title: 'blink::Node', - size: [331776], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'MessageLoop::RunTask', - size: [331776], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [331776], - defined: [true], - } - ] - }, - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [331776], - defined: [true], - } - ] - }, - { - dimension: OBJECT_TYPE, - title: 'MissingSumOverAllTypes', - size: [51200], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'MessageLoop::RunTask', - size: [51200], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [51200], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [51200], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [51200], - defined: [true], - } - ] - } - ] - } - ] - }, - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [51200], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [51200], - defined: [true], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [51200], - defined: [true], - } - ] - } - ] - } - ] - } - ] - } - ]); - }); - - test('instantiate_multipleDiff', function() { - var heapDumps = createHeapDumps(true /* with allocation counts */); - - var viewEl = tr.ui.analysis.createTestPane( - 'tr-ui-a-memory-dump-heap-details-pane'); - viewEl.heapDumps = heapDumps; - viewEl.aggregationMode = AggregationMode.DIFF; - viewEl.rebuild(); - this.addHTMLOutput(viewEl); - - changeView(viewEl, TOP_DOWN_HEAVY_VIEW); - checkTable(viewEl, - { - expectedAggregationMode: AggregationMode.DIFF, - expectedInfoBarDisplayed: true, - expectedCountColumns: true - }, - [ - { - dimension: ROOT, - title: 'partition_alloc', - size: [4194304, 4954521], - count: [1000, 900], - averageSize: [4194304 / 1000, 4954521 / 900], - defined: [true, true], - children: [ - { - dimension: STACK_FRAME, - title: 'MessageLoop::RunTask', - size: [4194304, 4823449], - count: [1000, 884], - averageSize: [4194304 / 1000, 4823449 / 884], - defined: [true, true], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [1406976, 2170880], - count: [299, 600], - averageSize: [1406976 / 299, 2170880 / 600], - defined: [true, true], - children: [ - { - dimension: STACK_FRAME, - title: '<self>', - size: [102400, 393216], - count: [30, 17], - averageSize: [102400 / 30, 393216 / 17], - defined: [true, true] - }, - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [1048576, 1572864], - count: [101, 270], - averageSize: [1048576 / 101, 1572864 / 270], - defined: [true, true], - children: [ - { - dimension: OBJECT_TYPE, - title: 'v8::Context', - size: [716800, 614400], - count: [100, 123], - averageSize: [716800 / 100, 614400 / 123], - defined: [true, true] - }, - { - dimension: OBJECT_TYPE, - title: 'blink::Node', - size: [undefined, 819200], - count: [undefined, 4], - averageSize: [undefined, 819200 / 4], - defined: [false, true] - } - ] - }, - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [204800, 204800], - count: [25, 313], - averageSize: [204800 / 25, 204800 / 313], - defined: [true, true], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [51200, 204800], - count: [9, 313], - averageSize: [51200 / 9, 204800 / 313], - defined: [true, true], - children: [ - { - dimension: OBJECT_TYPE, - title: 'MissingSumOverAllTypes', - size: [51200, undefined], - count: [9, undefined], - averageSize: [51200 / 9, undefined], - defined: [true, false] - } - ] - }, - { - dimension: OBJECT_TYPE, - title: 'v8::Context', - size: [153600, 122880], - count: [15, 270], - averageSize: [153600 / 15, 122880 / 270], - defined: [true, true] - }, - { - dimension: OBJECT_TYPE, - title: 'MissingSumOverAllTypes', - size: [51200, undefined], - count: [9, undefined], - averageSize: [51200 / 9, undefined], - defined: [true, false], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [51200, undefined], - count: [9, undefined], - averageSize: [51200 / 9, undefined], - defined: [true, false] - } - ] - } - ] - }, - { - dimension: OBJECT_TYPE, - title: 'blink::Node', - size: [331776, 819200], - count: [10, 4], - averageSize: [331776 / 10, 819200 / 4], - defined: [true, true], - children: [ - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [undefined, 819200], - count: [undefined, 4], - averageSize: [undefined, 819200 / 4], - defined: [false, true] - } - ] - }, - { - dimension: OBJECT_TYPE, - title: 'v8::Context', - size: [1024000, 1024000], - count: [176, 500], - averageSize: [1024000 / 176, 1024000 / 500], - defined: [true, true], - children: [ - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [716800, 614400], - count: [100, 123], - averageSize: [716800 / 100, 614400 / 123], - defined: [true, true] - }, - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [153600, 122880], - count: [15, 270], - averageSize: [153600 / 15, 122880 / 270], - defined: [true, true] - } - ] - }, - { - dimension: OBJECT_TYPE, - title: 'MissingSumOverAllTypes', - size: [51200, undefined], - count: [9, undefined], - averageSize: [51200 / 9, undefined], - defined: [true, false], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [51200, undefined], - count: [9, undefined], - averageSize: [51200 / 9, undefined], - defined: [true, false], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [51200, undefined], - count: [9, undefined], - averageSize: [51200 / 9, undefined], - defined: [true, false] - } - ] - } - ] - } - ] - }, - { - dimension: STACK_FRAME, - title: 'MissingParent', - size: [10, undefined], - count: [2, undefined], - averageSize: [10 / 2, undefined], - defined: [true, false], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [10, undefined], - count: [2, undefined], - averageSize: [10 / 2, undefined], - defined: [true, false] - } - ] - }, - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [2404352, 2621440], - count: [399, 199], - averageSize: [2404352 / 399, 2621440 / 199], - defined: [true, true], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [2404352, 2621440], - count: [399, 199], - averageSize: [2404352 / 399, 2621440 / 199], - defined: [true, true], - children: [ - { - dimension: STACK_FRAME, - title: '<self>', - size: [307200, undefined], - count: [300, undefined], - averageSize: [307200 / 300, undefined], - defined: [true, false], - children: [ - { - dimension: OBJECT_TYPE, - title: 'v8::Context', - size: [15360, undefined], - count: [5, undefined], - averageSize: [15360 / 5, undefined], - defined: [true, false] - } - ] - }, - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [2097152, 2516582], - count: [99, 158], - averageSize: [2097152 / 99, 2516582 / 158], - defined: [true, true], - children: [ - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [2097152, undefined], - count: [99, undefined], - averageSize: [2097152 / 99, undefined], - defined: [true, false] - } - ] - }, - { - dimension: OBJECT_TYPE, - title: 'v8::Context', - size: [20480, 20480], - count: [6, 4], - averageSize: [20480 / 6, 20480 / 4], - defined: [true, true], - children: [ - { - dimension: STACK_FRAME, - title: '<self>', - size: [15360, undefined], - count: [5, undefined], - averageSize: [15360 / 5, undefined], - defined: [true, false] - } - ] - }, - { - dimension: OBJECT_TYPE, - title: 'WTF::StringImpl', - size: [undefined, 126362], - count: [undefined, 56], - averageSize: [undefined, 126362 / 56], - defined: [false, true] - } - ] - }, - { - dimension: OBJECT_TYPE, - title: 'v8::Context', - size: [20480, 20480], - count: [6, 4], - averageSize: [20480 / 6, 20480 / 4], - defined: [true, true], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [20480, 20480], - count: [6, 4], - averageSize: [20480 / 6, 20480 / 4], - defined: [true, true], - children: [ - { - dimension: STACK_FRAME, - title: '<self>', - size: [15360, undefined], - count: [5, undefined], - averageSize: [15360 / 5, undefined], - defined: [true, false] - } - ] - } - ] - }, - { - dimension: OBJECT_TYPE, - title: 'WTF::StringImpl', - size: [undefined, 126362], - count: [undefined, 56], - averageSize: [undefined, 126362 / 56], - defined: [false, true], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [undefined, 126362], - count: [undefined, 56], - averageSize: [undefined, 126362 / 56], - defined: [false, true] - } - ] - } - ] - }, - { - dimension: OBJECT_TYPE, - title: 'v8::Context', - size: [1048576, 1127219], - count: [200, 504], - averageSize: [1048576 / 200, 1127219 / 504], - defined: [true, true], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [1024000, 1024000], - count: [176, 500], - averageSize: [1024000 / 176, 1024000 / 500], - defined: [true, true], - children: [ - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [716800, 614400], - count: [100, 123], - averageSize: [716800 / 100, 614400 / 123], - defined: [true, true] - }, - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [153600, 122880], - count: [15, 270], - averageSize: [153600 / 15, 122880 / 270], - defined: [true, true] - } - ] - }, - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [20480, 20480], - count: [6, 4], - averageSize: [20480 / 6, 20480 / 4], - defined: [true, true], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [20480, 20480], - count: [6, 4], - averageSize: [20480 / 6, 20480 / 4], - defined: [true, true], - children: [ - { - dimension: STACK_FRAME, - title: '<self>', - size: [15360, undefined], - count: [5, undefined], - averageSize: [15360 / 5, undefined], - defined: [true, false] - } - ] - } - ] - } - ] - }, - { - dimension: OBJECT_TYPE, - title: 'blink::Node', - size: [331776, 819200], - count: [10, 4], - averageSize: [331776 / 10, 819200 / 4], - defined: [true, true], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [331776, 819200], - count: [10, 4], - averageSize: [331776 / 10, 819200 / 4], - defined: [true, true], - children: [ - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [undefined, 819200], - count: [undefined, 4], - averageSize: [undefined, 819200 / 4], - defined: [false, true] - } - ] - } - ] - }, - { - dimension: OBJECT_TYPE, - title: 'MissingSumOverAllTypes', - size: [51200, undefined], - count: [9, undefined], - averageSize: [51200 / 9, undefined], - defined: [true, false], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [51200, undefined], - count: [9, undefined], - averageSize: [51200 / 9, undefined], - defined: [true, false], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [51200, undefined], - count: [9, undefined], - averageSize: [51200 / 9, undefined], - defined: [true, false], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [51200, undefined], - count: [9, undefined], - averageSize: [51200 / 9, undefined], - defined: [true, false] - } - ] - } - ] - } - ] - }, - { - dimension: OBJECT_TYPE, - title: 'WTF::StringImpl', - size: [undefined, 126362], - count: [undefined, 56], - averageSize: [undefined, 126362 / 56], - defined: [false, true], - children: [ - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [undefined, 126362], - count: [undefined, 56], - averageSize: [undefined, 126362 / 56], - defined: [false, true], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [undefined, 126362], - count: [undefined, 56], - averageSize: [undefined, 126362 / 56], - defined: [false, true] - } - ] - } - ] - } - ] - }, - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [3811338, 4792320], - count: [700, 799], - averageSize: [3811338 / 700, 4792320 / 799], - defined: [true, true], - children: [ - { - dimension: STACK_FRAME, - title: '<self>', - size: [409600, 393216], - count: [330, 17], - averageSize: [409600 / 330, 393216 / 17], - defined: [true, true], - children: [ - { - dimension: OBJECT_TYPE, - title: 'v8::Context', - size: [15360, undefined], - count: [5, undefined], - averageSize: [15360 / 5, undefined], - defined: [true, false] - } - ] - }, - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [3145728, 4089446], - count: [200, 428], - averageSize: [3145728 / 200, 4089446 / 428], - defined: [true, true], - children: [ - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [2097152, undefined], - count: [99, undefined], - averageSize: [2097152 / 99, undefined], - defined: [true, false] - }, - { - dimension: OBJECT_TYPE, - title: 'v8::Context', - size: [716800, 614400], - count: [100, 123], - averageSize: [716800 / 100, 614400 / 123], - defined: [true, true] - }, - { - dimension: OBJECT_TYPE, - title: 'blink::Node', - size: [undefined, 819200], - count: [undefined, 4], - averageSize: [undefined, 819200 / 4], - defined: [false, true] - } - ] - }, - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [204800, 204800], - count: [25, 313], - averageSize: [204800 / 25, 204800 / 313], - defined: [true, true], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [51200, 204800], - count: [9, 313], - averageSize: [51200 / 9, 204800 / 313], - defined: [true, true], - children: [ - { - dimension: OBJECT_TYPE, - title: 'MissingSumOverAllTypes', - size: [51200, undefined], - count: [9, undefined], - averageSize: [51200 / 9, undefined], - defined: [true, false] - } - ] - }, - { - dimension: OBJECT_TYPE, - title: 'v8::Context', - size: [153600, 122880], - count: [15, 270], - averageSize: [153600 / 15, 122880 / 270], - defined: [true, true] - }, - { - dimension: OBJECT_TYPE, - title: 'MissingSumOverAllTypes', - size: [51200, undefined], - count: [9, undefined], - averageSize: [51200 / 9, undefined], - defined: [true, false], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [51200, undefined], - count: [9, undefined], - averageSize: [51200 / 9, undefined], - defined: [true, false] - } - ] - } - ] - }, - { - dimension: OBJECT_TYPE, - title: 'blink::Node', - size: [331776, 819200], - count: [10, 4], - averageSize: [331776 / 10, 819200 / 4], - defined: [true, true], - children: [ - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [undefined, 819200], - count: [undefined, 4], - averageSize: [undefined, 819200 / 4], - defined: [false, true] - } - ] - }, - { - dimension: OBJECT_TYPE, - title: 'v8::Context', - size: [1044480, 1044480], - count: [182, 504], - averageSize: [1044480 / 182, 1044480 / 504], - defined: [true, true], - children: [ - { - dimension: STACK_FRAME, - title: '<self>', - size: [15360, undefined], - count: [5, undefined], - averageSize: [15360 / 5, undefined], - defined: [true, false] - }, - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [716800, 614400], - count: [100, 123], - averageSize: [716800 / 100, 614400 / 123], - defined: [true, true] - }, - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [153600, 122880], - count: [15, 270], - averageSize: [153600 / 15, 122880 / 270], - defined: [true, true] - } - ] - }, - { - dimension: OBJECT_TYPE, - title: 'MissingSumOverAllTypes', - size: [51200, undefined], - count: [9, undefined], - averageSize: [51200 / 9, undefined], - defined: [true, false], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [51200, undefined], - count: [9, undefined], - averageSize: [51200 / 9, undefined], - defined: [true, false], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [51200, undefined], - count: [9, undefined], - averageSize: [51200 / 9, undefined], - defined: [true, false] - } - ] - } - ] - }, - { - dimension: OBJECT_TYPE, - title: 'WTF::StringImpl', - size: [undefined, 126362], - count: [undefined, 56], - averageSize: [undefined, 126362 / 56], - defined: [false, true] - } - ] - }, - { - dimension: STACK_FRAME, - title: '<self>', - size: [409600, 524288], - count: [330, 33], - averageSize: [409600 / 330, 524288 / 33], - defined: [true, true], - children: [ - { - dimension: OBJECT_TYPE, - title: 'v8::Context', - size: [15360, 131072], - count: [5, 16], - averageSize: [15360 / 5, 131072 / 16], - defined: [true, true] - } - ] - }, - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [3452928, 4194304], - count: [500, 469], - averageSize: [3452928 / 500, 4194304 / 469], - defined: [true, true], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [2404352, 2621440], - count: [399, 199], - averageSize: [2404352 / 399, 2621440 / 199], - defined: [true, true], - children: [ - { - dimension: STACK_FRAME, - title: '<self>', - size: [307200, undefined], - count: [300, undefined], - averageSize: [307200 / 300, undefined], - defined: [true, false], - children: [ - { - dimension: OBJECT_TYPE, - title: 'v8::Context', - size: [15360, undefined], - count: [5, undefined], - averageSize: [15360 / 5, undefined], - defined: [true, false] - } - ] - }, - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [2097152, 2516582], - count: [99, 158], - averageSize: [2097152 / 99, 2516582 / 158], - defined: [true, true], - children: [ - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [2097152, undefined], - count: [99, undefined], - averageSize: [2097152 / 99, undefined], - defined: [true, false] - } - ] - }, - { - dimension: OBJECT_TYPE, - title: 'v8::Context', - size: [20480, 20480], - count: [6, 4], - averageSize: [20480 / 6, 20480 / 4], - defined: [true, true], - children: [ - { - dimension: STACK_FRAME, - title: '<self>', - size: [15360, undefined], - count: [5, undefined], - averageSize: [15360 / 5, undefined], - defined: [true, false] - } - ] - }, - { - dimension: OBJECT_TYPE, - title: 'WTF::StringImpl', - size: [undefined, 126362], - count: [undefined, 56], - averageSize: [undefined, 126362 / 56], - defined: [false, true] - } - ] - }, - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [2097152, undefined], - count: [99, undefined], - averageSize: [2097152 / 99, undefined], - defined: [true, false] - }, - { - dimension: OBJECT_TYPE, - title: 'v8::Context', - size: [737280, 634880], - count: [106, 127], - averageSize: [737280 / 106, 634880 / 127], - defined: [true, true], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [20480, 20480], - count: [6, 4], - averageSize: [20480 / 6, 20480 / 4], - defined: [true, true], - children: [ - { - dimension: STACK_FRAME, - title: '<self>', - size: [15360, undefined], - count: [5, undefined], - averageSize: [15360 / 5, undefined], - defined: [true, false] - } - ] - } - ] - }, - { - dimension: OBJECT_TYPE, - title: 'blink::Node', - size: [undefined, 819200], - count: [undefined, 4], - averageSize: [undefined, 819200 / 4], - defined: [false, true] - }, - { - dimension: OBJECT_TYPE, - title: 'WTF::StringImpl', - size: [undefined, 126362], - count: [undefined, 56], - averageSize: [undefined, 126362 / 56], - defined: [false, true], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [undefined, 126362], - count: [undefined, 56], - averageSize: [undefined, 126362 / 56], - defined: [false, true] - } - ] - } - ] - }, - { - dimension: STACK_FRAME, - title: 'MissingParent', - size: [10, undefined], - count: [2, undefined], - averageSize: [10 / 2, undefined], - defined: [true, false], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [10, undefined], - count: [2, undefined], - averageSize: [10 / 2, undefined], - defined: [true, false] - } - ] - }, - { - dimension: OBJECT_TYPE, - title: 'v8::Context', - size: [1048576, 1258291], - count: [200, 520], - averageSize: [1048576 / 200, 1258291 / 520], - defined: [true, true], - children: [ - { - dimension: STACK_FRAME, - title: 'MessageLoop::RunTask', - size: [1048576, 1127219], - count: [200, 504], - averageSize: [1048576 / 200, 1127219 / 504], - defined: [true, true], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [1024000, 1024000], - count: [176, 500], - averageSize: [1024000 / 176, 1024000 / 500], - defined: [true, true], - children: [ - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [716800, 614400], - count: [100, 123], - averageSize: [716800 / 100, 614400 / 123], - defined: [true, true] - }, - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [153600, 122880], - count: [15, 270], - averageSize: [153600 / 15, 122880 / 270], - defined: [true, true] - } - ] - }, - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [20480, 20480], - count: [6, 4], - averageSize: [20480 / 6, 20480 / 4], - defined: [true, true], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [20480, 20480], - count: [6, 4], - averageSize: [20480 / 6, 20480 / 4], - defined: [true, true], - children: [ - { - dimension: STACK_FRAME, - title: '<self>', - size: [15360, undefined], - count: [5, undefined], - averageSize: [15360 / 5, undefined], - defined: [true, false] - } - ] - } - ] - } - ] - }, - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [1044480, 1044480], - count: [182, 504], - averageSize: [1044480 / 182, 1044480 / 504], - defined: [true, true], - children: [ - { - dimension: STACK_FRAME, - title: '<self>', - size: [15360, undefined], - count: [5, undefined], - averageSize: [15360 / 5, undefined], - defined: [true, false] - }, - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [716800, 614400], - count: [100, 123], - averageSize: [716800 / 100, 614400 / 123], - defined: [true, true] - }, - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [153600, 122880], - count: [15, 270], - averageSize: [153600 / 15, 122880 / 270], - defined: [true, true] - } - ] - }, - { - dimension: STACK_FRAME, - title: '<self>', - size: [15360, 131072], - count: [5, 16], - averageSize: [15360 / 5, 131072 / 16], - defined: [true, true] - }, - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [737280, 634880], - count: [106, 127], - averageSize: [737280 / 106, 634880 / 127], - defined: [true, true], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [20480, 20480], - count: [6, 4], - averageSize: [20480 / 6, 20480 / 4], - defined: [true, true], - children: [ - { - dimension: STACK_FRAME, - title: '<self>', - size: [15360, undefined], - count: [5, undefined], - averageSize: [15360 / 5, undefined], - defined: [true, false] - } - ] - } - ] - } - ] - }, - { - dimension: OBJECT_TYPE, - title: 'blink::Node', - size: [331776, 1048576], - count: [10, 5], - averageSize: [331776 / 10, 1048576 / 5], - defined: [true, true], - children: [ - { - dimension: STACK_FRAME, - title: 'MessageLoop::RunTask', - size: [331776, 819200], - count: [10, 4], - averageSize: [331776 / 10, 819200 / 4], - defined: [true, true], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [331776, 819200], - count: [10, 4], - averageSize: [331776 / 10, 819200 / 4], - defined: [true, true], - children: [ - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [undefined, 819200], - count: [undefined, 4], - averageSize: [undefined, 819200 / 4], - defined: [false, true] - } - ] - } - ] - }, - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [331776, 819200], - count: [10, 4], - averageSize: [331776 / 10, 819200 / 4], - defined: [true, true], - children: [ - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [undefined, 819200], - count: [undefined, 4], - averageSize: [undefined, 819200 / 4], - defined: [false, true] - } - ] - }, - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [undefined, 819200], - count: [undefined, 4], - averageSize: [undefined, 819200 / 4], - defined: [false, true] - } - ] - }, - { - dimension: OBJECT_TYPE, - title: 'MissingSumOverAllTypes', - size: [51200, undefined], - count: [9, undefined], - averageSize: [51200 / 9, undefined], - defined: [true, false], - children: [ - { - dimension: STACK_FRAME, - title: 'MessageLoop::RunTask', - size: [51200, undefined], - count: [9, undefined], - averageSize: [51200 / 9, undefined], - defined: [true, false], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [51200, undefined], - count: [9, undefined], - averageSize: [51200 / 9, undefined], - defined: [true, false], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [51200, undefined], - count: [9, undefined], - averageSize: [51200 / 9, undefined], - defined: [true, false], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [51200, undefined], - count: [9, undefined], - averageSize: [51200 / 9, undefined], - defined: [true, false] - } - ] - } - ] - } - ] - }, - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [51200, undefined], - count: [9, undefined], - averageSize: [51200 / 9, undefined], - defined: [true, false], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [51200, undefined], - count: [9, undefined], - averageSize: [51200 / 9, undefined], - defined: [true, false], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [51200, undefined], - count: [9, undefined], - averageSize: [51200 / 9, undefined], - defined: [true, false] - } - ] - } - ] - } - ] - }, - { - dimension: OBJECT_TYPE, - title: 'WTF::StringImpl', - size: [undefined, 126362], - count: [undefined, 56], - averageSize: [undefined, 126362 / 56], - defined: [false, true], - children: [ - { - dimension: STACK_FRAME, - title: 'MessageLoop::RunTask', - size: [undefined, 126362], - count: [undefined, 56], - averageSize: [undefined, 126362 / 56], - defined: [false, true], - children: [ - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [undefined, 126362], - count: [undefined, 56], - averageSize: [undefined, 126362 / 56], - defined: [false, true], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [undefined, 126362], - count: [undefined, 56], - averageSize: [undefined, 126362 / 56], - defined: [false, true] - } - ] - } - ] - }, - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [undefined, 126362], - count: [undefined, 56], - averageSize: [undefined, 126362 / 56], - defined: [false, true] - }, - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [undefined, 126362], - count: [undefined, 56], - averageSize: [undefined, 126362 / 56], - defined: [false, true], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [undefined, 126362], - count: [undefined, 56], - averageSize: [undefined, 126362 / 56], - defined: [false, true] - } - ] - } - ] - } - ] - } - ]); - - changeView(viewEl, TOP_DOWN_TREE_VIEW); - checkTable(viewEl, - { - expectedAggregationMode: AggregationMode.DIFF, - expectedCountColumns: true - }, - [ - { - dimension: ROOT, - title: 'partition_alloc', - size: [4194304, 4954521], - count: [1000, 900], - averageSize: [4194304 / 1000, 4954521 / 900], - defined: [true, true], - children: [ - { - dimension: STACK_FRAME, - title: 'MessageLoop::RunTask', - size: [4194304, 4823449], - count: [1000, 884], - averageSize: [4194304 / 1000, 4823449 / 884], - defined: [true, true], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [1406976, 2170880], - count: [299, 600], - averageSize: [1406976 / 299, 2170880 / 600], - defined: [true, true], - children: [ - { - dimension: STACK_FRAME, - title: '<self>', - size: [102400, 393216], - count: [30, 17], - averageSize: [102400 / 30, 393216 / 17], - defined: [true, true] - }, - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [1048576, 1572864], - count: [101, 270], - averageSize: [1048576 / 101, 1572864 / 270], - defined: [true, true], - children: [ - { - dimension: OBJECT_TYPE, - title: 'v8::Context', - size: [716800, 614400], - count: [100, 123], - averageSize: [716800 / 100, 614400 / 123], - defined: [true, true] - }, - { - dimension: OBJECT_TYPE, - title: '<other>', - size: [331776, 139264], - count: [1, 143], - averageSize: [331776 / 1, 139264 / 143], - defined: [true, true] - }, - { - dimension: OBJECT_TYPE, - title: 'blink::Node', - size: [undefined, 819200], - count: [undefined, 4], - averageSize: [undefined, 819200 / 4], - defined: [false, true] - } - ] - }, - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [204800, 204800], - count: [25, 313], - averageSize: [204800 / 25, 204800 / 313], - defined: [true, true], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [undefined, 204800], - count: [undefined, 313], - averageSize: [undefined, 204800 / 313], - defined: [false, true] - }, - { - dimension: OBJECT_TYPE, - title: 'v8::Context', - size: [153600, 122880], - count: [15, 270], - averageSize: [153600 / 15, 122880 / 270], - defined: [true, true] - }, - { - dimension: OBJECT_TYPE, - title: '<other>', - size: [51200, 81920], - count: [10, 43], - averageSize: [51200 / 10, 81920 / 43], - defined: [true, true] - } - ] - }, - { - dimension: STACK_FRAME, - title: '<other>', - size: [51200, undefined], - count: [143, undefined], - averageSize: [51200 / 143, undefined], - defined: [true, false] - }, - { - dimension: OBJECT_TYPE, - title: 'blink::Node', - size: [331776, 819200], - count: [10, 4], - averageSize: [331776 / 10, 819200 / 4], - defined: [true, true], - children: [ - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [undefined, 819200], - count: [undefined, 4], - averageSize: [undefined, 819200 / 4], - defined: [false, true] - } - ] - }, - { - dimension: OBJECT_TYPE, - title: 'v8::Context', - size: [1024000, 1024000], - count: [176, 500], - averageSize: [1024000 / 176, 1024000 / 500], - defined: [true, true], - children: [ - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [716800, 614400], - count: [100, 123], - averageSize: [716800 / 100, 614400 / 123], - defined: [true, true] - }, - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [153600, 122880], - count: [15, 270], - averageSize: [153600 / 15, 122880 / 270], - defined: [true, true] - }, - { - dimension: STACK_FRAME, - title: '<other>', - size: [153600, 286720], - count: [61, 107], - averageSize: [153600 / 61, 286720 / 107], - defined: [true, true] - } - ] - }, - { - dimension: OBJECT_TYPE, - title: '<other>', - size: [51200, 327680], - count: [113, 96], - averageSize: [51200 / 113, 327680 / 96], - defined: [true, true] - } - ] - }, - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [2404352, 2621440], - count: [399, 199], - averageSize: [2404352 / 399, 2621440 / 199], - defined: [true, true], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [2404352, 2621440], - count: [399, 199], - averageSize: [2404352 / 399, 2621440 / 199], - defined: [true, true], - children: [ - { - dimension: STACK_FRAME, - title: '<self>', - size: [307200, undefined], - count: [300, undefined], - averageSize: [307200 / 300, undefined], - defined: [true, false], - children: [ - { - dimension: OBJECT_TYPE, - title: 'v8::Context', - size: [15360, undefined], - count: [5, undefined], - averageSize: [15360 / 5, undefined], - defined: [true, false] - }, - { - dimension: OBJECT_TYPE, - title: '<other>', - size: [291840, undefined], - count: [295, undefined], - averageSize: [291840 / 295, undefined], - defined: [true, false] - } - ] - }, - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [2097152, 2516582], - count: [99, 158], - averageSize: [2097152 / 99, 2516582 / 158], - defined: [true, true], - children: [ - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [2097152, undefined], - count: [99, undefined], - averageSize: [2097152 / 99, undefined], - defined: [true, false] - } - ] - }, - { - dimension: STACK_FRAME, - title: '<other>', - size: [undefined, 104858], - count: [undefined, 41], - averageSize: [undefined, 104858 / 41], - defined: [false, true] - }, - { - dimension: OBJECT_TYPE, - title: 'v8::Context', - size: [20480, 20480], - count: [6, 4], - averageSize: [20480 / 6, 20480 / 4], - defined: [true, true], - children: [ - { - dimension: STACK_FRAME, - title: '<self>', - size: [15360, undefined], - count: [5, undefined], - averageSize: [15360 / 5, undefined], - defined: [true, false] - }, - { - dimension: STACK_FRAME, - title: '<other>', - size: [5120, undefined], - count: [1, undefined], - averageSize: [5120 / 1, undefined], - defined: [true, false] - } - ] - }, - { - dimension: OBJECT_TYPE, - title: '<other>', - size: [2383872, 2474598], - count: [393, 139], - averageSize: [2383872 / 393, 2474598 / 139], - defined: [true, true] - }, - { - dimension: OBJECT_TYPE, - title: 'WTF::StringImpl', - size: [undefined, 126362], - count: [undefined, 56], - averageSize: [undefined, 126362 / 56], - defined: [false, true] - } - ] - } - ] - }, - { - dimension: STACK_FRAME, - title: '<other>', - size: [382976, 31129], - count: [302, 85], - averageSize: [382976 / 302, 31129 / 85], - defined: [true, true] - }, - { - dimension: OBJECT_TYPE, - title: 'v8::Context', - size: [1048576, 1127219], - count: [200, 504], - averageSize: [1048576 / 200, 1127219 / 504], - defined: [true, true], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [1024000, 1024000], - count: [176, 500], - averageSize: [1024000 / 176, 1024000 / 500], - defined: [true, true], - children: [ - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [716800, 614400], - count: [100, 123], - averageSize: [716800 / 100, 614400 / 123], - defined: [true, true] - }, - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [153600, 122880], - count: [15, 270], - averageSize: [153600 / 15, 122880 / 270], - defined: [true, true] - }, - { - dimension: STACK_FRAME, - title: '<other>', - size: [153600, 286720], - count: [61, 107], - averageSize: [153600 / 61, 286720 / 107], - defined: [true, true] - } - ] - }, - { - dimension: STACK_FRAME, - title: '<other>', - size: [24576, 103219], - count: [24, 4], - averageSize: [24576 / 24, 103219 / 4], - defined: [true, true] - } - ] - }, - { - dimension: OBJECT_TYPE, - title: '<other>', - size: [3145728, 3696230], - count: [800, 380], - averageSize: [3145728 / 800, 3696230 / 380], - defined: [true, true] - } - ] - }, - { - dimension: STACK_FRAME, - title: '<self>', - size: [undefined, 131072], - count: [undefined, 16], - averageSize: [undefined, 131072 / 16], - defined: [false, true], - children: [ - { - dimension: OBJECT_TYPE, - title: 'v8::Context', - size: [undefined, 131072], - count: [undefined, 16], - averageSize: [undefined, 131072 / 16], - defined: [false, true] - } - ] - }, - { - dimension: OBJECT_TYPE, - title: 'v8::Context', - size: [1048576, 1258291], - count: [200, 520], - averageSize: [1048576 / 200, 1258291 / 520], - defined: [true, true], - children: [ - { - dimension: STACK_FRAME, - title: 'MessageLoop::RunTask', - size: [1048576, 1127219], - count: [200, 504], - averageSize: [1048576 / 200, 1127219 / 504], - defined: [true, true], - children: [ - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [1024000, 1024000], - count: [176, 500], - averageSize: [1024000 / 176, 1024000 / 500], - defined: [true, true], - children: [ - { - dimension: STACK_FRAME, - title: 'V8.Execute', - size: [716800, 614400], - count: [100, 123], - averageSize: [716800 / 100, 614400 / 123], - defined: [true, true] - }, - { - dimension: STACK_FRAME, - title: 'FunctionCall', - size: [153600, 122880], - count: [15, 270], - averageSize: [153600 / 15, 122880 / 270], - defined: [true, true] - }, - { - dimension: STACK_FRAME, - title: '<other>', - size: [153600, 286720], - count: [61, 107], - averageSize: [153600 / 61, 286720 / 107], - defined: [true, true] - } - ] - }, - { - dimension: STACK_FRAME, - title: '<other>', - size: [24576, 103219], - count: [24, 4], - averageSize: [24576 / 24, 103219 / 4], - defined: [true, true] - } - ] - }, - { - dimension: STACK_FRAME, - title: '<self>', - size: [undefined, 131072], - count: [undefined, 16], - averageSize: [undefined, 131072 / 16], - defined: [false, true] - } - ] - }, - { - dimension: OBJECT_TYPE, - title: 'blink::Node', - size: [331776, 1048576], - count: [10, 5], - averageSize: [331776 / 10, 1048576 / 5], - defined: [true, true] - }, - { - dimension: OBJECT_TYPE, - title: '<other>', - size: [2813952, 2647654], - count: [790, 375], - averageSize: [2813952 / 790, 2647654 / 375], - defined: [true, true] - } - ] - } - ]); - }); - - test('instantiate_multipleMax', function() { - var heapDumps = createHeapDumps(false); - - var viewEl = tr.ui.analysis.createTestPane( - 'tr-ui-a-memory-dump-heap-details-pane'); - viewEl.heapDumps = heapDumps; - viewEl.aggregationMode = AggregationMode.MAX; - viewEl.rebuild(); - this.addHTMLOutput(viewEl); - - changeView(viewEl, TOP_DOWN_HEAVY_VIEW); - checkTable(viewEl, - { - expectedAggregationMode: AggregationMode.MAX, - expectedInfoBarDisplayed: true - }, - [ - { - dimension: ROOT, - title: 'partition_alloc', - size: [4194304, 4954521], - defined: [true, true], - children: 9 // No need to check the full structure again. - } - ]); - }); - - test('instantiate_multipleWithUndefined', function() { - var heapDumps = createHeapDumps(false); - heapDumps.splice(1, 0, undefined); - - var viewEl = tr.ui.analysis.createTestPane( - 'tr-ui-a-memory-dump-heap-details-pane'); - viewEl.heapDumps = heapDumps; - viewEl.aggregationMode = AggregationMode.DIFF; - viewEl.rebuild(); - this.addHTMLOutput(viewEl); - - // Top-down tree view (default). - checkTable(viewEl, - { expectedAggregationMode: AggregationMode.DIFF }, - [ - { - dimension: ROOT, - title: 'partition_alloc', - size: [4194304, undefined, 4954521], - defined: [true, false, true], - children: 5 // No need to check the full structure again. - } - ]); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/memory_dump_overview_pane.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/memory_dump_overview_pane.html deleted file mode 100644 index 9f2152d1106..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/memory_dump_overview_pane.html +++ /dev/null @@ -1,757 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/color_scheme.html"> -<link rel="import" href="/tracing/base/iteration_helpers.html"> -<link rel="import" href="/tracing/model/memory_allocator_dump.html"> -<link rel="import" - href="/tracing/ui/analysis/memory_dump_allocator_details_pane.html"> -<link rel="import" href="/tracing/ui/analysis/memory_dump_sub_view_util.html"> -<link rel="import" - href="/tracing/ui/analysis/memory_dump_vm_regions_details_pane.html"> -<link rel="import" href="/tracing/ui/analysis/stacked_pane.html"> -<link rel="import" href="/tracing/ui/base/color_legend.html"> -<link rel="import" href="/tracing/ui/base/dom_helpers.html"> -<link rel="import" href="/tracing/ui/base/table.html"> -<link rel="import" href="/tracing/ui/view_specific_brushing_state.html"> -<link rel="import" href="/tracing/value/numeric.html"> -<link rel="import" href="/tracing/value/unit.html"> -<link rel="import" href="/tracing/value/unit_scale.html"> - -<polymer-element name="tr-ui-a-memory-dump-overview-pane" - extends="tr-ui-a-stacked-pane"> - <template> - <style> - :host { - display: flex; - flex-direction: column; - } - - #label { - flex: 0 0 auto; - padding: 8px; - - background-color: #eee; - border-bottom: 1px solid #8e8e8e; - border-top: 1px solid white; - - font-size: 15px; - font-weight: bold; - } - - #contents { - flex: 1 0 auto; - align-self: stretch; - font-size: 12px; - } - - #info_text { - padding: 8px; - color: #666; - font-style: italic; - text-align: center; - } - - #table { - display: none; /* Hide until memory dumps are set. */ - flex: 1 0 auto; - align-self: stretch; - } - </style> - <tr-ui-b-view-specific-brushing-state id="state" - view-id="analysis.memory_dump_overview_pane"> - </tr-ui-b-view-specific-brushing-state> - <div id="label">Overview</div> - <div id="contents"> - <div id="info_text">No memory memory dumps selected</div> - <tr-ui-b-table id="table"></tr-ui-b-table> - </div> - </template> -</polymer-element> -<script> -'use strict'; - -tr.exportTo('tr.ui.analysis', function() { - - var ColorScheme = tr.b.ColorScheme; - var ScalarNumeric = tr.v.ScalarNumeric; - var sizeInBytes_smallerIsBetter = - tr.v.Unit.byName.sizeInBytes_smallerIsBetter; - - var PLATFORM_SPECIFIC_TOTAL_NAME_SUFFIX = '_bytes'; - - var DISPLAYED_SIZE_NUMERIC_NAME = - tr.model.MemoryAllocatorDump.DISPLAYED_SIZE_NUMERIC_NAME; - var SOME_TIMESTAMPS_INFO_QUANTIFIER = - tr.ui.analysis.MemoryColumn.SOME_TIMESTAMPS_INFO_QUANTIFIER; - - // Unicode symbols used for memory cell info icons and messages. - var RIGHTWARDS_ARROW_WITH_HOOK = String.fromCharCode(0x21AA); - var RIGHTWARDS_ARROW_FROM_BAR = String.fromCharCode(0x21A6); - var GREATER_THAN_OR_EQUAL_TO = String.fromCharCode(0x2265); - var UNMARRIED_PARTNERSHIP_SYMBOL = String.fromCharCode(0x26AF); - var TRIGRAM_FOR_HEAVEN = String.fromCharCode(0x2630); - - // TODO(petrcermak): Move this to iteration_helpers.html. - function lazyMap(list, fn, opt_this) { - opt_this = opt_this || this; - var result = undefined; - list.forEach(function(item, index) { - var value = fn.call(opt_this, item, index); - if (value === undefined) - return; - if (result === undefined) - result = new Array(list.length); - result[index] = value; - }); - return result; - } - - /** @constructor */ - function ProcessNameColumn() { - tr.ui.analysis.TitleColumn.call(this, 'Process'); - } - - ProcessNameColumn.prototype = { - __proto__: tr.ui.analysis.TitleColumn.prototype, - - formatTitle: function(row) { - if (row.contexts === undefined) - return row.title; // Total row. - var titleEl = document.createElement('tr-ui-b-color-legend'); - titleEl.label = row.title; - return titleEl; - } - }; - - /** @constructor */ - function UsedMemoryColumn(name, cellPath, aggregationMode) { - tr.ui.analysis.NumericMemoryColumn.call( - this, name, cellPath, aggregationMode); - } - - UsedMemoryColumn.COLOR = - ColorScheme.getColorForReservedNameAsString('used_memory_column'); - UsedMemoryColumn.OLDER_COLOR = - ColorScheme.getColorForReservedNameAsString('older_used_memory_column'); - - UsedMemoryColumn.prototype = { - __proto__: tr.ui.analysis.NumericMemoryColumn.prototype, - - get title() { - return tr.ui.b.createSpan({ - textContent: this.name, - color: UsedMemoryColumn.COLOR - }); - }, - - getFormattingContext: function(unit) { - return { unitPrefix: tr.v.UnitScale.Binary.MEBI }; - }, - - color: function(numerics, processMemoryDumps) { - return UsedMemoryColumn.COLOR; - }, - - getChildPaneBuilder: function(processMemoryDumps) { - if (processMemoryDumps === undefined) - return undefined; - - var vmRegions = lazyMap(processMemoryDumps, function(pmd) { - if (pmd === undefined) - return undefined; - return pmd.mostRecentVmRegions; - }); - if (vmRegions === undefined) - return undefined; - - return function() { - var pane = document.createElement( - 'tr-ui-a-memory-dump-vm-regions-details-pane'); - pane.vmRegions = vmRegions; - pane.aggregationMode = this.aggregationMode; - return pane; - }.bind(this); - } - }; - - /** @constructor */ - function PeakMemoryColumn(name, cellPath, aggregationMode) { - UsedMemoryColumn.call(this, name, cellPath, aggregationMode); - } - - PeakMemoryColumn.prototype = { - __proto__: UsedMemoryColumn.prototype, - - addInfos: function(numerics, processMemoryDumps, infos) { - if (processMemoryDumps === undefined) - return; // Total row. - - var resettableValueCount = 0; - var nonResettableValueCount = 0; - for (var i = 0; i < numerics.length; i++) { - if (numerics[i] === undefined) - continue; - if (processMemoryDumps[i].arePeakResidentBytesResettable) - resettableValueCount++; - else - nonResettableValueCount++; - } - - if (resettableValueCount > 0 && nonResettableValueCount > 0) { - infos.push(tr.ui.analysis.createWarningInfo('Both resettable and ' + - 'non-resettable peak RSS values were provided by the process')); - } else if (resettableValueCount > 0) { - infos.push({ - icon: RIGHTWARDS_ARROW_WITH_HOOK, - message: 'Peak RSS since previous memory dump.' - }); - } else { - infos.push({ - icon: RIGHTWARDS_ARROW_FROM_BAR, - message: 'Peak RSS since process startup. Finer grained ' + - 'peaks require a Linux kernel version ' + - GREATER_THAN_OR_EQUAL_TO + ' 4.0.' - }); - } - } - }; - - /** @constructor */ - function ByteStatColumn(name, cellPath, aggregationMode) { - UsedMemoryColumn.call(this, name, cellPath, aggregationMode); - } - - ByteStatColumn.prototype = { - __proto__: UsedMemoryColumn.prototype, - - color: function(numerics, processMemoryDumps) { - if (processMemoryDumps === undefined) - return UsedMemoryColumn.COLOR; // Total row. - - var allOlderValues = processMemoryDumps.every( - function(processMemoryDump) { - if (processMemoryDump === undefined) - return true; - return !processMemoryDump.hasOwnVmRegions; - }); - - // Show the cell in lighter blue if all values were older (i.e. none of - // the defined process memory dumps had own VM regions). - if (allOlderValues) - return UsedMemoryColumn.OLDER_COLOR; - else - return UsedMemoryColumn.COLOR; - }, - - addInfos: function(numerics, processMemoryDumps, infos) { - if (processMemoryDumps === undefined) - return; // Total row. - - var olderValueCount = 0; - for (var i = 0; i < numerics.length; i++) { - var processMemoryDump = processMemoryDumps[i]; - if (processMemoryDump !== undefined && - !processMemoryDump.hasOwnVmRegions) { - olderValueCount++; - } - } - - if (olderValueCount === 0) - return; // There are no older values. - - var infoQuantifier = olderValueCount < numerics.length ? - ' ' + SOME_TIMESTAMPS_INFO_QUANTIFIER /* some values are older */ : - '' /* all values are older */; - - // Emit an info if there was at least one older value (i.e. at least one - // defined process memory dump did not have own VM regions). - infos.push({ - message: 'Older value' + infoQuantifier + - ' (only heavy (purple) memory dumps contain memory maps).', - icon: UNMARRIED_PARTNERSHIP_SYMBOL - }); - } - }; - - // Rules for constructing and sorting used memory columns. - UsedMemoryColumn.RULES = [ - { - condition: 'Total resident', - importance: 10, - columnConstructor: UsedMemoryColumn - }, - { - condition: 'Peak total resident', - importance: 9, - columnConstructor: PeakMemoryColumn - }, - { - condition: 'PSS', - importance: 8, - columnConstructor: ByteStatColumn - }, - { - condition: 'Private dirty', - importance: 7, - columnConstructor: ByteStatColumn - }, - { - condition: 'Swapped', - importance: 6, - columnConstructor: ByteStatColumn - }, - { - // All other columns. - importance: 0, - columnConstructor: UsedMemoryColumn - } - ]; - - // Map from ProcessMemoryDump totals fields to column names. - UsedMemoryColumn.TOTALS_MAP = { - 'residentBytes': 'Total resident', - 'peakResidentBytes': 'Peak total resident' - }; - - // Map from VMRegionByteStats field names to column names. - UsedMemoryColumn.BYTE_STAT_MAP = { - 'proportionalResident': 'PSS', - 'privateDirtyResident': 'Private dirty', - 'swapped': 'Swapped' - }; - - /** @constructor */ - function AllocatorColumn(name, cellPath, aggregationMode) { - tr.ui.analysis.NumericMemoryColumn.call( - this, name, cellPath, aggregationMode); - } - - AllocatorColumn.prototype = { - __proto__: tr.ui.analysis.NumericMemoryColumn.prototype, - - get title() { - var titleEl = document.createElement('tr-ui-b-color-legend'); - titleEl.label = this.name; - return titleEl; - }, - - getFormattingContext: function(unit) { - return { unitPrefix: tr.v.UnitScale.Binary.MEBI }; - }, - - addInfos: function(numerics, processMemoryDumps, infos) { - if (processMemoryDumps === undefined) - return; - - var heapDumpCount = 0; - var missingSizeCount = 0; - - for (var i = 0; i < processMemoryDumps.length; i++) { - var processMemoryDump = processMemoryDumps[i]; - if (processMemoryDump === undefined) - continue; - - var heapDumps = processMemoryDump.heapDumps; - if (heapDumps !== undefined && heapDumps[this.name] !== undefined) - heapDumpCount++; - var allocatorDump = - processMemoryDump.getMemoryAllocatorDumpByFullName(this.name); - - if (allocatorDump !== undefined && - allocatorDump.numerics[DISPLAYED_SIZE_NUMERIC_NAME] === undefined) { - missingSizeCount++; - } - } - - // Emit a heap dump info if at least one of the process memory dumps has - // a heap dump associated with this allocator. - if (heapDumpCount > 0) { - var infoQuantifier = heapDumpCount < numerics.length ? - ' ' + SOME_TIMESTAMPS_INFO_QUANTIFIER : ''; - infos.push({ - message: 'Heap dump provided' + infoQuantifier + '.', - icon: TRIGRAM_FOR_HEAVEN - }); - } - - // Emit a warning if this allocator did not provide size in at least one - // of the process memory dumps. - if (missingSizeCount > 0) { - var infoQuantifier = missingSizeCount < numerics.length ? - ' ' + SOME_TIMESTAMPS_INFO_QUANTIFIER : ''; - infos.push(tr.ui.analysis.createWarningInfo( - 'Size was not provided' + infoQuantifier + '.')); - } - }, - - getChildPaneBuilder: function(processMemoryDumps) { - if (processMemoryDumps === undefined) - return undefined; - - var memoryAllocatorDumps = lazyMap(processMemoryDumps, function(pmd) { - if (pmd === undefined) - return undefined; - return pmd.getMemoryAllocatorDumpByFullName(this.name); - }, this); - if (memoryAllocatorDumps === undefined) - return undefined; - - var heapDumps = lazyMap(processMemoryDumps, function(pmd) { - if (pmd === undefined || pmd.heapDumps === undefined) - return undefined; - return pmd.heapDumps[this.name]; - }, this); - - return function() { - var pane = document.createElement( - 'tr-ui-a-memory-dump-allocator-details-pane'); - pane.memoryAllocatorDumps = memoryAllocatorDumps; - pane.heapDumps = heapDumps; - pane.aggregationMode = this.aggregationMode; - return pane; - }.bind(this); - } - }; - - /** @constructor */ - function TracingColumn(name, cellPath, aggregationMode) { - AllocatorColumn.call(this, name, cellPath, aggregationMode); - } - - TracingColumn.COLOR = - ColorScheme.getColorForReservedNameAsString('tracing_memory_column'); - - TracingColumn.prototype = { - __proto__: AllocatorColumn.prototype, - - get title() { - return tr.ui.b.createSpan({ - textContent: this.name, - color: TracingColumn.COLOR - }); - }, - - color: function(numerics, processMemoryDumps) { - return TracingColumn.COLOR; - } - }; - - // Rules for constructing and sorting allocator columns. - AllocatorColumn.RULES = [ - { - condition: 'tracing', - importance: 0, - columnConstructor: TracingColumn - }, - { - // All other columns. - importance: 1, - columnConstructor: AllocatorColumn - } - ]; - - Polymer('tr-ui-a-memory-dump-overview-pane', { - created: function() { - this.processMemoryDumps_ = undefined; - this.aggregationMode_ = undefined; - }, - - ready: function() { - this.$.table.selectionMode = tr.ui.b.TableFormat.SelectionMode.CELL; - this.$.table.addEventListener('selection-changed', - function(tableEvent) { - tableEvent.stopPropagation(); - this.changeChildPane_(); - }.bind(this)); - }, - - /** - * Sets the process memory dumps and schedules rebuilding the pane. - * - * The provided value should be a chronological list of dictionaries - * mapping process IDs to process memory dumps. Example: - * - * [ - * { - * // PMDs at timestamp 1. - * 42: tr.model.ProcessMemoryDump {} - * }, - * { - * // PMDs at timestamp 2. - * 42: tr.model.ProcessMemoryDump {}, - * 89: tr.model.ProcessMemoryDump {} - * } - * ] - */ - set processMemoryDumps(processMemoryDumps) { - this.processMemoryDumps_ = processMemoryDumps; - this.scheduleRebuildPane_(); - }, - - get processMemoryDumps() { - return this.processMemoryDumps_; - }, - - set aggregationMode(aggregationMode) { - this.aggregationMode_ = aggregationMode; - this.scheduleRebuildPane_(); - }, - - get aggregationMode() { - return this.aggregationMode_; - }, - - get selectedMemoryCell() { - if (this.processMemoryDumps_ === undefined || - this.processMemoryDumps_.length === 0) { - return undefined; - } - - var selectedTableRow = this.$.table.selectedTableRow; - if (!selectedTableRow) - return undefined; - - var selectedColumnIndex = this.$.table.selectedColumnIndex; - if (selectedColumnIndex === undefined) - return undefined; - - var selectedColumn = this.$.table.tableColumns[selectedColumnIndex]; - var selectedMemoryCell = selectedColumn.cell(selectedTableRow); - return selectedMemoryCell; - }, - - changeChildPane_: function() { - this.storeSelection_(); - this.childPaneBuilder = this.determineChildPaneBuilderFromSelection_(); - }, - - determineChildPaneBuilderFromSelection_: function() { - if (this.processMemoryDumps_ === undefined || - this.processMemoryDumps_.length === 0) { - return undefined; - } - - var selectedTableRow = this.$.table.selectedTableRow; - if (!selectedTableRow) - return undefined; - - var selectedColumnIndex = this.$.table.selectedColumnIndex; - if (selectedColumnIndex === undefined) - return undefined; - var selectedColumn = this.$.table.tableColumns[selectedColumnIndex]; - - return selectedColumn.getChildPaneBuilder(selectedTableRow.contexts); - }, - - rebuildPane_: function() { - if (this.processMemoryDumps_ === undefined || - this.processMemoryDumps_.length === 0) { - // Show the info text (hide the table). - this.$.info_text.style.display = 'block'; - this.$.table.style.display = 'none'; - - this.$.table.clear(); - this.$.table.rebuild(); - return; - } - - // Show the table (hide the info text). - this.$.info_text.style.display = 'none'; - this.$.table.style.display = 'block'; - - var rows = this.createRows_(); - var columns = this.createColumns_(rows); - var footerRows = this.createFooterRows_(rows, columns); - - this.$.table.tableRows = rows; - this.$.table.footerRows = footerRows; - this.$.table.tableColumns = columns; - this.$.table.rebuild(); - - this.restoreSelection_(); - }, - - createRows_: function() { - // Timestamp (list index) -> Process ID (dict key) -> PMD. - var timeToPidToProcessMemoryDump = this.processMemoryDumps_; - - // Process ID (dict key) -> Timestamp (list index) -> PMD or undefined. - var pidToTimeToProcessMemoryDump = tr.b.invertArrayOfDicts( - timeToPidToProcessMemoryDump); - - // Process (list index) -> Component (dict key) -> Cell. - return tr.b.dictionaryValues(tr.b.mapItems( - pidToTimeToProcessMemoryDump, function(pid, timeToDump) { - // Get the process associated with the dumps. We can use any defined - // process memory dump in timeToDump since they all have the same pid. - var process = tr.b.findFirstInArray(timeToDump).process; - - // Used memory (total resident, PSS, ...). - var usedMemoryCells = tr.ui.analysis.createCells(timeToDump, - function(dump) { - var sizes = {}; - - var totals = dump.totals; - if (totals !== undefined) { - // Common totals. - tr.b.iterItems(UsedMemoryColumn.TOTALS_MAP, - function(totalName, cellName) { - var total = totals[totalName]; - if (total === undefined) - return; - sizes[cellName] = new ScalarNumeric( - sizeInBytes_smallerIsBetter, total); - }); - - // Platform-specific totals (e.g. private resident on Mac). - var platformSpecific = totals.platformSpecific; - if (platformSpecific !== undefined) { - tr.b.iterItems(platformSpecific, function(name, size) { - // Change raw OS-specific total name to a user-friendly - // column title (e.g. 'private_bytes' -> 'Private'). - if (name.endsWith(PLATFORM_SPECIFIC_TOTAL_NAME_SUFFIX)) { - name = name.substring(0, name.length - - PLATFORM_SPECIFIC_TOTAL_NAME_SUFFIX.length); - } - name = name.replace('_', ' ').trim(); - name = name.charAt(0).toUpperCase() + name.slice(1); - sizes[name] = new ScalarNumeric( - sizeInBytes_smallerIsBetter, size); - }); - } - } - - // VM regions byte stats. - var vmRegions = dump.mostRecentVmRegions; - if (vmRegions !== undefined) { - tr.b.iterItems(UsedMemoryColumn.BYTE_STAT_MAP, - function(byteStatName, cellName) { - var byteStat = vmRegions.byteStats[byteStatName]; - if (byteStat === undefined) - return; - sizes[cellName] = new ScalarNumeric( - sizeInBytes_smallerIsBetter, byteStat); - }); - } - - return sizes; - }); - - // Allocator memory (v8, oilpan, ...). - var allocatorCells = tr.ui.analysis.createCells(timeToDump, - function(dump) { - var memoryAllocatorDumps = dump.memoryAllocatorDumps; - if (memoryAllocatorDumps === undefined) - return undefined; - var sizes = {}; - memoryAllocatorDumps.forEach(function(allocatorDump) { - var rootDisplayedSizeNumeric = allocatorDump.numerics[ - DISPLAYED_SIZE_NUMERIC_NAME]; - if (rootDisplayedSizeNumeric === undefined) { - rootDisplayedSizeNumeric = - new ScalarNumeric(sizeInBytes_smallerIsBetter, 0); - } - sizes[allocatorDump.fullName] = rootDisplayedSizeNumeric; - }); - return sizes; - }); - - return { - title: process.userFriendlyName, - contexts: timeToDump, - usedMemoryCells: usedMemoryCells, - allocatorCells: allocatorCells - }; - })); - }, - - createFooterRows_: function(rows, columns) { - // Add a 'Total' row if there are at least two process memory dumps. - if (rows.length <= 1) - return []; - - var totalRow = {title: 'Total'}; - tr.ui.analysis.aggregateTableRowCells(totalRow, rows, columns); - - return [totalRow]; - }, - - createColumns_: function(rows) { - var titleColumn = new ProcessNameColumn(); - titleColumn.width = '200px'; - - var usedMemorySizeColumns = tr.ui.analysis.MemoryColumn.fromRows( - rows, 'usedMemoryCells', this.aggregationMode_, - UsedMemoryColumn.RULES); - - var allocatorSizeColumns = tr.ui.analysis.MemoryColumn.fromRows( - rows, 'allocatorCells', this.aggregationMode_, - AllocatorColumn.RULES); - - var sizeColumns = usedMemorySizeColumns.concat(allocatorSizeColumns); - tr.ui.analysis.MemoryColumn.spaceEqually(sizeColumns); - - var columns = [titleColumn].concat(sizeColumns); - return columns; - }, - - storeSelection_: function() { - var selectedRowTitle; - var selectedRow = this.$.table.selectedTableRow; - if (selectedRow !== undefined) - selectedRowTitle = selectedRow.title; - - var selectedColumnName; - var selectedColumnIndex = this.$.table.selectedColumnIndex; - if (selectedColumnIndex !== undefined) { - var selectedColumn = this.$.table.tableColumns[selectedColumnIndex]; - selectedColumnName = selectedColumn.name; - } - - this.$.state.set( - {rowTitle: selectedRowTitle, columnName: selectedColumnName}); - }, - - restoreSelection_: function() { - var settings = this.$.state.get(); - if (settings === undefined || settings.rowTitle === undefined || - settings.columnName === undefined) - return; - - var selectedColumnName = settings.columnName; - var selectedColumnIndex = tr.b.findFirstIndexInArray( - this.$.table.tableColumns, function(column) { - return column.name === selectedColumnName; - }); - if (selectedColumnIndex < 0) - return; - - var selectedRowTitle = settings.rowTitle; - var selectedRow = tr.b.findFirstInArray(this.$.table.tableRows, - function(row) { - return row.title === selectedRowTitle; - }); - if (selectedRow === undefined) - return; - - this.$.table.selectedTableRow = selectedRow; - this.$.table.selectedColumnIndex = selectedColumnIndex; - } - }); - - return { - // All exports are for testing only. - ProcessNameColumn: ProcessNameColumn, - UsedMemoryColumn: UsedMemoryColumn, - PeakMemoryColumn: PeakMemoryColumn, - ByteStatColumn: ByteStatColumn, - AllocatorColumn: AllocatorColumn, - TracingColumn: TracingColumn - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/memory_dump_overview_pane_test.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/memory_dump_overview_pane_test.html deleted file mode 100644 index bb377bba241..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/memory_dump_overview_pane_test.html +++ /dev/null @@ -1,812 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/iteration_helpers.html"> -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/heap_dump.html"> -<link rel="import" href="/tracing/model/memory_allocator_dump.html"> -<link rel="import" href="/tracing/model/memory_dump_test_utils.html"> -<link rel="import" href="/tracing/ui/analysis/memory_dump_overview_pane.html"> -<link rel="import" - href="/tracing/ui/analysis/memory_dump_sub_view_test_utils.html"> -<link rel="import" href="/tracing/ui/analysis/memory_dump_sub_view_util.html"> -<link rel="import" href="/tracing/ui/brushing_state_controller.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var ScalarNumeric = tr.v.ScalarNumeric; - var sizeInBytes_smallerIsBetter = - tr.v.Unit.byName.sizeInBytes_smallerIsBetter; - var MemoryAllocatorDump = tr.model.MemoryAllocatorDump; - var HeapDump = tr.model.HeapDump; - var AggregationMode = tr.ui.analysis.MemoryColumn.AggregationMode; - var checkSizeNumericFields = tr.ui.analysis.checkSizeNumericFields; - var checkColor = tr.ui.analysis.checkColor; - var checkColumns = tr.ui.analysis.checkColumns; - var checkColumnInfosAndColor = tr.ui.analysis.checkColumnInfosAndColor; - var convertToProcessMemoryDumps = tr.ui.analysis.convertToProcessMemoryDumps; - var extractProcessMemoryDumps = tr.ui.analysis.extractProcessMemoryDumps; - var extractVmRegions = tr.ui.analysis.extractVmRegions; - var extractMemoryAllocatorDumps = tr.ui.analysis.extractMemoryAllocatorDumps; - var isElementDisplayed = tr.ui.analysis.isElementDisplayed; - var addProcessMemoryDump = tr.model.MemoryDumpTestUtils.addProcessMemoryDump; - var addGlobalMemoryDump = tr.model.MemoryDumpTestUtils.addGlobalMemoryDump; - var ProcessNameColumn = tr.ui.analysis.ProcessNameColumn; - var UsedMemoryColumn = tr.ui.analysis.UsedMemoryColumn; - var PeakMemoryColumn = tr.ui.analysis.PeakMemoryColumn; - var ByteStatColumn = tr.ui.analysis.ByteStatColumn; - var AllocatorColumn = tr.ui.analysis.AllocatorColumn; - var TracingColumn = tr.ui.analysis.TracingColumn; - - function spanMatcher(expectedTitle) { - return function(actualTitle) { - assert.instanceOf(actualTitle, HTMLElement); - assert.strictEqual(actualTitle.tagName, 'SPAN'); - assert.strictEqual(actualTitle.textContent, expectedTitle); - }; - } - - function colorLegendMatcher(expectedTitle) { - return function(actualTitle) { - assert.instanceOf(actualTitle, HTMLElement); - assert.strictEqual(actualTitle.tagName, 'TR-UI-B-COLOR-LEGEND'); - assert.strictEqual(actualTitle.label, expectedTitle); - }; - } - - var EXPECTED_COLUMNS = [ - { title: 'Process', type: ProcessNameColumn, noAggregation: true }, - { title: spanMatcher('Total resident'), type: UsedMemoryColumn }, - { title: spanMatcher('Peak total resident'), type: PeakMemoryColumn }, - { title: spanMatcher('PSS'), type: ByteStatColumn }, - { title: spanMatcher('Private dirty'), type: ByteStatColumn }, - { title: spanMatcher('Swapped'), type: ByteStatColumn }, - { title: spanMatcher('Private'), type: UsedMemoryColumn }, - { title: colorLegendMatcher('blink'), type: AllocatorColumn }, - { title: colorLegendMatcher('gpu'), type: AllocatorColumn }, - { title: colorLegendMatcher('malloc'), type: AllocatorColumn }, - { title: colorLegendMatcher('oilpan'), type: AllocatorColumn }, - { title: colorLegendMatcher('v8'), type: AllocatorColumn }, - { title: spanMatcher('tracing'), type: TracingColumn } - ]; - - function checkRow(columns, row, expectedTitle, expectedSizes, - expectedContexts) { - // Check title. - var formattedTitle = columns[0].formatTitle(row); - if (typeof expectedTitle === 'function') - expectedTitle(formattedTitle); - else - assert.strictEqual(formattedTitle, expectedTitle); - - // Check all sizes. The first assert below is a test sanity check. - assert.lengthOf(expectedSizes, columns.length - 1 /* all except title */); - for (var i = 0; i < expectedSizes.length; i++) - checkSizeNumericFields(row, columns[i + 1], expectedSizes[i]); - - // There should be no row nesting on the overview pane. - assert.isUndefined(row.subRows); - - if (expectedContexts) - assert.deepEqual(tr.b.asArray(row.contexts), expectedContexts); - else - assert.isUndefined(row.contexts); - } - - function checkRows(columns, actualRows, expectedRows) { - if (expectedRows === undefined) { - assert.isUndefined(actualRows); - return; - } - assert.lengthOf(actualRows, expectedRows.length); - for (var i = 0; i < expectedRows.length; i++) { - var actualRow = actualRows[i]; - var expectedRow = expectedRows[i]; - checkRow(columns, actualRow, expectedRow.title, expectedRow.sizes, - expectedRow.contexts); - } - } - - function checkSpanWithColor(span, expectedText, expectedColorReservedName) { - assert.strictEqual(span.tagName, 'SPAN'); - assert.strictEqual(span.textContent, expectedText); - checkColor(span.style.color, expectedColorReservedName); - } - - function checkColorLegend(legend, expectedLabel) { - assert.strictEqual(legend.tagName, 'TR-UI-B-COLOR-LEGEND'); - assert.strictEqual(legend.label, expectedLabel); - } - - function createAndCheckMemoryDumpOverviewPane( - test, processMemoryDumps, expectedRows, expectedFooterRows, - aggregationMode) { - var viewEl = - tr.ui.analysis.createTestPane('tr-ui-a-memory-dump-overview-pane'); - viewEl.processMemoryDumps = processMemoryDumps; - viewEl.aggregationMode = aggregationMode; - viewEl.rebuild(); - test.addHTMLOutput(viewEl); - - // Check that the table is shown. - assert.isTrue(isElementDisplayed(viewEl.$.table)); - assert.isFalse(isElementDisplayed(viewEl.$.info_text)); - - assert.isUndefined(viewEl.createChildPane()); - - var table = viewEl.$.table; - var columns = table.tableColumns; - checkColumns(columns, EXPECTED_COLUMNS, aggregationMode); - var rows = table.tableRows; - - checkRows(columns, table.tableRows, expectedRows); - checkRows(columns, table.footerRows, expectedFooterRows); - } - - var FIELD = 1 << 0; - var DUMP = 1 << 1; - - function checkOverviewColumnInfosAndColor(column, fieldAndDumpMask, - dumpCreatedCallback, expectedInfos, expectedColorReservedName) { - var fields = fieldAndDumpMask.map(function(mask, index) { - return mask & FIELD ? - new ScalarNumeric(sizeInBytes_smallerIsBetter, 1024 + 32 * index) : - undefined; - }); - - var contexts; - if (dumpCreatedCallback === undefined) { - contexts = undefined; - } else { - tr.c.TestUtils.newModel(function(model) { - var process = model.getOrCreateProcess(1); - fieldAndDumpMask.forEach(function(mask, i) { - var timestamp = 10 + i; - var gmd = addGlobalMemoryDump(model, timestamp); - if (mask & DUMP) { - var pmd = addProcessMemoryDump(gmd, process, timestamp); - dumpCreatedCallback(pmd, mask); - } - }); - contexts = model.globalMemoryDumps.map(function(gmd) { - return gmd.processMemoryDumps[1]; - }); - }); - } - - checkColumnInfosAndColor( - column, fields, contexts, expectedInfos, expectedColorReservedName); - } - - test('instantiate_empty', function() { - tr.ui.analysis.createAndCheckEmptyPanes(this, - 'tr-ui-a-memory-dump-overview-pane', 'processMemoryDumps', - function(viewEl) { - // Check that the info text is shown. - assert.isTrue(isElementDisplayed(viewEl.$.info_text)); - assert.isFalse(isElementDisplayed(viewEl.$.table)); - }); - }); - - test('instantiate_singleGlobalMemoryDump', function() { - var processMemoryDumps = convertToProcessMemoryDumps( - [tr.ui.analysis.createSingleTestGlobalMemoryDump()]); - createAndCheckMemoryDumpOverviewPane(this, - processMemoryDumps, - [ // Table rows. - { - title: colorLegendMatcher('Process 1'), - sizes: [[29884416], undefined, [9437184], [5767168], undefined, - undefined, undefined, undefined, [7340032], undefined, - undefined, [2097152]], - contexts: extractProcessMemoryDumps(processMemoryDumps, 1) - }, - { - title: colorLegendMatcher('Process 2'), - sizes: [[17825792], [39845888], [18350080], [0], [32], [8912896], - [7340032], [0], [1048576], [1], [5242880], [1572864]], - contexts: extractProcessMemoryDumps(processMemoryDumps, 2) - }, - { - title: colorLegendMatcher('Process 4'), - sizes: [undefined, [17825792], undefined, undefined, undefined, - undefined, undefined, undefined, undefined, undefined, - undefined, undefined], - contexts: extractProcessMemoryDumps(processMemoryDumps, 4) - } - ], - [ // Footer rows. - { - title: 'Total', - sizes: [[47710208], [57671680], [27787264], [5767168], [32], - [8912896], [7340032], [0], [8388608], [1], [5242880], - [3670016]], - contexts: undefined - } - ], - undefined /* no aggregation */); - }); - - test('instantiate_multipleGlobalMemoryDumps', function() { - var processMemoryDumps = convertToProcessMemoryDumps( - tr.ui.analysis.createMultipleTestGlobalMemoryDumps()); - createAndCheckMemoryDumpOverviewPane(this, - processMemoryDumps, - [ // Table rows. - { - title: colorLegendMatcher('Process 1'), - sizes: [[31457280, 29884416, undefined], undefined, - [10485760, 9437184, undefined], [8388608, 5767168, undefined], - undefined, undefined, undefined, undefined, - [undefined, 7340032, undefined], undefined, undefined, - [undefined, 2097152, undefined]], - contexts: extractProcessMemoryDumps(processMemoryDumps, 1) - }, - { - title: colorLegendMatcher('Process 2'), - sizes: [[19398656, 17825792, 15728640], - [40370176, 39845888, 40894464], [18350080, 18350080, 18350080], - [0, 0, -2621440], [32, 32, 64], [10485760, 8912896, 7340032], - [undefined, 7340032, 6291456], [undefined, 0, 1048576], - [2097152, 1048576, 786432], [undefined, 1, undefined], - [5242880, 5242880, 5767168], [1048576, 1572864, 2097152]], - contexts: extractProcessMemoryDumps(processMemoryDumps, 2) - }, - { - title: colorLegendMatcher('Process 3'), - sizes: [undefined, undefined, undefined, undefined, undefined, - undefined, undefined, undefined, undefined, - [2147483648, undefined, 1073741824], - [1073741824, undefined, 2147483648], undefined], - contexts: extractProcessMemoryDumps(processMemoryDumps, 3) - }, - { - title: colorLegendMatcher('Process 4'), - sizes: [undefined, [undefined, 17825792, 17825792], undefined, - undefined, undefined, undefined, undefined, undefined, - undefined, undefined, undefined, undefined], - contexts: extractProcessMemoryDumps(processMemoryDumps, 4) - } - ], - [ // Footer rows. - { - title: 'Total', - sizes: [[50855936, 47710208, 15728640], - [40370176, 57671680, 58720256], [28835840, 27787264, 18350080], - [8388608, 5767168, -2621440], [32, 32, 64], - [10485760, 8912896, 7340032], [undefined, 7340032, 6291456], - [undefined, 0, 1048576], [2097152, 8388608, 786432], - [2147483648, 1, 1073741824], [1078984704, 5242880, 2153250816], - [1048576, 3670016, 2097152]], - contexts: undefined - } - ], - AggregationMode.DIFF); - }); - - test('instantiate_singleProcessMemoryDump', function() { - var processMemoryDumps = convertToProcessMemoryDumps( - [tr.ui.analysis.createSingleTestProcessMemoryDump()]); - createAndCheckMemoryDumpOverviewPane(this, - processMemoryDumps, - [ // Table rows. - { - title: colorLegendMatcher('Process 2'), - sizes: [[17825792], [39845888], [18350080], [0], [32], [8912896], - [7340032], [0], [1048576], [1], [5242880], [1572864]], - contexts: extractProcessMemoryDumps(processMemoryDumps, 2) - } - ], - [] /* footer rows */, - undefined /* no aggregation */); - }); - - test('instantiate_multipleProcessMemoryDumps', function() { - var processMemoryDumps = convertToProcessMemoryDumps( - tr.ui.analysis.createMultipleTestProcessMemoryDumps()); - createAndCheckMemoryDumpOverviewPane(this, - processMemoryDumps, - [ // Table rows. - { - title: colorLegendMatcher('Process 2'), - sizes: [[19398656, 17825792, 15728640], - [40370176, 39845888, 40894464], [18350080, 18350080, 18350080], - [0, 0, -2621440], [32, 32, 64], [10485760, 8912896, 7340032], - [undefined, 7340032, 6291456], [undefined, 0, 1048576], - [2097152, 1048576, 786432], [undefined, 1, undefined], - [5242880, 5242880, 5767168], [1048576, 1572864, 2097152]], - contexts: extractProcessMemoryDumps(processMemoryDumps, 2) - } - ], - [] /* footer rows */, - AggregationMode.MAX); - }); - - test('selection', function() { - var processMemoryDumps = convertToProcessMemoryDumps( - tr.ui.analysis.createMultipleTestGlobalMemoryDumps()); - - var viewEl = - tr.ui.analysis.createTestPane('tr-ui-a-memory-dump-overview-pane'); - viewEl.processMemoryDumps = processMemoryDumps; - viewEl.aggregationMode = AggregationMode.DIFF; - viewEl.rebuild(); - this.addHTMLOutput(viewEl); - - var table = viewEl.$.table; - - // Simulate clicking on the 'malloc' cell of the second process. - table.selectedTableRow = table.tableRows[1]; - table.selectedColumnIndex = 9; - assert.lengthOf(viewEl.requestedChildPanes, 2); - var lastChildPane = viewEl.requestedChildPanes[1]; - assert.equal( - lastChildPane.tagName, 'TR-UI-A-MEMORY-DUMP-ALLOCATOR-DETAILS-PANE'); - assert.strictEqual(lastChildPane.aggregationMode, AggregationMode.DIFF); - assert.deepEqual(lastChildPane.memoryAllocatorDumps, - extractMemoryAllocatorDumps(processMemoryDumps, 2, 'malloc')); - - // Simulate clicking on the 'Oilpan' cell of the second process. - table.selectedColumnIndex = 10; - assert.lengthOf(viewEl.requestedChildPanes, 3); - var lastChildPane = viewEl.requestedChildPanes[2]; - assert.isUndefined(viewEl.lastChildPane); - }); - - test('memory', function() { - var processMemoryDumps = convertToProcessMemoryDumps( - tr.ui.analysis.createMultipleTestGlobalMemoryDumps()); - var containerEl = document.createElement('div'); - containerEl.brushingStateController = - new tr.c.BrushingStateController(undefined); - - function simulateView(pids, aggregationMode, - expectedSelectedCellFieldValues, expectedSelectedRowTitle, - expectedSelectedColumnIndex, callback) { - var viewEl = - tr.ui.analysis.createTestPane('tr-ui-a-memory-dump-overview-pane'); - var table = viewEl.$.table; - containerEl.textContent = ''; - containerEl.appendChild(viewEl); - - var displayedProcessMemoryDumps = processMemoryDumps.map( - function(memoryDumps) { - return tr.b.filterItems(memoryDumps, function(pid, pmd) { - return pids.indexOf(pmd.process.pid) !== -1; - }); - }); - viewEl.processMemoryDumps = displayedProcessMemoryDumps; - viewEl.aggregationMode = aggregationMode; - viewEl.rebuild(); - - if (expectedSelectedCellFieldValues === undefined) { - assert.isUndefined(viewEl.childPaneBuilder); - } else { - checkSizeNumericFields(table.selectedTableRow, - table.tableColumns[table.selectedColumnIndex], - expectedSelectedCellFieldValues); - } - - assert.strictEqual( - table.selectedColumnIndex, expectedSelectedColumnIndex); - if (expectedSelectedRowTitle === undefined) - assert.isUndefined(table.selectedTableRow); - else - assert.equal(table.selectedTableRow.title, expectedSelectedRowTitle); - - callback(viewEl, viewEl.$.table); - } - - simulateView( - [1, 2, 3, 4], // All processes. - AggregationMode.DIFF, - undefined, undefined, undefined, // No cell should be selected. - function(view, table) { - assert.isUndefined(view.createChildPane()); - - // Select the 'PSS' column of the second process. - table.selectedTableRow = table.tableRows[1]; - table.selectedColumnIndex = 3; - }); - - simulateView( - [2, 3], - AggregationMode.MAX, - [18350080, 18350080, 18350080], 'Process 2', 3, /* PSS */ - function(view, table) { - var childPane = view.createChildPane(); - assert.equal( - childPane.tagName, 'TR-UI-A-MEMORY-DUMP-VM-REGIONS-DETAILS-PANE'); - assert.deepEqual(tr.b.asArray(childPane.vmRegions), - extractVmRegions(processMemoryDumps, 2)); - assert.strictEqual(childPane.aggregationMode, AggregationMode.MAX); - }); - - simulateView( - [3], - undefined, /* No aggregation */ - undefined, undefined, undefined, // No cell selected. - function(view, table) { - assert.isUndefined(view.createChildPane()); - }); - - simulateView( - [1, 2, 3, 4], - AggregationMode.DIFF, - [18350080, 18350080, 18350080], 'Process 2', 3, /* PSS */ - function(view, table) { - var childPane = view.createChildPane(); - assert.equal( - childPane.tagName, 'TR-UI-A-MEMORY-DUMP-VM-REGIONS-DETAILS-PANE'); - assert.deepEqual(tr.b.asArray(childPane.vmRegions), - extractVmRegions(processMemoryDumps, 2)); - assert.strictEqual(childPane.aggregationMode, AggregationMode.DIFF); - - // Select the 'v8' column of the first process (empty cell). - table.selectedTableRow = table.tableRows[0]; - table.selectedColumnIndex = 10; - }); - - simulateView( - [1], - undefined, /* No aggregation */ - undefined, undefined, undefined, // No cell should selected. - function(view, table) { - assert.isUndefined(view.createChildPane()); - - // Select 'Total resident' column of the first process. - table.selectedTableRow = table.tableRows[0]; - table.selectedColumnIndex = 1; - }); - - simulateView( - [1, 2, 3, 4], - AggregationMode.MAX, - [31457280, 29884416, undefined], 'Process 1', 1, /* Total resident */ - function(view, table) { - var childPane = view.createChildPane(); - assert.equal( - childPane.tagName, 'TR-UI-A-MEMORY-DUMP-VM-REGIONS-DETAILS-PANE'); - assert.deepEqual(tr.b.asArray(childPane.vmRegions), - extractVmRegions(processMemoryDumps, 1)); - assert.strictEqual(childPane.aggregationMode, AggregationMode.MAX); - }); - }); - - test('processNameColumn_formatTitle', function() { - var c = new ProcessNameColumn(); - - // With context (total row). - assert.strictEqual(c.formatTitle({ - title: 'Total', - usedMemoryCells: {} - }), 'Total'); - - // Without context (process row). - var title = c.formatTitle({ - title: 'Process 1', - usedMemoryCells: {}, - contexts: [tr.ui.analysis.createSingleTestProcessMemoryDump()] - }); - checkColorLegend(title, 'Process 1'); - }); - - test('usedMemoryColumn', function() { - var c = new UsedMemoryColumn('Private', 'bytes', tr.b.identity, - AggregationMode.DIFF); - checkSpanWithColor(c.title, 'Private', - 'used_memory_column' /* blue (column title) */); - checkColor(c.color(undefined /* contexts */), - 'used_memory_column' /* blue (column cells) */); - }); - - test('peakMemoryColumn', function() { - var c = new PeakMemoryColumn('Peak', 'bytes', tr.b.identity, - AggregationMode.MAX); - checkSpanWithColor(c.title, 'Peak', - 'used_memory_column' /* blue (column title) */); - checkColor(c.color(undefined) /* contexts */, - 'used_memory_column' /* blue (column cells) */); - - var RESETTABLE_PEAK = 1 << 2; - var NON_RESETTABLE_PEAK = 1 << 3; - function checkPeakColumnInfosAndColor(fieldAndDumpMask, expectedInfos) { - checkOverviewColumnInfosAndColor(c, - fieldAndDumpMask, - function(pmd, mask) { - if (mask & RESETTABLE_PEAK) { - assert.strictEqual( - mask & NON_RESETTABLE_PEAK, 0); // Test sanity check. - pmd.arePeakResidentBytesResettable = true; - } else if (mask & NON_RESETTABLE_PEAK) { - pmd.arePeakResidentBytesResettable = false; - } - }, - expectedInfos, - 'used_memory_column'); - } - - // No context. - checkOverviewColumnInfosAndColor(c, - [FIELD], - undefined /* no context */, - [] /* no infos */, - 'used_memory_column' /* blue color */); - checkOverviewColumnInfosAndColor(c, - [FIELD, FIELD, 0, FIELD], - undefined /* no context */, - [] /* no infos */, - 'used_memory_column' /* blue color */); - - // All resettable. - var EXPECTED_RESETTABLE_INFO = { - icon: '\u21AA', - message: 'Peak RSS since previous memory dump.' - }; - checkPeakColumnInfosAndColor([ - FIELD | DUMP | RESETTABLE_PEAK - ], [EXPECTED_RESETTABLE_INFO]); - checkPeakColumnInfosAndColor([ - FIELD | DUMP | RESETTABLE_PEAK, - DUMP /* ignored because there's no field */, - 0, - FIELD | DUMP | RESETTABLE_PEAK - ], [EXPECTED_RESETTABLE_INFO]); - - // All non-resettable. - var EXPECTED_NON_RESETTABLE_INFO = { - icon: '\u21A6', - message: 'Peak RSS since process startup. Finer grained peaks require ' + - 'a Linux kernel version \u2265 4.0.' - }; - checkPeakColumnInfosAndColor([ - FIELD | DUMP | NON_RESETTABLE_PEAK - ], [EXPECTED_NON_RESETTABLE_INFO]); - checkPeakColumnInfosAndColor([ - 0, - DUMP | RESETTABLE_PEAK /* ignored because there's no field */, - FIELD | DUMP | NON_RESETTABLE_PEAK, - FIELD | DUMP | NON_RESETTABLE_PEAK - ], [EXPECTED_NON_RESETTABLE_INFO]); - - // Combination (warning). - var EXPECTED_COMBINATION_INFO = { - icon: '\u26A0', - message: 'Both resettable and non-resettable peak RSS values were ' + - 'provided by the process', - color: 'red' - }; - checkPeakColumnInfosAndColor([ - FIELD | DUMP | NON_RESETTABLE_PEAK, - 0, - FIELD | DUMP | RESETTABLE_PEAK, - 0 - ], [EXPECTED_COMBINATION_INFO]); - }); - - test('byteStatColumn', function() { - var c = new ByteStatColumn('Stat', 'bytes', tr.b.identity, - AggregationMode.DIFF); - checkSpanWithColor(c.title, 'Stat', - 'used_memory_column' /* blue (column title) */); - - var HAS_OWN_VM_REGIONS = 1 << 2; - function checkByteStatColumnInfosAndColor( - fieldAndDumpMask, expectedInfos, expectedIsOlderColor) { - checkOverviewColumnInfosAndColor(c, - fieldAndDumpMask, - function(pmd, mask) { - if (mask & HAS_OWN_VM_REGIONS) - pmd.vmRegions = []; - }, - expectedInfos, - expectedIsOlderColor ? - 'older_used_memory_column' /* light blue */ : - 'used_memory_column' /* blue color */); - } - - var EXPECTED_ALL_OLDER_VALUES = { - icon: '\u26AF', - message: 'Older value (only heavy (purple) memory dumps contain ' + - 'memory maps).' - }; - var EXPECTED_SOME_OLDER_VALUES = { - icon: '\u26AF', - message: 'Older value at some selected timestamps (only heavy ' + - '(purple) memory dumps contain memory maps).' - }; - - // No context. - checkOverviewColumnInfosAndColor(c, - [FIELD], - undefined /* no context */, - [] /* no infos */, - 'used_memory_column' /* blue color */); - checkOverviewColumnInfosAndColor(c, - [FIELD, FIELD, 0, FIELD], - undefined /* no context */, - [] /* no infos */, - 'used_memory_column' /* blue color */); - - // All process memory dumps have own VM regions. - checkByteStatColumnInfosAndColor([ - FIELD | DUMP | HAS_OWN_VM_REGIONS - ], [] /* no infos */, false /* blue color */); - checkByteStatColumnInfosAndColor([ - FIELD | DUMP | HAS_OWN_VM_REGIONS, - FIELD | DUMP | HAS_OWN_VM_REGIONS, - 0, - FIELD | DUMP | HAS_OWN_VM_REGIONS - ], [] /* no infos */, false /* blue color */); - - // No process memory dumps have own VM regions. - checkByteStatColumnInfosAndColor([ - FIELD | DUMP - ], [EXPECTED_ALL_OLDER_VALUES], true /* light blue */); - checkByteStatColumnInfosAndColor([ - FIELD | DUMP, - FIELD | DUMP - ], [EXPECTED_ALL_OLDER_VALUES], true /* light blue */); - - // Some process memory dumps don't have own VM regions. - checkByteStatColumnInfosAndColor([ - FIELD | DUMP, - 0, - FIELD | DUMP - ], [EXPECTED_SOME_OLDER_VALUES], true /* light blue */); - checkByteStatColumnInfosAndColor([ - FIELD | DUMP | HAS_OWN_VM_REGIONS, - FIELD | DUMP, - FIELD | DUMP | HAS_OWN_VM_REGIONS - ], [EXPECTED_SOME_OLDER_VALUES], false /* blue */); - }); - - test('allocatorColumn', function() { - var c = new AllocatorColumn('Allocator', 'bytes', tr.b.identity, - AggregationMode.MAX); - checkColorLegend(c.title, 'Allocator'); - checkColor(c.color(undefined /* contexts */), - undefined /* no color (column cells) */); - - var HAS_HEAP_DUMPS = 1 << 2; - var HAS_ALLOCATOR_HEAP_DUMP = 1 << 3; - var MISSING_SIZE = 1 << 4; - function checkAllocatorColumnInfosAndColor(fieldAndDumpMask, - expectedInfos) { - checkOverviewColumnInfosAndColor(c, - fieldAndDumpMask, - function(pmd, mask) { - if (mask & HAS_HEAP_DUMPS) - pmd.heapDumps = {}; - if (mask & HAS_ALLOCATOR_HEAP_DUMP) - pmd.heapDumps['Allocator'] = new HeapDump(pmd, 'Allocator'); - var mad = new MemoryAllocatorDump(pmd, 'Allocator'); - if (!(mask & MISSING_SIZE)) { - mad.addNumeric('size', - new ScalarNumeric(sizeInBytes_smallerIsBetter, 7)); - } - pmd.memoryAllocatorDumps = [mad]; - }, - expectedInfos, - undefined /* no color */); - } - - // No context. - checkOverviewColumnInfosAndColor(c, - [FIELD], - undefined /* no context */, - [] /* no infos */, - undefined /* no color */); - checkOverviewColumnInfosAndColor(c, - [FIELD, FIELD, 0, FIELD], - undefined /* no context */, - [] /* no infos */, - undefined /* no color */); - - // No infos. - checkAllocatorColumnInfosAndColor([ - FIELD | DUMP - ], [] /* no infos */); - checkAllocatorColumnInfosAndColor([ - FIELD | DUMP, - FIELD | DUMP | HAS_HEAP_DUMPS, - 0, - FIELD | DUMP - ], [] /* infos */); - - var EXPECTED_ALL_HAVE_ALLOCATOR_HEAP_DUMP = { - icon: '\u2630', - message: 'Heap dump provided.' - }; - var EXPECTED_SOME_HAVE_ALLOCATOR_HEAP_DUMP = { - icon: '\u2630', - message: 'Heap dump provided at some selected timestamps.' - }; - - // All process memory dumps have heap dumps. - checkAllocatorColumnInfosAndColor([ - FIELD | DUMP | HAS_HEAP_DUMPS | HAS_ALLOCATOR_HEAP_DUMP - ], [EXPECTED_ALL_HAVE_ALLOCATOR_HEAP_DUMP]); - checkAllocatorColumnInfosAndColor([ - FIELD | DUMP | HAS_HEAP_DUMPS | HAS_ALLOCATOR_HEAP_DUMP, - FIELD | DUMP | HAS_HEAP_DUMPS | HAS_ALLOCATOR_HEAP_DUMP, - FIELD | DUMP | HAS_HEAP_DUMPS | HAS_ALLOCATOR_HEAP_DUMP - ], [EXPECTED_ALL_HAVE_ALLOCATOR_HEAP_DUMP]); - - // Some process memory dumps have heap dumps. - checkAllocatorColumnInfosAndColor([ - 0, - FIELD | DUMP | HAS_HEAP_DUMPS | HAS_ALLOCATOR_HEAP_DUMP - ], [EXPECTED_SOME_HAVE_ALLOCATOR_HEAP_DUMP]); - checkAllocatorColumnInfosAndColor([ - FIELD | DUMP | HAS_HEAP_DUMPS | HAS_ALLOCATOR_HEAP_DUMP, - FIELD | DUMP | HAS_HEAP_DUMPS, - FIELD | DUMP | HAS_HEAP_DUMPS | HAS_ALLOCATOR_HEAP_DUMP - ], [EXPECTED_SOME_HAVE_ALLOCATOR_HEAP_DUMP]); - - var EXPECTED_ALL_MISSING_SIZE = { - icon: '\u26A0', - message: 'Size was not provided.', - color: 'red' - }; - var EXPECTED_SOME_MISSING_SIZE = { - icon: '\u26A0', - message: 'Size was not provided at some selected timestamps.', - color: 'red' - }; - - // All process memory dumps are missing allocator size. - checkAllocatorColumnInfosAndColor([ - FIELD | DUMP | MISSING_SIZE - ], [EXPECTED_ALL_MISSING_SIZE]); - checkAllocatorColumnInfosAndColor([ - FIELD | DUMP | MISSING_SIZE, - FIELD | DUMP | MISSING_SIZE, - FIELD | DUMP | MISSING_SIZE - ], [EXPECTED_ALL_MISSING_SIZE]); - - // Some process memory dumps use Android memtrack PSS fallback. - checkAllocatorColumnInfosAndColor([ - 0, - FIELD | DUMP | MISSING_SIZE - ], [EXPECTED_SOME_MISSING_SIZE]); - checkAllocatorColumnInfosAndColor([ - FIELD | DUMP | MISSING_SIZE, - FIELD | DUMP, - FIELD | DUMP | MISSING_SIZE - ], [EXPECTED_SOME_MISSING_SIZE]); - - // Combination of heap dump and memtrack fallback infos. - checkAllocatorColumnInfosAndColor([ - FIELD | DUMP | MISSING_SIZE | HAS_HEAP_DUMPS | - HAS_ALLOCATOR_HEAP_DUMP - ], [ - EXPECTED_ALL_HAVE_ALLOCATOR_HEAP_DUMP, - EXPECTED_ALL_MISSING_SIZE - ]); - checkAllocatorColumnInfosAndColor([ - FIELD | DUMP | HAS_HEAP_DUMPS | HAS_ALLOCATOR_HEAP_DUMP, - FIELD | DUMP, - FIELD | DUMP | MISSING_SIZE - ], [ - EXPECTED_SOME_HAVE_ALLOCATOR_HEAP_DUMP, - EXPECTED_SOME_MISSING_SIZE - ]); - }); - - test('tracingColumn', function() { - var c = new TracingColumn('Tracing', 'bytes', tr.b.identity, - AggregationMode.DIFF); - checkSpanWithColor(c.title, 'Tracing', - 'tracing_memory_column' /* expected column title gray color */); - checkColor(c.color(undefined /* contexts */), - 'tracing_memory_column' /* expected column cells gray color */); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/memory_dump_sub_view_test_utils.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/memory_dump_sub_view_test_utils.html deleted file mode 100644 index 36235636c56..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/memory_dump_sub_view_test_utils.html +++ /dev/null @@ -1,570 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/color.html"> -<link rel="import" href="/tracing/base/color_scheme.html"> -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/global_memory_dump.html"> -<link rel="import" href="/tracing/model/heap_dump.html"> -<link rel="import" href="/tracing/model/memory_dump_test_utils.html"> -<link rel="import" href="/tracing/model/process_memory_dump.html"> -<link rel="import" href="/tracing/model/vm_region.html"> -<link rel="import" href="/tracing/value/numeric.html"> -<link rel="import" href="/tracing/value/unit.html"> - -<script> -'use strict'; - -/** - * @fileoverview Helper functions for memory dump analysis sub-view tests. - */ -tr.exportTo('tr.ui.analysis', function() { - var Color = tr.b.Color; - var ColorScheme = tr.b.ColorScheme; - var GlobalMemoryDump = tr.model.GlobalMemoryDump; - var ProcessMemoryDump = tr.model.ProcessMemoryDump; - var VMRegion = tr.model.VMRegion; - var VMRegionClassificationNode = tr.model.VMRegionClassificationNode; - var ScalarNumeric = tr.v.ScalarNumeric; - var sizeInBytes_smallerIsBetter = - tr.v.Unit.byName.sizeInBytes_smallerIsBetter; - var unitlessNumber_smallerIsBetter = - tr.v.Unit.byName.unitlessNumber_smallerIsBetter; - var HeapDump = tr.model.HeapDump; - var addGlobalMemoryDump = tr.model.MemoryDumpTestUtils.addGlobalMemoryDump; - var addProcessMemoryDump = tr.model.MemoryDumpTestUtils.addProcessMemoryDump; - var newAllocatorDump = tr.model.MemoryDumpTestUtils.newAllocatorDump; - var addOwnershipLink = tr.model.MemoryDumpTestUtils.addOwnershipLink; - - function createMultipleTestGlobalMemoryDumps() { - var model = tr.c.TestUtils.newModel(function(model) { - var pA = model.getOrCreateProcess(1); - var pB = model.getOrCreateProcess(2); - var pC = model.getOrCreateProcess(3); - var pD = model.getOrCreateProcess(4); - - // ====================================================================== - // First timestamp. - // ====================================================================== - var gmd1 = addGlobalMemoryDump(model, 42); - - // Totals and VM regions. - var pmd1A = addProcessMemoryDump(gmd1, pA, 41); - pmd1A.totals = { residentBytes: 31457280 /* 30 MiB */ }; - pmd1A.vmRegions = VMRegionClassificationNode.fromRegions([ - VMRegion.fromDict({ - startAddress: 1024, - sizeInBytes: 20971520, /* 20 MiB */ - protectionFlags: VMRegion.PROTECTION_FLAG_READ, - mappedFile: '[stack]', - byteStats: { - privateDirtyResident: 8388608, /* 8 MiB */ - sharedCleanResident: 12582912, /* 12 MiB */ - proportionalResident: 10485760 /* 10 MiB */ - } - }) - ]); - - // Everything. - var pmd1B = addProcessMemoryDump(gmd1, pB, 42); - pmd1B.totals = { - residentBytes: 20971520, /* 20 MiB */ - peakResidentBytes: 41943040, /* 40 MiB */ - arePeakResidentBytesResettable: false, - platformSpecific: { - private_bytes: 10485760 /* 10 MiB */ - } - }; - pmd1B.vmRegions = VMRegionClassificationNode.fromRegions([ - VMRegion.fromDict({ - startAddress: 256, - sizeInBytes: 6000, - protectionFlags: VMRegion.PROTECTION_FLAG_READ | - VMRegion.PROTECTION_FLAG_WRITE, - mappedFile: '[stack:20310]', - byteStats: { - proportionalResident: 15728640, /* 15 MiB */ - privateDirtyResident: 1572864, /* 1.5 MiB */ - swapped: 32 /* 32 B */ - } - }), - VMRegion.fromDict({ - startAddress: 100000, - sizeInBytes: 4096, - protectionFlags: VMRegion.PROTECTION_FLAG_READ, - mappedFile: '/usr/lib/libwtf.so', - byteStats: { - proportionalResident: 4194304, /* 4 MiB */ - privateDirtyResident: 0, - swapped: 0 /* 32 B */ - } - }) - ]); - pmd1B.memoryAllocatorDumps = [ - newAllocatorDump(pmd1B, 'malloc', { size: 3145728 /* 3 MiB */ }), - newAllocatorDump(pmd1B, 'v8', { size: 5242880 /* 5 MiB */ }), - newAllocatorDump(pmd1B, 'tracing', { - size: 1048576 /* 1 MiB */, - resident_size: 1572864 /* 1.5 MiB */ - }) - ]; - - // Allocator dumps only. - var pmd1C = addProcessMemoryDump(gmd1, pC, 43); - pmd1C.memoryAllocatorDumps = (function() { - var oilpanDump = newAllocatorDump(pmd1C, 'oilpan', { - size: 3221225472 /* 3 GiB */, - inner_size: 5242880 /* 5 MiB */, - objects_count: new ScalarNumeric(unitlessNumber_smallerIsBetter, 2015) - }); - var v8Dump = newAllocatorDump(pmd1C, 'v8', { - size: 1073741824 /* 1 GiB */, - inner_size: 2097152 /* 2 MiB */, - objects_count: new ScalarNumeric(unitlessNumber_smallerIsBetter, 204) - }); - - addOwnershipLink(v8Dump, oilpanDump); - - return [oilpanDump, v8Dump]; - })(); - pmd1C.heapDumps = { - 'v8': (function() { - var v8HeapDump = new HeapDump(pmd1C, 'v8'); - v8HeapDump.addEntry( - tr.c.TestUtils.newStackTrace(model, - ['V8.Execute', 'UpdateLayoutTree']), - undefined /* sum over all object types */, - 536870912 /* 512 MiB */); - return v8HeapDump; - })() - }; - - // ====================================================================== - // Second timestamp. - // ====================================================================== - var gmd2 = addGlobalMemoryDump(model, 68); - - // Everything. - var pmd2A = addProcessMemoryDump(gmd2, pA, 67); - pmd2A.totals = { residentBytes: 32505856 /* 31 MiB */ }; - pmd2A.vmRegions = VMRegionClassificationNode.fromRegions([ - VMRegion.fromDict({ - startAddress: 1024, - sizeInBytes: 20971520, /* 20 MiB */ - protectionFlags: VMRegion.PROTECTION_FLAG_READ, - mappedFile: '[stack]', - byteStats: { - privateDirtyResident: 8388608, /* 8 MiB */ - sharedCleanResident: 11534336, /* 11 MiB */ - proportionalResident: 11534336 /* 11 MiB */ - } - }), - VMRegion.fromDict({ - startAddress: 104857600, - sizeInBytes: 5242880, /* 5 MiB */ - protectionFlags: VMRegion.PROTECTION_FLAG_EXECUTE, - mappedFile: '/usr/bin/google-chrome', - byteStats: { - privateDirtyResident: 0, - sharedCleanResident: 4194304, /* 4 MiB */ - proportionalResident: 524288 /* 512 KiB */ - } - }) - ]); - pmd2A.memoryAllocatorDumps = [ - newAllocatorDump(pmd2A, 'malloc', { size: 9437184 /* 9 MiB */ }), - newAllocatorDump(pmd2A, 'tracing', { - size: 2097152 /* 2 MiB */, - resident_size: 2621440 /* 2.5 MiB */ - }) - ]; - - // Totals and allocator dumps only. - var pmd2B = addProcessMemoryDump(gmd2, pB, 69); - pmd2B.totals = { - residentBytes: 19922944, /* 19 MiB */ - peakResidentBytes: 41943040, /* 40 MiB */ - arePeakResidentBytesResettable: false, - platformSpecific: { - private_bytes: 8912896 /* 8.5 MiB */ - } - }; - pmd2B.memoryAllocatorDumps = [ - newAllocatorDump(pmd2B, 'malloc', { size: 2621440 /* 2.5 MiB */ }), - newAllocatorDump(pmd2B, 'v8', { size: 5242880 /* 5 MiB */ }), - newAllocatorDump(pmd2B, 'blink', { size: 7340032 /* 7 MiB */ }), - newAllocatorDump(pmd2B, 'oilpan', { size: 1 }), - newAllocatorDump(pmd2B, 'tracing', { - size: 1572864 /* 1.5 MiB */, - resident_size: 2097152 /* 2 MiB */ - }), - newAllocatorDump(pmd2B, 'gpu', { memtrack_pss: 524288 /* 512 KiB */ }) - ]; - - // Resettable peak total size only. - var pmd2D = addProcessMemoryDump(gmd2, pD, 71); - pmd2D.totals = { - peakResidentBytes: 17825792, /* 17 MiB */ - arePeakResidentBytesResettable: true - }; - - // ====================================================================== - // Third timestamp. - // ====================================================================== - var gmd3 = addGlobalMemoryDump(model, 100); - - // Everything. - var pmd3B = addProcessMemoryDump(gmd3, pB, 102); - pmd3B.totals = { - residentBytes: 18874368, /* 18 MiB */ - peakResidentBytes: 44040192, /* 42 MiB */ - arePeakResidentBytesResettable: false, - platformSpecific: { - private_bytes: 7340032 /* 7 MiB */ - } - }; - pmd3B.vmRegions = VMRegionClassificationNode.fromRegions([ - VMRegion.fromDict({ - startAddress: 256, - sizeInBytes: 6000, - protectionFlags: VMRegion.PROTECTION_FLAG_READ | - VMRegion.PROTECTION_FLAG_WRITE, - mappedFile: '[stack:20310]', - byteStats: { - proportionalResident: 21495808, /* 20.5 MiB */ - privateDirtyResident: 524288, /* 0.5 MiB */ - swapped: 64 /* 32 B */ - } - }) - ]); - pmd3B.memoryAllocatorDumps = [ - newAllocatorDump(pmd3B, 'malloc', {size: 2883584 /* 2.75 MiB */ }), - newAllocatorDump(pmd3B, 'v8', { size: 5767168 /* 5.5 MiB */ }), - newAllocatorDump(pmd3B, 'blink', { size: 6291456 /* 7 MiB */ }), - newAllocatorDump(pmd3B, 'tracing', { - size: 2097152 /* 2 MiB */, - resident_size: 3145728 /* 3 MiB */ - }), - newAllocatorDump(pmd3C, 'gpu', { - size: 1048576 /* 1 MiB */, - memtrack_pss: 786432 /* 768 KiB */ - }) - ]; - - // Allocator dumps only. - var pmd3C = addProcessMemoryDump(gmd3, pC, 100); - pmd3C.memoryAllocatorDumps = (function() { - var oilpanDump = newAllocatorDump(pmd3C, 'oilpan', { - size: 3221225472 /* 3 GiB */, - inner_size: 5242880 /* 5 MiB */, - objects_count: new ScalarNumeric(unitlessNumber_smallerIsBetter, 2015) - }); - var v8Dump = newAllocatorDump(pmd3C, 'v8', { - size: 2147483648 /* 2 GiB */, - inner_size: 2097152 /* 2 MiB */, - objects_count: new ScalarNumeric(unitlessNumber_smallerIsBetter, 204) - }); - - addOwnershipLink(v8Dump, oilpanDump); - - return [oilpanDump, v8Dump]; - })(); - pmd3C.heapDumps = { - 'v8': (function() { - var v8HeapDump = new HeapDump(pmd1C, 'v8'); - v8HeapDump.addEntry( - tr.c.TestUtils.newStackTrace(model, - ['V8.Execute', 'UpdateLayoutTree']), - undefined /* sum over all object types */, - 268435456 /* 256 MiB */); - v8HeapDump.addEntry( - tr.c.TestUtils.newStackTrace(model, - ['V8.Execute', 'FrameView::layout']), - undefined /* sum over all object types */, - 134217728 /* 128 MiB */); - return v8HeapDump; - })() - }; - - // Resettable peak total size only. - var pmd3D = addProcessMemoryDump(gmd3, pD, 99); - pmd3D.totals = { - peakResidentBytes: 17825792, /* 17 MiB */ - arePeakResidentBytesResettable: true - }; - }); - - return model.globalMemoryDumps; - } - - function createSingleTestGlobalMemoryDump() { - return createMultipleTestGlobalMemoryDumps()[1]; - } - - function createMultipleTestProcessMemoryDumps() { - return createMultipleTestGlobalMemoryDumps().map(function(gmd) { - return gmd.processMemoryDumps[2]; - }); - } - - function createSingleTestProcessMemoryDump() { - return createMultipleTestProcessMemoryDumps()[1]; - } - - function checkNumericFields(row, column, expectedValues, expectedUnit) { - var fields; - if (column === undefined) - fields = row; - else - fields = column.fields(row); - - if (expectedValues === undefined) { - assert.isUndefined(fields); - return; - } - - assert.lengthOf(fields, expectedValues.length); - for (var i = 0; i < fields.length; i++) { - var field = fields[i]; - var expectedValue = expectedValues[i]; - if (expectedValue === undefined) { - assert.isUndefined(field); - } else { - assert.isDefined(expectedUnit); // Test sanity check. - assert.instanceOf(field, ScalarNumeric); - assert.equal(field.value, expectedValue); - assert.equal(field.unit, expectedUnit); - } - } - } - - function checkSizeNumericFields(row, column, expectedValues) { - checkNumericFields(row, column, expectedValues, - sizeInBytes_smallerIsBetter); - } - - function checkStringFields(row, column, expectedStrings) { - var fields = column.fields(row); - - if (expectedStrings === undefined) { - assert.isUndefined(fields); - return; - } - - assert.deepEqual(tr.b.asArray(fields), expectedStrings); - } - - /** - * Check the titles, types and aggregation modes of a list of columns. - * expectedColumns is a list of dictionaries with the following fields: - * - * - title: Either the expected title (string), or a matcher for it - * (function that accepts the actual title as its argument). - * - type: The expected class of the column. - * - noAggregation: If true, the column is expected to have no aggregation - * mode (regardless of expectedAggregationMode). - */ - function checkColumns(columns, expectedColumns, expectedAggregationMode) { - assert.lengthOf(columns, expectedColumns.length); - for (var i = 0; i < expectedColumns.length; i++) { - var actualColumn = columns[i]; - var expectedColumn = expectedColumns[i]; - var expectedTitle = expectedColumn.title; - if (typeof expectedTitle === 'function') - expectedTitle(actualColumn.title); // Custom title matcher. - else - assert.strictEqual(actualColumn.title, expectedTitle); // String title. - assert.instanceOf(actualColumn, expectedColumn.type); - assert.strictEqual(actualColumn.aggregationMode, - expectedColumn.noAggregation ? undefined : expectedAggregationMode); - } - } - - function checkColumnInfosAndColor( - column, fields, contexts, expectedInfos, expectedColorReservedName) { - // Test sanity checks. - assert.isDefined(fields); - if (contexts !== undefined) - assert.lengthOf(contexts, fields.length); - - // Check infos. - var infos = []; - column.addInfos(fields, contexts, infos); - assert.lengthOf(infos, expectedInfos.length); - for (var i = 0; i < expectedInfos.length; i++) - assert.deepEqual(infos[i], expectedInfos[i]); - - // Check color. - var actualColor = typeof column.color === 'function' ? - column.color(fields, contexts) : - column.color; - checkColor(actualColor, expectedColorReservedName); - } - - function checkColor(actualColorString, expectedColorReservedName) { - if (expectedColorReservedName === undefined) { - assert.isUndefined(actualColorString); - return; - } - - var actualColor = Color.fromString(actualColorString); - var expectedColor = ColorScheme.colors[ - ColorScheme.getColorIdForReservedName(expectedColorReservedName)]; - assert.deepEqual(actualColor, expectedColor); - } - - function createAndCheckEmptyPanes( - test, paneTagName, propertyName, opt_callback) { - // Unset property. - var unsetViewEl = createTestPane(paneTagName); - unsetViewEl.rebuild(); - assert.isUndefined(unsetViewEl.createChildPane()); - test.addHTMLOutput(unsetViewEl); - - // Undefined property. - var undefinedViewEl = createTestPane(paneTagName); - undefinedViewEl[propertyName] = undefined; - undefinedViewEl.rebuild(); - assert.isUndefined(undefinedViewEl.createChildPane()); - test.addHTMLOutput(undefinedViewEl); - - // Empty property. - var emptyViewEl = createTestPane(paneTagName); - emptyViewEl[propertyName] = []; - emptyViewEl.rebuild(); - assert.isUndefined(undefinedViewEl.createChildPane()); - test.addHTMLOutput(emptyViewEl); - - // Check that all the panes have the same dimensions. - var unsetBounds = unsetViewEl.getBoundingClientRect(); - var undefinedBounds = undefinedViewEl.getBoundingClientRect(); - var emptyBounds = emptyViewEl.getBoundingClientRect(); - assert.equal(undefinedBounds.width, unsetBounds.width); - assert.equal(emptyBounds.width, unsetBounds.width); - assert.equal(undefinedBounds.height, unsetBounds.height); - assert.equal(emptyBounds.height, unsetBounds.height); - - // Custom checks (if provided). - if (opt_callback) { - opt_callback(unsetViewEl); - opt_callback(undefinedViewEl); - opt_callback(emptyViewEl); - } - } - - function createTestPane(tagName) { - var paneEl = document.createElement(tagName); - - // Store a list of requested child panes (for inspection in tests). - paneEl.requestedChildPanes = []; - paneEl.addEventListener('request-child-pane-change', function() { - paneEl.requestedChildPanes.push(paneEl.createChildPane()); - }); - - paneEl.createChildPane = function() { - var childPaneBuilder = this.childPaneBuilder; - if (childPaneBuilder === undefined) - return undefined; - return childPaneBuilder(); - }; - - return paneEl; - } - - // TODO(petrcermak): Consider moving this to tracing/ui/base/dom_helpers.html. - function isElementDisplayed(element) { - var style = getComputedStyle(element); - var displayed = style['display']; - if (displayed === undefined) - return true; - return displayed.indexOf('none') === -1; - } - - /** - * Convert a list of ContainerMemoryDump(s) to a list of dictionaries of the - * underlying ProcessMemoryDump(s). - */ - function convertToProcessMemoryDumps(containerMemoryDumps) { - return containerMemoryDumps.map(function(containerMemoryDump) { - return containerMemoryDump.processMemoryDumps; - }); - } - - /** - * Extract a chronological list of ProcessMemoryDump(s) (for a given process) - * from a chronological list of dictionaries of ProcessMemoryDump(s). - */ - function extractProcessMemoryDumps(processMemoryDumps, pid) { - return processMemoryDumps.map(function(memoryDumps) { - return memoryDumps[pid]; - }); - } - - /** - * Extract a chronological list of lists of VMRegion(s) (for a given process) - * from a chronological list of dictionaries of ProcessMemoryDump(s). - */ - function extractVmRegions(processMemoryDumps, pid) { - return processMemoryDumps.map(function(memoryDumps) { - var processMemoryDump = memoryDumps[pid]; - if (processMemoryDump === undefined) - return undefined; - return processMemoryDump.mostRecentVmRegions; - }); - } - - /** - * Extract a chronological list of MemoryAllocatorDump(s) (for a given - * process and allocator name) from a chronological list of dictionaries of - * ProcessMemoryDump(s). - */ - function extractMemoryAllocatorDumps(processMemoryDumps, pid, allocatorName) { - return processMemoryDumps.map(function(memoryDumps) { - var processMemoryDump = memoryDumps[pid]; - if (processMemoryDump === undefined) - return undefined; - return processMemoryDump.getMemoryAllocatorDumpByFullName(allocatorName); - }); - } - - /** - * Extract a chronological list of HeapDump(s) (for a given process and - * allocator name) from a chronological list of dictionaries of - * ProcessMemoryDump(s). - */ - function extractHeapDumps(processMemoryDumps, pid, allocatorName) { - return processMemoryDumps.map(function(memoryDumps) { - var processMemoryDump = memoryDumps[pid]; - if (processMemoryDump === undefined || - processMemoryDump.heapDumps === undefined) - return undefined; - return processMemoryDump.heapDumps[allocatorName]; - }); - } - - return { - createSingleTestGlobalMemoryDump: createSingleTestGlobalMemoryDump, - createMultipleTestGlobalMemoryDumps: createMultipleTestGlobalMemoryDumps, - createSingleTestProcessMemoryDump: createSingleTestProcessMemoryDump, - createMultipleTestProcessMemoryDumps: createMultipleTestProcessMemoryDumps, - checkNumericFields: checkNumericFields, - checkSizeNumericFields: checkSizeNumericFields, - checkStringFields: checkStringFields, - checkColumns: checkColumns, - checkColumnInfosAndColor: checkColumnInfosAndColor, - checkColor: checkColor, - createAndCheckEmptyPanes: createAndCheckEmptyPanes, - createTestPane: createTestPane, - isElementDisplayed: isElementDisplayed, - convertToProcessMemoryDumps: convertToProcessMemoryDumps, - extractProcessMemoryDumps: extractProcessMemoryDumps, - extractVmRegions: extractVmRegions, - extractMemoryAllocatorDumps: extractMemoryAllocatorDumps, - extractHeapDumps: extractHeapDumps - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/memory_dump_sub_view_util.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/memory_dump_sub_view_util.html deleted file mode 100644 index 74a38e81cda..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/memory_dump_sub_view_util.html +++ /dev/null @@ -1,889 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/iteration_helpers.html"> -<link rel="import" href="/tracing/ui/base/dom_helpers.html"> -<link rel="import" href="/tracing/ui/base/table.html"> -<link rel="import" href="/tracing/value/numeric.html"> -<link rel="import" href="/tracing/value/ui/scalar_span.html"> - -<script> -'use strict'; - -/** - * @fileoverview Helper code for memory dump sub-views. - */ -tr.exportTo('tr.ui.analysis', function() { - - var NO_BREAK_SPACE = String.fromCharCode(160); - var RIGHTWARDS_ARROW = String.fromCharCode(8594); - - var COLLATOR = new Intl.Collator(undefined, {numeric: true}); - - /** - * A table column for displaying memory dump row titles. - * - * @constructor - */ - function TitleColumn(title) { - this.title = title; - } - - TitleColumn.prototype = { - supportsCellSelection: false, - - /** - * Get the title associated with a given row. - * - * This method will decorate the title with color and '+++'/'---' prefix if - * appropriate (as determined by the optional row.contexts field). - * Examples: - * - * +----------------------+-----------------+--------+--------+ - * | Contexts provided at | Interpretation | Prefix | Color | - * +----------------------+-----------------+--------+--------+ - * | 1111111111 | always present | | | - * | 0000111111 | added | +++ | red | - * | 1111111000 | deleted | --- | green | - * | 1100111111* | flaky | | purple | - * | 0001001111 | added + flaky | +++ | purple | - * | 1111100010 | deleted + flaky | --- | purple | - * +----------------------+-----------------+--------+--------+ - * - * *) This means that, given a selection of 10 memory dumps, a particular - * row (e.g. a process) was present in the first 2 and last 6 of them - * (but not in the third and fourth dump). - * - * This method should therefore NOT be overriden by subclasses. The - * formatTitle method should be overriden instead when necessary. - */ - value: function(row) { - var formattedTitle = this.formatTitle(row); - - var contexts = row.contexts; - if (contexts === undefined || contexts.length === 0) - return formattedTitle; - - // Determine if the row was provided in the first and last row and how - // many times it changed between being provided and not provided. - var firstContext = contexts[0]; - var lastContext = contexts[contexts.length - 1]; - var changeDefinedContextCount = 0; - for (var i = 1; i < contexts.length; i++) { - if ((contexts[i] === undefined) !== (contexts[i - 1] === undefined)) - changeDefinedContextCount++; - } - - // Determine the color and prefix of the title. - var color = undefined; - var prefix = undefined; - if (!firstContext && lastContext) { - // The row was added. - color = 'red'; - prefix = '+++'; - } else if (firstContext && !lastContext) { - // The row was removed. - color = 'green'; - prefix = '---'; - } - if (changeDefinedContextCount > 1) { - // The row was flaky (added/removed more than once). - color = 'purple'; - } - - if (color === undefined && prefix === undefined) - return formattedTitle; - - var titleEl = document.createElement('span'); - if (prefix !== undefined) { - var prefixEl = tr.ui.b.createSpan({textContent: prefix}); - // Enforce same width of '+++' and '---'. - prefixEl.style.fontFamily = 'monospace'; - titleEl.appendChild(prefixEl); - titleEl.appendChild(tr.ui.b.asHTMLOrTextNode(NO_BREAK_SPACE)); - } - if (color !== undefined) - titleEl.style.color = color; - titleEl.appendChild(tr.ui.b.asHTMLOrTextNode(formattedTitle)); - return titleEl; - }, - - /** - * Format the title associated with a given row. This method is intended to - * be overriden by subclasses. - */ - formatTitle: function(row) { - return row.title; - }, - - cmp: function(rowA, rowB) { - return COLLATOR.compare(rowA.title, rowB.title); - } - }; - - /** - * Abstract table column for displaying memory dump data. - * - * @constructor - */ - function MemoryColumn(name, cellPath, aggregationMode) { - this.name = name; - this.cellPath = cellPath; - - // See MemoryColumn.AggregationMode enum in this file. - this.aggregationMode = aggregationMode; - } - - /** - * Construct columns from cells in a hierarchy of rows and a list of rules. - * - * The list of rules contains objects with three fields: - * - * condition: Optional string or regular expression matched against the - * name of a cell. If omitted, the rule will match any cell. - * importance: Mandatory number which determines the final order of the - * columns. The column with the highest importance will be first in the - * returned array. - * columnConstructor: Mandatory memory column constructor. - * - * Example: - * - * var importanceRules = [ - * { - * condition: 'page_size', - * columnConstructor: NumericMemoryColumn, - * importance: 8 - * }, - * { - * condition: /size/, - * columnConstructor: CustomNumericMemoryColumn, - * importance: 10 - * }, - * { - * // No condition: matches all columns. - * columnConstructor: NumericMemoryColumn, - * importance: 9 - * } - * ]; - * - * Given a name of a cell, the corresponding column constructor and - * importance are determined by the first rule whose condition matches the - * column's name. For example, given a cell with name 'inner_size', the - * corresponding column will be constructed using CustomNumericMemoryColumn - * and its importance (for sorting purposes) will be 10 (second rule). - * - * After columns are constructed for all cell names, they are sorted in - * descending order of importance and the resulting list is returned. In the - * example above, the constructed columns will be sorted into three groups as - * follows: - * - * [most important, left in the resulting table] - * 1. columns whose name contains 'size' excluding 'page_size' because it - * would have already matched the first rule (Note that string matches - * must be exact so a column named 'page_size2' would not match the - * first rule and would therefore belong to this group). - * 2. columns whose name does not contain 'size'. - * 3. columns whose name is 'page_size'. - * [least important, right in the resulting table] - * - * where columns will be sorted alphabetically within each group. - */ - MemoryColumn.fromRows = function(rows, cellKey, aggregationMode, rules) { - // Recursively find the names of all cells of the rows (and their sub-rows). - var cellNames = new Set(); - function gatherCellNames(rows) { - rows.forEach(function(row) { - if (row === undefined) - return; - var fieldCells = row[cellKey]; - if (fieldCells !== undefined) { - tr.b.iterItems(fieldCells, function(fieldName, fieldCell) { - if (fieldCell === undefined || fieldCell.fields === undefined) - return; - cellNames.add(fieldName); - }); - } - var subRows = row.subRows; - if (subRows !== undefined) - gatherCellNames(subRows); - }); - } - gatherCellNames(rows); - - // Based on the provided list of rules, construct the columns and calculate - // their importance. - var positions = []; - cellNames.forEach(function(cellName) { - var cellPath = [cellKey, cellName]; - var matchingRule = MemoryColumn.findMatchingRule(cellName, rules); - var constructor = matchingRule.columnConstructor; - var column = new constructor(cellName, cellPath, aggregationMode); - positions.push({ - importance: matchingRule.importance, - column: column - }); - }); - - positions.sort(function(a, b) { - // Sort columns with the same importance alphabetically. - if (a.importance === b.importance) - return COLLATOR.compare(a.column.name, b.column.name); - - // Sort columns in descending order of importance. - return b.importance - a.importance; - }); - - return positions.map(function(position) { return position.column }); - }; - - MemoryColumn.spaceEqually = function(columns) { - var columnWidth = (100 / columns.length).toFixed(3) + '%'; - columns.forEach(function(column) { - column.width = columnWidth; - }); - }; - - MemoryColumn.findMatchingRule = function(name, rules) { - for (var i = 0; i < rules.length; i++) { - var rule = rules[i]; - if (MemoryColumn.nameMatchesCondition(name, rule.condition)) - return rule; - } - return undefined; - }; - - MemoryColumn.nameMatchesCondition = function(name, condition) { - // Rules without conditions match all columns. - if (condition === undefined) - return true; - - // String conditions must match the column name exactly. - if (typeof(condition) === 'string') - return name === condition; - - // If the condition is not a string, assume it is a RegExp. - return condition.test(name); - }; - - /** @enum */ - MemoryColumn.AggregationMode = { - DIFF: 0, - MAX: 1 - }; - - MemoryColumn.SOME_TIMESTAMPS_INFO_QUANTIFIER = 'at some selected timestamps'; - - MemoryColumn.prototype = { - get title() { - return this.name; - }, - - cell: function(row) { - var cell = row; - var cellPath = this.cellPath; - for (var i = 0; i < cellPath.length; i++) { - if (cell === undefined) - return undefined; - cell = cell[cellPath[i]]; - } - return cell; - }, - - aggregateCells: function(row, subRows) { - // No generic aggregation. - }, - - fields: function(row) { - var cell = this.cell(row); - if (cell === undefined) - return undefined; - return cell.fields; - }, - - /** - * Format a cell associated with this column from the given row. This - * method is not intended to be overriden. - */ - value: function(row) { - var fields = this.fields(row); - if (this.hasAllRelevantFieldsUndefined(fields)) - return ''; - - // Determine the color and infos of the resulting element. - var contexts = row.contexts; - var color = this.color(fields, contexts); - var infos = []; - this.addInfos(fields, contexts, infos); - - // Format the actual fields. - var formattedFields = this.formatFields(fields); - - // If no color is specified and there are no infos, there is no need to - // wrap the value in a span element.# - if ((color === undefined || formattedFields === '') && infos.length === 0) - return formattedFields; - - var fieldEl = document.createElement('span'); - fieldEl.style.display = 'flex'; - fieldEl.style.alignItems = 'center'; - fieldEl.style.justifyContent = 'flex-end'; - fieldEl.appendChild(tr.ui.b.asHTMLOrTextNode(formattedFields)); - - // Add info icons with tooltips. - infos.forEach(function(info) { - var infoEl = document.createElement('span'); - infoEl.style.paddingLeft = '4px'; - infoEl.style.cursor = 'help'; - infoEl.style.fontWeight = 'bold'; - infoEl.textContent = info.icon; - if (info.color !== undefined) - infoEl.style.color = info.color; - infoEl.title = info.message; - fieldEl.appendChild(infoEl); - }, this); - - // Set the color of the element. - if (color !== undefined) - fieldEl.style.color = color; - - return fieldEl; - }, - - /** - * Returns true iff all fields of a row which are relevant for the current - * aggregation mode (e.g. first and last field for diff mode) are undefined. - */ - hasAllRelevantFieldsUndefined: function(fields) { - if (fields === undefined) - return true; - - switch (this.aggregationMode) { - case MemoryColumn.AggregationMode.DIFF: - // Only the first and last field are relevant. - return fields[0] === undefined && - fields[fields.length - 1] === undefined; - - case MemoryColumn.AggregationMode.MAX: - default: - // All fields are relevant. - return fields.every(function(field) { return field === undefined; }); - } - }, - - /** - * Get the color of the given fields formatted by this column. At least one - * field relevant for the current aggregation mode is guaranteed to be - * defined. - */ - color: function(fields, contexts) { - return undefined; - }, - - /** - * Format an arbitrary number of fields. At least one field relevant for - * the current aggregation mode is guaranteed to be defined. - */ - formatFields: function(fields) { - if (fields.length === 1) - return this.formatSingleField(fields[0]); - else - return this.formatMultipleFields(fields); - }, - - /** - * Format a single defined field. - * - * This method is intended to be overriden by field type specific columns - * (e.g. show '1.0 KiB' instead of '1024' for ScalarNumeric(s) representing - * bytes). - */ - formatSingleField: function(field) { - throw new Error('Not implemented'); - }, - - /** - * Format multiple fields. At least one field relevant for the current - * aggregation mode is guaranteed to be defined. - * - * The aggregation mode specializations of this method (e.g. - * formatMultipleFieldsDiff) are intended to be overriden by field type - * specific columns. - */ - formatMultipleFields: function(fields) { - switch (this.aggregationMode) { - case MemoryColumn.AggregationMode.DIFF: - return this.formatMultipleFieldsDiff( - fields[0], fields[fields.length - 1]); - - case MemoryColumn.AggregationMode.MAX: - return this.formatMultipleFieldsMax(fields); - - default: - return tr.ui.b.createSpan({ - textContent: '(unsupported aggregation mode)', - italic: true - }); - } - }, - - formatMultipleFieldsDiff: function(firstField, lastField) { - throw new Error('Not implemented'); - }, - - formatMultipleFieldsMax: function(fields) { - return this.formatSingleField(this.getMaxField(fields)); - }, - - cmp: function(rowA, rowB) { - var fieldsA = this.fields(rowA); - var fieldsB = this.fields(rowB); - - // Sanity check. - if (fieldsA !== undefined && fieldsB !== undefined && - fieldsA.length !== fieldsB.length) - throw new Error('Different number of fields'); - - // Handle empty fields. - var undefinedA = this.hasAllRelevantFieldsUndefined(fieldsA); - var undefinedB = this.hasAllRelevantFieldsUndefined(fieldsB); - if (undefinedA && undefinedB) - return 0; - if (undefinedA) - return -1; - if (undefinedB) - return 1; - - return this.compareFields(fieldsA, fieldsB); - }, - - /** - * Compare a pair of single or multiple fields. At least one field relevant - * for the current aggregation mode is guaranteed to be defined in each of - * the two lists. - */ - compareFields: function(fieldsA, fieldsB) { - if (fieldsA.length === 1) - return this.compareSingleFields(fieldsA[0], fieldsB[0]); - else - return this.compareMultipleFields(fieldsA, fieldsB); - }, - - /** - * Compare a pair of single defined fields. - * - * This method is intended to be overriden by field type specific columns. - */ - compareSingleFields: function(fieldA, fieldB) { - throw new Error('Not implemented'); - }, - - /** - * Compare a pair of multiple fields. At least one field relevant for the - * current aggregation mode is guaranteed to be defined in each of the two - * lists. - * - * The aggregation mode specializations of this method (e.g. - * compareMultipleFieldsDiff) are intended to be overriden by field type - * specific columns. - */ - compareMultipleFields: function(fieldsA, fieldsB) { - switch (this.aggregationMode) { - case MemoryColumn.AggregationMode.DIFF: - return this.compareMultipleFieldsDiff( - fieldsA[0], fieldsA[fieldsA.length - 1], - fieldsB[0], fieldsB[fieldsB.length - 1]); - - case MemoryColumn.AggregationMode.MAX: - return this.compareMultipleFieldsMax(fieldsA, fieldsB); - - default: - return 0; - } - }, - - compareMultipleFieldsDiff: function(firstFieldA, lastFieldA, firstFieldB, - lastFieldB) { - throw new Error('Not implemented'); - }, - - compareMultipleFieldsMax: function(fieldsA, fieldsB) { - return this.compareSingleFields( - this.getMaxField(fieldsA), this.getMaxField(fieldsB)); - }, - - getMaxField: function(fields) { - return fields.reduce(function(accumulator, field) { - if (field === undefined) - return accumulator; - if (accumulator === undefined || - this.compareSingleFields(field, accumulator) > 0) { - return field; - } - return accumulator; - }.bind(this), undefined); - }, - - addInfos: function(fields, contexts, infos) { - // No generic infos. - }, - - getImportance: function(importanceRules) { - if (importanceRules.length === 0) - return 0; - - // Find the first matching rule. - var matchingRule = - MemoryColumn.findMatchingRule(this.name, importanceRules); - if (matchingRule !== undefined) - return matchingRule.importance; - - // No matching rule. Return lower importance than all rules. - var minImportance = importanceRules[0].importance; - for (var i = 1; i < importanceRules.length; i++) - minImportance = Math.min(minImportance, importanceRules[i].importance); - return minImportance - 1; - } - }; - - /** - * @constructor - */ - function StringMemoryColumn(name, cellPath, aggregationMode) { - MemoryColumn.call(this, name, cellPath, aggregationMode); - } - - StringMemoryColumn.prototype = { - __proto__: MemoryColumn.prototype, - - formatSingleField: function(string) { - return string; - }, - - formatMultipleFieldsDiff: function(firstString, lastString) { - if (firstString === undefined) { - // String was added ("+NEW_VALUE" in red). - var spanEl = tr.ui.b.createSpan({color: 'red'}); - spanEl.appendChild(tr.ui.b.asHTMLOrTextNode('+')); - spanEl.appendChild(tr.ui.b.asHTMLOrTextNode( - this.formatSingleField(lastString))); - return spanEl; - } else if (lastString === undefined) { - // String was removed ("-OLD_VALUE" in green). - var spanEl = tr.ui.b.createSpan({color: 'green'}); - spanEl.appendChild(tr.ui.b.asHTMLOrTextNode('-')); - spanEl.appendChild(tr.ui.b.asHTMLOrTextNode( - this.formatSingleField(firstString))); - return spanEl; - } else if (firstString === lastString) { - // String didn't change ("VALUE" with unchanged color). - return this.formatSingleField(firstString); - } else { - // String changed ("OLD_VALUE -> NEW_VALUE" in orange). - var spanEl = tr.ui.b.createSpan({color: 'DarkOrange'}); - spanEl.appendChild(tr.ui.b.asHTMLOrTextNode( - this.formatSingleField(firstString))); - spanEl.appendChild(tr.ui.b.asHTMLOrTextNode( - ' ' + RIGHTWARDS_ARROW + ' ')); - spanEl.appendChild(tr.ui.b.asHTMLOrTextNode( - this.formatSingleField(lastString))); - return spanEl; - } - }, - - compareSingleFields: function(stringA, stringB) { - return COLLATOR.compare(stringA, stringB); - }, - - compareMultipleFieldsDiff: function(firstStringA, lastStringA, firstStringB, - lastStringB) { - // If one of the strings was added (and the other one wasn't), mark the - // corresponding diff as greater. - if (firstStringA === undefined && firstStringB !== undefined) - return 1; - if (firstStringA !== undefined && firstStringB === undefined) - return -1; - - // If both strings were added, compare the last values (greater last - // value implies greater diff). - if (firstStringA === undefined && firstStringB === undefined) - return this.compareSingleFields(lastStringA, lastStringB); - - // If one of the strings was removed (and the other one wasn't), mark the - // corresponding diff as lower. - if (lastStringA === undefined && lastStringB !== undefined) - return -1; - if (lastStringA !== undefined && lastStringB === undefined) - return 1; - - // If both strings were removed, compare the first values (greater first - // value implies smaller (!) diff). - if (lastStringA === undefined && lastStringB === undefined) - return this.compareSingleFields(firstStringB, firstStringA); - - var areStringsAEqual = firstStringA === lastStringA; - var areStringsBEqual = firstStringB === lastStringB; - - // Consider diffs of strings that did not change to be smaller than diffs - // of strings that did change. - if (areStringsAEqual && areStringsBEqual) - return 0; - if (areStringsAEqual) - return -1; - if (areStringsBEqual) - return 1; - - // Both strings changed. We are unable to determine the ordering of the - // diffs. - return 0; - } - }; - - /** - * @constructor - */ - function NumericMemoryColumn(name, cellPath, aggregationMode) { - MemoryColumn.call(this, name, cellPath, aggregationMode); - } - - // Avoid tiny positive/negative diffs (displayed in the UI as '+0.0 B' and - // '-0.0 B') due to imprecise floating-point arithmetic by treating all diffs - // within the (-DIFF_EPSILON, DIFF_EPSILON) range as zeros. - NumericMemoryColumn.DIFF_EPSILON = 0.0001; - - NumericMemoryColumn.prototype = { - __proto__: MemoryColumn.prototype, - - align: tr.ui.b.TableFormat.ColumnAlignment.RIGHT, - - aggregateCells: function(row, subRows) { - var subRowCells = subRows.map(this.cell, this); - - // Determine if there is at least one defined numeric in the sub-row - // cells and the timestamp count. - var hasDefinedSubRowNumeric = false; - var timestampCount = undefined; - subRowCells.forEach(function(subRowCell) { - if (subRowCell === undefined) - return; - - var subRowNumerics = subRowCell.fields; - if (subRowNumerics === undefined) - return; - - if (timestampCount === undefined) - timestampCount = subRowNumerics.length; - else if (timestampCount !== subRowNumerics.length) - throw new Error('Sub-rows have different numbers of timestamps'); - - if (hasDefinedSubRowNumeric) - return; // Avoid unnecessary traversals of the numerics. - hasDefinedSubRowNumeric = subRowNumerics.some(function(numeric) { - return numeric !== undefined; - }); - }); - if (!hasDefinedSubRowNumeric) - return; // No numeric to aggregate. - - // Get or create the row cell. - var cellPath = this.cellPath; - var rowCell = row; - for (var i = 0; i < cellPath.length; i++) { - var nextStepName = cellPath[i]; - var nextStep = rowCell[nextStepName]; - if (nextStep === undefined) { - if (i < cellPath.length - 1) - nextStep = {}; - else - nextStep = new MemoryCell(undefined); - rowCell[nextStepName] = nextStep; - } - rowCell = nextStep; - } - if (rowCell.fields === undefined) { - rowCell.fields = new Array(timestampCount); - } else if (rowCell.fields.length !== timestampCount) { - throw new Error( - 'Row has a different number of timestamps than sub-rows'); - } - - for (var i = 0; i < timestampCount; i++) { - if (rowCell.fields[i] !== undefined) - continue; - rowCell.fields[i] = tr.model.MemoryAllocatorDump.aggregateNumerics( - subRowCells.map(function(subRowCell) { - if (subRowCell === undefined || subRowCell.fields === undefined) - return undefined; - return subRowCell.fields[i]; - })); - } - }, - - formatSingleField: function(numeric) { - var formattingContext = this.getFormattingContext(numeric.unit); - var config = formattingContext !== undefined ? - { context: formattingContext } : undefined; - return tr.v.ui.createScalarSpan(numeric, config); - }, - - getFormattingContext: function(unit) { - return undefined; - }, - - formatMultipleFieldsDiff: function(firstNumeric, lastNumeric) { - return this.formatSingleField( - this.getDiffField_(firstNumeric, lastNumeric)); - }, - - compareSingleFields: function(numericA, numericB) { - return numericA.value - numericB.value; - }, - - compareMultipleFieldsDiff: function(firstNumericA, lastNumericA, - firstNumericB, lastNumericB) { - return this.getDiffFieldValue_(firstNumericA, lastNumericA) - - this.getDiffFieldValue_(firstNumericB, lastNumericB); - }, - - getDiffField_: function(firstNumeric, lastNumeric) { - var definedNumeric = firstNumeric || lastNumeric; - return new tr.v.ScalarNumeric(definedNumeric.unit.correspondingDeltaUnit, - this.getDiffFieldValue_(firstNumeric, lastNumeric)); - }, - - getDiffFieldValue_: function(firstNumeric, lastNumeric) { - var firstValue = firstNumeric === undefined ? 0 : firstNumeric.value; - var lastValue = lastNumeric === undefined ? 0 : lastNumeric.value; - var diff = lastValue - firstValue; - return Math.abs(diff) < NumericMemoryColumn.DIFF_EPSILON ? 0 : diff; - } - }; - - /** - * @constructor - */ - function MemoryCell(fields) { - this.fields = fields; - } - - MemoryCell.extractFields = function(cell) { - if (cell === undefined) - return undefined; - return cell.fields; - }; - - /** Limit for the number of sub-rows for recursive table row expansion. */ - var RECURSIVE_EXPANSION_MAX_VISIBLE_ROW_COUNT = 10; - - function expandTableRowsRecursively(table) { - var currentLevelRows = table.tableRows; - var totalVisibleRowCount = currentLevelRows.length; - - while (currentLevelRows.length > 0) { - // Calculate the total number of sub-rows on the current level. - var nextLevelRowCount = 0; - currentLevelRows.forEach(function(currentLevelRow) { - var subRows = currentLevelRow.subRows; - if (subRows === undefined || subRows.length === 0) - return; - nextLevelRowCount += subRows.length; - }); - - // Determine whether expanding all rows on the current level would cause - // the total number of visible rows go over the limit. - if (totalVisibleRowCount + nextLevelRowCount > - RECURSIVE_EXPANSION_MAX_VISIBLE_ROW_COUNT) { - break; - } - - // Expand all rows on the current level and gather their sub-rows. - var nextLevelRows = new Array(nextLevelRowCount); - var nextLevelRowIndex = 0; - currentLevelRows.forEach(function(currentLevelRow) { - var subRows = currentLevelRow.subRows; - if (subRows === undefined || subRows.length === 0) - return; - table.setExpandedForTableRow(currentLevelRow, true); - subRows.forEach(function(subRow) { - nextLevelRows[nextLevelRowIndex++] = subRow; - }); - }); - - // Update the total number of visible rows and progress to the next level. - totalVisibleRowCount += nextLevelRowCount; - currentLevelRows = nextLevelRows; - } - } - - function aggregateTableRowCellsRecursively(row, columns, opt_predicate) { - var subRows = row.subRows; - if (subRows === undefined || subRows.length === 0) - return; - - subRows.forEach(function(subRow) { - aggregateTableRowCellsRecursively(subRow, columns, opt_predicate); - }); - - if (opt_predicate === undefined || opt_predicate(row.contexts)) - aggregateTableRowCells(row, subRows, columns); - } - - function aggregateTableRowCells(row, subRows, columns) { - columns.forEach(function(column) { - if (!(column instanceof MemoryColumn)) - return; - column.aggregateCells(row, subRows); - }); - } - - function createCells(timeToValues, valueFieldsGetter, opt_this) { - opt_this = opt_this || this; - var fieldNameToFields = tr.b.invertArrayOfDicts( - timeToValues, valueFieldsGetter, opt_this); - return tr.b.mapItems(fieldNameToFields, function(fieldName, fields) { - return new tr.ui.analysis.MemoryCell(fields); - }); - } - - function createWarningInfo(message) { - return { - message: message, - icon: String.fromCharCode(9888), - color: 'red' - }; - } - - // TODO(petrcermak): Use a context manager instead - // (https://github.com/catapult-project/catapult/issues/2420). - function DetailsNumericMemoryColumn(name, cellPath, aggregationMode) { - NumericMemoryColumn.call(this, name, cellPath, aggregationMode); - } - - DetailsNumericMemoryColumn.prototype = { - __proto__: NumericMemoryColumn.prototype, - - getFormattingContext: function(unit) { - if (unit.baseUnit === tr.v.Unit.byName.sizeInBytes) - return { unitPrefix: tr.v.UnitScale.Binary.KIBI }; - return undefined; - } - }; - - return { - TitleColumn: TitleColumn, - MemoryColumn: MemoryColumn, - StringMemoryColumn: StringMemoryColumn, - NumericMemoryColumn: NumericMemoryColumn, - MemoryCell: MemoryCell, - expandTableRowsRecursively: expandTableRowsRecursively, - aggregateTableRowCellsRecursively: aggregateTableRowCellsRecursively, - aggregateTableRowCells: aggregateTableRowCells, - createCells: createCells, - createWarningInfo: createWarningInfo, - DetailsNumericMemoryColumn: DetailsNumericMemoryColumn - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/memory_dump_sub_view_util_test.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/memory_dump_sub_view_util_test.html deleted file mode 100644 index 3a4350ec276..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/memory_dump_sub_view_util_test.html +++ /dev/null @@ -1,1218 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/iteration_helpers.html"> -<link rel="import" - href="/tracing/ui/analysis/memory_dump_sub_view_test_utils.html"> -<link rel="import" href="/tracing/ui/analysis/memory_dump_sub_view_util.html"> -<link rel="import" href="/tracing/ui/base/dom_helpers.html"> -<link rel="import" href="/tracing/ui/base/table.html"> -<link rel="import" href="/tracing/value/numeric.html"> -<link rel="import" href="/tracing/value/unit.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var TitleColumn = tr.ui.analysis.TitleColumn; - var MemoryColumn = tr.ui.analysis.MemoryColumn; - var AggregationMode = MemoryColumn.AggregationMode; - var StringMemoryColumn = tr.ui.analysis.StringMemoryColumn; - var NumericMemoryColumn = tr.ui.analysis.NumericMemoryColumn; - var MemoryCell = tr.ui.analysis.MemoryCell; - var expandTableRowsRecursively = tr.ui.analysis.expandTableRowsRecursively; - var aggregateTableRowCells = tr.ui.analysis.aggregateTableRowCells; - var aggregateTableRowCellsRecursively = - tr.ui.analysis.aggregateTableRowCellsRecursively; - var ScalarNumeric = tr.v.ScalarNumeric; - var sizeInBytes_smallerIsBetter = - tr.v.Unit.byName.sizeInBytes_smallerIsBetter; - var checkSizeNumericFields = tr.ui.analysis.checkSizeNumericFields; - var checkNumericFields = tr.ui.analysis.checkNumericFields; - var checkStringFields = tr.ui.analysis.checkStringFields; - var createCells = tr.ui.analysis.createCells; - var createWarningInfo = tr.ui.analysis.createWarningInfo; - - function checkPercent(string, expectedPercent) { - assert.equal(Number(string.slice(0, -1)), expectedPercent); - assert.equal(string.slice(-1), '%'); - } - - function checkMemoryColumnFieldFormat(test, column, fields, - expectedTextContent, opt_expectedColor) { - var value = column.formatMultipleFields(fields); - if (expectedTextContent === undefined) { - assert.strictEqual(value, ''); - assert.isUndefined(opt_expectedColor); // Test sanity check. - return; - } - - var node = tr.ui.b.asHTMLOrTextNode(value); - var spanEl = document.createElement('span'); - spanEl.appendChild(node); - test.addHTMLOutput(spanEl); - - assert.strictEqual(node.textContent, expectedTextContent); - if (opt_expectedColor === undefined) - assert.notInstanceOf(node, HTMLElement); - else - assert.strictEqual(node.style.color, opt_expectedColor); - } - - function checkCompareFieldsEqual(column, fieldValuesA, fieldValuesB) { - assert.strictEqual(column.compareFields(fieldValuesA, fieldValuesB), 0); - } - - function checkCompareFieldsLess(column, fieldValuesA, fieldValuesB) { - assert.isBelow(column.compareFields(fieldValuesA, fieldValuesB), 0); - assert.isAbove(column.compareFields(fieldValuesB, fieldValuesA), 0); - } - - function checkNumericMemoryColumnFieldFormat(test, column, fieldValues, unit, - expectedValue) { - var value = column.formatMultipleFields( - buildScalarCell(unit, fieldValues).fields); - if (expectedValue === undefined) { - assert.equal(value, ''); - assert.isUndefined(expectedUnits); // Test sanity check. - return; - } - - test.addHTMLOutput(value); - assert.equal(value.tagName, 'TR-V-UI-SCALAR-SPAN'); - assert.equal(value.value, expectedValue); - assert.equal(value.unit, unit); - } - - function buildScalarCell(unit, values) { - return new MemoryCell(values.map(function(value) { - if (value === undefined) - return undefined; - return new ScalarNumeric(unit, value); - })); - } - - function buildTestRows() { - return [ - { - title: 'Row 1', - fields: { - 'cpu_temperature': new MemoryCell(['below zero', 'absolute zero']) - }, - subRows: [ - { - title: 'Row 1A', - fields: { - 'page_size': buildScalarCell(sizeInBytes_smallerIsBetter, - [1024, 1025]) - } - }, - { - title: 'Row 1B', - fields: { - 'page_size': buildScalarCell(sizeInBytes_smallerIsBetter, - [512, 513]), - 'mixed': new MemoryCell(['0.01', '0.10']), - 'mixed2': new MemoryCell([ - new ScalarNumeric(tr.v.Unit.byName.powerInWatts, 2.43e18), - new ScalarNumeric(tr.v.Unit.byName.powerInWatts, 0.5433) - ]) - } - } - ] - }, - { - title: 'Row 2', - fields: { - 'cpu_temperature': undefined, - 'mixed': buildScalarCell(tr.v.Unit.byName.timeDurationInMs, - [0.99, 0.999]) - } - } - ]; - } - - function checkMemoryColumn(column, expectedName, expectedTitle, - expectedAggregationMode, testRow, expectedCell, expectedType) { - assert.strictEqual(column.name, expectedName); - if (typeof expectedTitle === 'function') - expectedTitle(column.title); - else - assert.strictEqual(column.title, expectedTitle); - assert.strictEqual(column.aggregationMode, expectedAggregationMode); - assert.strictEqual(column.cell(testRow), expectedCell); - assert.instanceOf(column, expectedType); - } - - function checkCellValue( - test, value, expectedText, expectedColor, opt_expectedInfos) { - var expectedInfos = opt_expectedInfos || []; - assert.lengthOf(value.childNodes, 1 + expectedInfos.length); - assert.strictEqual(value.style.color, expectedColor); - if (typeof expectedText === 'string') - assert.strictEqual(value.childNodes[0].textContent, expectedText); - else - expectedText(value.childNodes[0]); - for (var i = 0; i < expectedInfos.length; i++) { - var expectedInfo = expectedInfos[i]; - var infoEl = value.childNodes[i + 1]; - assert.strictEqual(infoEl.textContent, expectedInfo.icon); - assert.strictEqual(infoEl.title, expectedInfo.message); - assert.strictEqual(infoEl.style.color, expectedInfo.color || ''); - } - test.addHTMLOutput(value); - } - - function sizeSpanMatcher( - expectedValue, opt_expectedIsDelta, opt_expectedContext) { - return function(element) { - assert.strictEqual(element.tagName, 'TR-V-UI-SCALAR-SPAN'); - assert.strictEqual(element.value, expectedValue); - assert.strictEqual(element.unit, opt_expectedIsDelta ? - tr.v.Unit.byName.sizeInBytesDelta_smallerIsBetter : - tr.v.Unit.byName.sizeInBytes_smallerIsBetter); - assert.deepEqual(element.context, opt_expectedContext); - }; - } - - test('checkTitleColumn_value', function() { - var column = new TitleColumn('column_title'); - assert.equal(column.title, 'column_title'); - assert.isFalse(column.supportsCellSelection); - - var row = {title: 'undefined', contexts: undefined}; - assert.equal(column.formatTitle(row), 'undefined'); - assert.equal(column.value(row), 'undefined'); - - var row = {title: 'constant', contexts: [{}, {}, {}, {}]}; - assert.equal(column.formatTitle(row), 'constant'); - assert.equal(column.value(row), 'constant'); - - var row = {title: 'added', contexts: [undefined, undefined, undefined, {}]}; - assert.equal(column.formatTitle(row), 'added'); - var value = column.value(row); - assert.equal(value.textContent, '+++\u00A0added'); - assert.equal(value.style.color, 'red'); - - var row = {title: 'removed', contexts: [true, true, undefined, undefined]}; - assert.equal(column.formatTitle(row), 'removed'); - var value = column.value(row); - assert.equal(value.textContent, '---\u00A0removed'); - assert.equal(value.style.color, 'green'); - - var row = {title: 'flaky', contexts: [true, undefined, true, true]}; - assert.equal(column.formatTitle(row), 'flaky'); - var value = column.value(row); - assert.equal(value.textContent, 'flaky'); - assert.equal(value.style.color, 'purple'); - - var row = - {title: 'added-flaky', contexts: [undefined, {}, undefined, true]}; - assert.equal(column.formatTitle(row), 'added-flaky'); - var value = column.value(row); - assert.equal(value.textContent, '+++\u00A0added-flaky'); - assert.equal(value.style.color, 'purple'); - - var row = - {title: 'removed-flaky', contexts: [true, undefined, {}, undefined]}; - assert.equal(column.formatTitle(row), 'removed-flaky'); - var value = column.value(row); - assert.equal(value.textContent, '---\u00A0removed-flaky'); - assert.equal(value.style.color, 'purple'); - }); - - test('checkTitleColumn_cmp', function() { - var column = new TitleColumn('column_title'); - - assert.isBelow(column.cmp({title: 'a'}, {title: 'b'}), 0); - assert.equal(column.cmp({title: 'cc'}, {title: 'cc'}), 0); - assert.isAbove(column.cmp({title: '10'}, {title: '2'}), 0); - }); - - test('checkMemoryColumn_fromRows', function() { - function MockColumn0() { - MemoryColumn.apply(this, arguments); - } - MockColumn0.prototype = { - __proto__: MemoryColumn.prototype, - get title() { return 'MockColumn0'; } - }; - - function MockColumn1() { - MemoryColumn.apply(this, arguments); - } - MockColumn1.prototype = { - __proto__: MemoryColumn.prototype, - get title() { return 'MockColumn1'; } - }; - - function MockColumn2() { - MemoryColumn.apply(this, arguments); - } - MockColumn2.prototype = { - __proto__: MemoryColumn.prototype, - get title() { return 'MockColumn2'; } - }; - - var rules = [ - { - condition: /size/, - importance: 10, - columnConstructor: MockColumn0 - }, - { - condition: 'cpu_temperature', - importance: 0, - columnConstructor: MockColumn1 - }, - { - condition: 'unmatched', - importance: -1, - get columnConstructor() { - throw new Error('The constructor should never be retrieved'); - } - }, - { - importance: 1, - columnConstructor: MockColumn2 - } - ]; - - var rows = buildTestRows(); - var columns = MemoryColumn.fromRows(rows, 'fields', AggregationMode.MAX, - rules); - assert.lengthOf(columns, 4); - - var pageSizeColumn = columns[0]; - checkMemoryColumn(pageSizeColumn, 'page_size', 'MockColumn0', - AggregationMode.MAX, {fields: {page_size: 'large'}}, 'large', - MockColumn0); - - var mixedColumn = columns[1]; - checkMemoryColumn(mixedColumn, 'mixed', 'MockColumn2', AggregationMode.MAX, - {fields: {mixed: 89}}, 89, MockColumn2); - - var mixed2Column = columns[2]; - checkMemoryColumn(mixed2Column, 'mixed2', 'MockColumn2', - AggregationMode.MAX, {fields: {mixed2: 'invalid'}}, 'invalid', - MemoryColumn); - - var cpuTemperatureColumn = columns[3]; - checkMemoryColumn(cpuTemperatureColumn, 'cpu_temperature', 'MockColumn1', - AggregationMode.MAX, {fields: {cpu_temperature: 42}}, 42, MockColumn1); - }); - - test('checkMemoryColumn_spaceEqually', function() { - // Zero columns. - var columns = []; - MemoryColumn.spaceEqually(columns); - - // One column. - var columns = [ - { - title: 'First Column', - value: function(row) { return row.firstData; } - } - ]; - MemoryColumn.spaceEqually(columns); - checkPercent(columns[0].width, 100); - - // Two columns. - var columns = [ - { - title: 'First Column', - value: function(row) { return row.firstData; } - }, - { - title: 'Second Column', - value: function(row) { return row.firstData; } - } - ]; - MemoryColumn.spaceEqually(columns); - checkPercent(columns[0].width, 50); - checkPercent(columns[1].width, 50); - }); - - test('checkMemoryColumn_instantiate', function() { - var c = new MemoryColumn('test_column', ['x'], AggregationMode.MAX); - assert.equal(c.name, 'test_column'); - assert.equal(c.title, 'test_column'); - assert.equal(c.cell({x: 95}), 95); - assert.isUndefined(c.width); - assert.isUndefined(c.color()); - }); - - test('checkMemoryColumn_cell', function() { - var c = new MemoryColumn('test_column', ['a', 'b'], AggregationMode.MAX); - var cell = new MemoryCell(undefined); - - assert.isUndefined(c.cell(undefined)); - assert.isUndefined(c.cell({b: cell})); - assert.isUndefined(c.cell({a: {c: cell}})); - assert.strictEqual(c.cell({a: {b: cell, c: 42}}), cell); - }); - - test('checkMemoryColumn_fields', function() { - var c = new MemoryColumn('test_column', ['x'], - AggregationMode.MAX); - - // Undefined cell or field inside cell. - assert.isUndefined(c.fields({})); - assert.isUndefined(c.fields({x: new MemoryCell(undefined)})); - - // Defined field(s) inside cell. - var field1 = new ScalarNumeric(tr.v.Unit.byName.powerInWatts, 1013.25); - var field2 = new ScalarNumeric(tr.v.Unit.byName.powerInWatts, 1065); - var row1 = {x: new MemoryCell([field1])}; - var row2 = {x: new MemoryCell([field1, field2])}; - assert.deepEqual(c.fields(row1), [field1]); - assert.deepEqual(c.fields(row2), [field1, field2]); - }); - - test('checkMemoryColumn_hasAllRelevantFieldsUndefined', function() { - // Single field. - var c1 = new MemoryColumn('single_column', ['x'], - undefined /* aggregation mode */); - assert.isTrue(c1.hasAllRelevantFieldsUndefined([undefined])); - assert.isFalse(c1.hasAllRelevantFieldsUndefined( - [new ScalarNumeric(sizeInBytes_smallerIsBetter, 16)])); - - // Multiple fields, diff aggregation mode. - var c2 = new MemoryColumn('diff_column', ['x'], - AggregationMode.DIFF); - assert.isTrue(c2.hasAllRelevantFieldsUndefined([undefined, undefined])); - assert.isTrue(c2.hasAllRelevantFieldsUndefined( - [undefined, undefined, undefined])); - assert.isTrue(c2.hasAllRelevantFieldsUndefined( - [undefined, new ScalarNumeric(sizeInBytes_smallerIsBetter, 16), - undefined])); - assert.isFalse(c2.hasAllRelevantFieldsUndefined( - [undefined, new ScalarNumeric(sizeInBytes_smallerIsBetter, 32)])); - assert.isFalse(c2.hasAllRelevantFieldsUndefined( - [new ScalarNumeric(sizeInBytes_smallerIsBetter, 32), undefined, - undefined])); - assert.isFalse(c2.hasAllRelevantFieldsUndefined([ - new ScalarNumeric(sizeInBytes_smallerIsBetter, 16), - undefined, - new ScalarNumeric(sizeInBytes_smallerIsBetter, 32)])); - - // Multiple fields, max aggregation mode. - var c3 = new MemoryColumn('max_column', ['x'], - AggregationMode.MAX); - assert.isTrue(c3.hasAllRelevantFieldsUndefined([undefined, undefined])); - assert.isTrue(c3.hasAllRelevantFieldsUndefined( - [undefined, undefined, undefined])); - assert.isFalse(c3.hasAllRelevantFieldsUndefined( - [undefined, new ScalarNumeric(sizeInBytes_smallerIsBetter, 16), - undefined])); - assert.isFalse(c3.hasAllRelevantFieldsUndefined( - [undefined, new ScalarNumeric(sizeInBytes_smallerIsBetter, 32)])); - assert.isFalse(c3.hasAllRelevantFieldsUndefined([ - new ScalarNumeric(sizeInBytes_smallerIsBetter, 32), - undefined, - new ScalarNumeric(sizeInBytes_smallerIsBetter, 16)])); - }); - - test('checkMemoryColumn_value_allFieldsUndefined', function() { - var c1 = new MemoryColumn('no_color', ['x'], - AggregationMode.MAX); - var c2 = new MemoryColumn('color', ['x'], - AggregationMode.DIFF); - Object.defineProperty(c2, 'color', { - get: function() { - throw new Error('The color should never be retrieved'); - } - }); - - // Infos should be completely ignored. - c1.addInfos = c2.addInfos = function() { - throw new Error('This method should never be called'); - }; - - [c1, c2].forEach(function(c) { - assert.equal(c.value({}), ''); - assert.equal(c.value({x: new MemoryCell(undefined)}), ''); - assert.equal(c.value({x: new MemoryCell([undefined])}), ''); - assert.equal(c.value({x: new MemoryCell([undefined, undefined])}), ''); - }); - - // Diff should only take into account the first and last field value. - assert.equal(c2.value({x: new MemoryCell( - [undefined, new ScalarNumeric(sizeInBytes_smallerIsBetter, 16), - undefined])}), ''); - }); - - test('checkMemoryColumn_getImportance', function() { - var c = new NumericMemoryColumn('test_column', ['x']); - - var rules1 = []; - assert.equal(c.getImportance(rules1), 0); - - var rules2 = [ - { - condition: 'test', - importance: 4 - }, - { - condition: /test$/, - importance: 2 - } - ]; - assert.equal(c.getImportance(rules2), 1); - - var rules3 = [ - { - condition: 'test_column', - importance: 10 - }, - { - importance: 5 - } - ]; - assert.equal(c.getImportance(rules3), 10); - - var rules4 = [ - { - condition: 'test_column2', - importance: 8 - }, - { - condition: /column/, - importance: 12 - } - ]; - assert.equal(c.getImportance(rules4), 12); - }); - - test('checkMemoryColumn_nameMatchesCondition', function() { - var c = new NumericMemoryColumn('test_column', ['x']); - - assert.isTrue(MemoryColumn.nameMatchesCondition('test_column', undefined)); - - assert.isFalse(MemoryColumn.nameMatchesCondition('test_column', 'test')); - assert.isTrue( - MemoryColumn.nameMatchesCondition('test_column', 'test_column')); - assert.isFalse( - MemoryColumn.nameMatchesCondition('test_column', 'test_column2')); - - assert.isTrue(MemoryColumn.nameMatchesCondition('test_column', /test/)); - assert.isTrue( - MemoryColumn.nameMatchesCondition('test_column', /^[^_]*_[^_]*$/)); - assert.isFalse(MemoryColumn.nameMatchesCondition('test_column', /test$/)); - }); - - test('checkStringMemoryColumn_value_singleField', function() { - var c = new StringMemoryColumn('', ['x'], AggregationMode.MAX); - c.color = function(fields, contexts) { - if (fields[0] < '0') - return 'green'; - else if (contexts && contexts[0] % 2 === 0) - return 'red'; - else - return undefined; - }; - - var infos1 = [{ icon: '\u{1F648}', message: 'Some info', color: 'blue' }]; - var infos2 = [ - { icon: '\u{1F649}', message: 'Start', color: 'cyan' }, - { icon: '\u{1F64A}', message: 'Stop' } - ]; - c.addInfos = function(fields, contexts, infos) { - if (fields[0] < '0') - infos.push.apply(infos, infos1); - else if (contexts && contexts[0] % 2 === 0) - infos.push.apply(infos, infos2); - }; - - var row = {x: new MemoryCell(['123'])}; - assert.strictEqual(c.value(row), '123'); - - var row = {x: new MemoryCell(['-123']), contexts: [undefined]}; - checkCellValue(this, c.value(row), '-123', 'green', infos1); - - var row = {x: new MemoryCell(['123']), contexts: [42]}; - checkCellValue(this, c.value(row), '123', 'red', infos2); - }); - - test('checkStringMemoryColumn_value_multipleFields', function() { - var c1 = new StringMemoryColumn('test_column1', ['x'], - undefined /* aggregation mode */); - var c2 = new StringMemoryColumn('test_column2', ['x'], - AggregationMode.DIFF); - c2.color = function(fields, contexts) { - return '#009999'; - }; - var c3 = new StringMemoryColumn('test_column3', ['x'], - AggregationMode.MAX); - c3.color = function(fields, contexts) { - if (fields[0] < '0') - return 'green'; - else if (contexts && contexts[contexts.length - 1] % 2 === 0) - return 'red'; - else - return undefined; - }; - - var infos1 = [{ icon: '\u{1F648}', message: 'Some info', color: 'blue' }]; - var infos2 = [ - { icon: '\u{1F649}', message: 'Start', color: 'cyan' }, - { icon: '\u{1F64A}', message: 'Stop' } - ]; - c1.addInfos = c2.addInfos = c3.addInfos = - function(fields, contexts, infos) { - if (fields[0] < '0') - infos.push.apply(infos, infos1); - else if (contexts && contexts[contexts.length - 1] % 2 === 0) - infos.push.apply(infos, infos2); - }; - - var row = {x: new MemoryCell(['123', '456'])}; - checkCellValue(this, c1.value(row), '(unsupported aggregation mode)', ''); - checkCellValue(this, c2.value(row), '123 \u2192 456', 'rgb(0, 153, 153)'); - assert.strictEqual(c3.value(row), '456'); - - var row = { - x: new MemoryCell(['-123', undefined, '+123']), - contexts: [12, 14, undefined] - }; - checkCellValue(this, c1.value(row), '(unsupported aggregation mode)', '', - infos1); - checkCellValue(this, c2.value(row), '-123 \u2192 +123', 'rgb(0, 153, 153)', - infos1); - checkCellValue(this, c3.value(row), '+123', 'green', infos1); - - var row = { - x: new MemoryCell(['123', undefined, '456']), - contexts: [31, 7, -2] - }; - checkCellValue(this, c1.value(row), '(unsupported aggregation mode)', '', - infos2); - checkCellValue(this, c2.value(row), '123 \u2192 456', 'rgb(0, 153, 153)', - infos2); - checkCellValue(this, c3.value(row), '456', 'red', infos2); - }); - - test('checkStringMemoryColumn_formatSingleField', function() { - var c = new StringMemoryColumn('test_column', ['x'], - undefined /* aggregation mode */); - - assert.equal(c.formatSingleField('1024'), '1024'); - assert.equal(c.formatSingleField('~10'), '~10'); - }); - - test('checkStringMemoryColumn_formatMultipleFields_diff', function() { - var c = new StringMemoryColumn('test_column', ['x'], - AggregationMode.DIFF); - - // Added value. - checkMemoryColumnFieldFormat(this, c, [undefined, 'few'], '+few', 'red'); - checkMemoryColumnFieldFormat(this, c, [undefined, 64, 32], '+32', 'red'); - - // Removed value. - checkMemoryColumnFieldFormat(this, c, ['00', undefined], '-00', 'green'); - checkMemoryColumnFieldFormat(this, c, [1, undefined, 2, undefined], '-1', - 'green'); - - // Identical values. - checkMemoryColumnFieldFormat(this, c, ['Unchanged', 'Unchanged'], - 'Unchanged', undefined /* unchanged color (not an HTML element) */); - checkMemoryColumnFieldFormat(this, c, [16, 32, undefined, 64, 16], '16', - undefined /* unchanged color (not an HTML element) */); - - // Different values. - checkMemoryColumnFieldFormat(this, c, ['A', 'C', undefined, 'C', 'B'], - 'A \u2192 B', 'darkorange'); - checkMemoryColumnFieldFormat(this, c, [16, undefined, 64], '16 \u2192 64', - 'darkorange'); - }); - - test('checkStringMemoryColumn_formatMultipleFields_max', function() { - var c = new StringMemoryColumn('test_column', ['x'], - AggregationMode.MAX); - - // Different values. - checkMemoryColumnFieldFormat(this, c, ['A', 'B', 'A'], 'B', - undefined /* unchanged color (not an HTML element) */); - checkMemoryColumnFieldFormat(this, c, [16, 16, undefined, 17], '17', - undefined /* unchanged color (not an HTML element) */); - - // Identical values. - checkMemoryColumnFieldFormat(this, c, ['X', 'X'], 'X', - undefined /* unchanged color (not an HTML element) */); - checkMemoryColumnFieldFormat(this, c, [7, undefined, 7, undefined, 7], '7', - undefined /* unchanged color (not an HTML element) */); - }); - - test('checkStringMemoryColumn_compareSingleFields', function() { - var c = new StringMemoryColumn('test_column', ['x'], - undefined /* aggregation mode */); - - assert.isBelow(c.compareSingleFields( - new ScalarNumeric(sizeInBytes_smallerIsBetter, 2), - new ScalarNumeric(sizeInBytes_smallerIsBetter, 10)), 0); - assert.equal(c.compareSingleFields('equal', 'equal'), 0); - assert.isAbove(c.compareSingleFields('100', '99'), 0); - }); - - test('checkStringMemoryColumn_compareMultipleFields_diff', function() { - var c = new StringMemoryColumn('test_column', ['x'], - AggregationMode.DIFF); - - // One field was added. - checkCompareFieldsLess(c, [-10, 10], [undefined, 5]); - checkCompareFieldsLess(c, - [-100, undefined, undefined], [undefined, 4, 5]); - checkCompareFieldsLess(c, - [1, 2, 3, 4], [undefined, 'x', undefined, 'y']); - - // Both fields were added. - checkCompareFieldsEqual(c, - [undefined, 'C', undefined, 'A'], [undefined, 'B', 'D', 'A']); - checkCompareFieldsLess(c, [undefined, 1], [undefined, 2]); - checkCompareFieldsLess(c, [undefined, 6, 3], [undefined, 5, 4]); - - // One field was removed (neither was added). - checkCompareFieldsLess(c, ['B', undefined], ['A', 'A']); - checkCompareFieldsLess(c, - [5, undefined, undefined], [undefined, -5, -10]); - - // Both fields were removed (neither was added) - checkCompareFieldsEqual(c, ['T', 'A', undefined, undefined], - ['T', 'B', 'C', undefined]); - checkCompareFieldsLess(c, [5, undefined], [4, undefined]); - - // Neither field was added or removed. - checkCompareFieldsLess(c, ['BB', 'BB'], ['AA', 'CC']); - checkCompareFieldsEqual(c, [7, 8, 9], [6, 9, 10]); - checkCompareFieldsEqual(c, [5, undefined, 5], [4, 3, 4]); - }); - - test('checkStringMemoryColumn_compareMultipleFields_max', function() { - var c = new StringMemoryColumn('test_column', ['x'], - AggregationMode.MAX); - - // At least one field has multiple values. - checkCompareFieldsEqual(c, [0, 1, 3], [1, 3, 2]); - checkCompareFieldsLess(c, ['4', undefined, '4'], ['3', '4', '5']); - checkCompareFieldsLess(c, [3, 3, 3], [9, undefined, 10]); - - // Both fields have single values. - checkCompareFieldsEqual(c, - [undefined, 'ttt', undefined], ['ttt', 'ttt', undefined]); - checkCompareFieldsLess(c, [undefined, -1, undefined], [-2, -2, -2]); - checkCompareFieldsLess(c, ['Q', 'Q', undefined], ['X', undefined, 'X']); - }); - - test('checkStringMemoryColumn_cmp', function() { - var c = new StringMemoryColumn('test_column', ['x'], - AggregationMode.DIFF); - - // Cell (or the associated field) undefined in one or both rows. - assert.equal(c.cmp({}, {y: new MemoryCell([undefined])}), 0); - assert.equal(c.cmp({x: new MemoryCell(undefined)}, {}), 0); - assert.equal(c.cmp({x: new MemoryCell([undefined, undefined])}, {}), 0); - assert.isAbove(c.cmp({x: new MemoryCell(['negative'])}, {}), 0); - assert.isAbove(c.cmp({x: new MemoryCell(['negative'])}, - {x: new MemoryCell([undefined])}), 0); - assert.isBelow(c.cmp({}, {x: new MemoryCell(['positive'])}), 0); - assert.isBelow(c.cmp({x: new MemoryCell(undefined)}, - {x: new MemoryCell(['positive'])}), 0); - - // Single field. - assert.equal(c.cmp({x: new MemoryCell(['equal'])}, - {x: new MemoryCell(['equal'])}), 0); - assert.isAbove(c.cmp({x: new MemoryCell(['bigger'])}, - {x: new MemoryCell(['BIG'])}), 0); - assert.isBelow(c.cmp({x: new MemoryCell(['small'])}, - {x: new MemoryCell(['smaLL'])}), 0); - - // Multiple fields. - assert.isBelow(c.cmp( - {x: new MemoryCell(['MemoryColumn', 'supports*', undefined])}, - {x: new MemoryCell(['comparing', 'multiple', 'values :-)'])}), 0); - }); - - test('checkNumericMemoryColumn_value', function() { - var c = new NumericMemoryColumn('test_column', ['x'], - AggregationMode.DIFF); - c.color = function(fields, contexts) { - return '#009999'; - }; - var infos1 = [createWarningInfo('Attention!')]; - c.addInfos = function(fields, contexts, infos) { - infos.push.apply(infos, infos1); - }; - - // Undefined field values. - var row = {x: buildScalarCell(sizeInBytes_smallerIsBetter, - [undefined, 1, undefined])}; - assert.equal(c.value(row), ''); - - // Single field value. - var row = {x: buildScalarCell(sizeInBytes_smallerIsBetter, - [5.4975581e13 /* 50 TiB */])}; - checkCellValue(this, c.value(row), sizeSpanMatcher(5.4975581e13), - 'rgb(0, 153, 153)', infos1); - - // Multiple field values. - var row = { - x: buildScalarCell(sizeInBytes_smallerIsBetter, - [5.4975581e13 /* 50 TiB */, undefined, 2.1990233e13 /* 20 TiB */]) - }; - checkCellValue(this, c.value(row), - sizeSpanMatcher(-3.2985348e13, true /* opt_expectedIsDelta */), - 'rgb(0, 153, 153)', infos1); - - // With custom formatting context. - c.getFormattingContext = function(unit) { - assert.strictEqual(unit, - tr.v.Unit.byName.sizeInBytesDelta_smallerIsBetter); - return { minimumFractionDigits: 2 }; - }; - checkCellValue(this, c.value(row), - sizeSpanMatcher(-3.2985348e13, true /* opt_expectedIsDelta */, - { minimumFractionDigits: 2 }), - 'rgb(0, 153, 153)', infos1); - }); - - test('checkNumericMemoryColumn_formatSingleField', function() { - var c = new NumericMemoryColumn('non_bytes_column', ['x'], - undefined /* aggregation mode */); - var value = c.formatSingleField(new ScalarNumeric( - tr.v.Unit.byName.unitlessNumber_smallerIsBetter, 123)); - assert.equal(value.tagName, 'TR-V-UI-SCALAR-SPAN'); - assert.equal(value.value, 123); - assert.equal(value.unit, tr.v.Unit.byName.unitlessNumber_smallerIsBetter); - this.addHTMLOutput(value); - - var c = new NumericMemoryColumn('bytes_column', ['x'], - undefined /* aggregation mode */); - var value = c.formatSingleField(new ScalarNumeric( - sizeInBytes_smallerIsBetter, 456)); - assert.equal(value.tagName, 'TR-V-UI-SCALAR-SPAN'); - assert.equal(value.value, 456); - assert.equal(value.unit, tr.v.Unit.byName.sizeInBytes_smallerIsBetter); - this.addHTMLOutput(value); - }); - - test('checkNumericMemoryColumn_formatMultipleFields_diff', - function() { - var c = new NumericMemoryColumn('non_bytes_column', ['x'], - AggregationMode.DIFF); - checkNumericMemoryColumnFieldFormat(this, c, [1, 2, 3], - tr.v.Unit.byName.unitlessNumberDelta_smallerIsBetter, 2); - checkNumericMemoryColumnFieldFormat(this, c, [10, undefined], - tr.v.Unit.byName.unitlessNumberDelta_smallerIsBetter, -10); - checkNumericMemoryColumnFieldFormat(this, c, [undefined, 60, 0], - tr.v.Unit.byName.unitlessNumberDelta_smallerIsBetter, 0); - checkNumericMemoryColumnFieldFormat( - this, c, [2.71828, 2.71829] /* diff within epsilon */, - tr.v.Unit.byName.unitlessNumberDelta_smallerIsBetter, 0); - - var c = new NumericMemoryColumn('bytes_column', ['x'], - AggregationMode.DIFF); - checkNumericMemoryColumnFieldFormat(this, c, [1, 2, 3], - tr.v.Unit.byName.sizeInBytesDelta_smallerIsBetter, 2); - checkNumericMemoryColumnFieldFormat(this, c, [10, undefined], - tr.v.Unit.byName.sizeInBytesDelta_smallerIsBetter, -10); - checkNumericMemoryColumnFieldFormat(this, c, [undefined, 60, 0], - tr.v.Unit.byName.sizeInBytesDelta_smallerIsBetter, 0); - checkNumericMemoryColumnFieldFormat( - this, c, [1.41421, 1.41422] /* diff within epsilon */, - tr.v.Unit.byName.sizeInBytesDelta_smallerIsBetter, 0); - }); - - test('checkNumericMemoryColumn_formatMultipleFields_max', - function() { - var c = new NumericMemoryColumn('non_bytes_column', ['x'], - AggregationMode.MAX); - checkNumericMemoryColumnFieldFormat(this, c, [1, 2, 3], - tr.v.Unit.byName.unitlessNumber_smallerIsBetter, 3); - checkNumericMemoryColumnFieldFormat(this, c, [10, undefined], - tr.v.Unit.byName.unitlessNumber_smallerIsBetter, 10); - checkNumericMemoryColumnFieldFormat(this, c, [undefined, 60, 0], - tr.v.Unit.byName.unitlessNumber_smallerIsBetter, 60); - checkNumericMemoryColumnFieldFormat(this, c, [undefined, 10, 20, undefined], - tr.v.Unit.byName.unitlessNumber_smallerIsBetter, 20); - - var c = new NumericMemoryColumn('bytes_column', ['x'], - AggregationMode.MAX); - checkNumericMemoryColumnFieldFormat(this, c, [1, 2, 3], - tr.v.Unit.byName.sizeInBytes_smallerIsBetter, 3); - checkNumericMemoryColumnFieldFormat(this, c, [10, undefined], - tr.v.Unit.byName.sizeInBytes_smallerIsBetter, 10); - checkNumericMemoryColumnFieldFormat(this, c, [undefined, 60, 0], - tr.v.Unit.byName.sizeInBytes_smallerIsBetter, 60); - checkNumericMemoryColumnFieldFormat(this, c, [undefined, 10, 20, undefined], - tr.v.Unit.byName.sizeInBytes_smallerIsBetter, 20); - }); - - test('checkNumericMemoryColumn_cmp', function() { - var c = new NumericMemoryColumn('test_column', ['x'], - AggregationMode.DIFF); - - // Undefined field values. - assert.isAbove(c.cmp({x: buildScalarCell(sizeInBytes_smallerIsBetter, - [-9999999999])}, - {x: undefined}), 0); - assert.isBelow(c.cmp({x: new MemoryCell(undefined)}, - {x: buildScalarCell(sizeInBytes_smallerIsBetter, [748, 749])}), 0); - assert.equal(c.cmp({}, - {x: buildScalarCell(sizeInBytes_smallerIsBetter, - [undefined, undefined])}), 0); - - // Single field value. - assert.isBelow(c.cmp( - {x: buildScalarCell(sizeInBytes_smallerIsBetter, [16384])}, - {x: buildScalarCell(sizeInBytes_smallerIsBetter, [32768])}), 0); - - // Multiple field values. - assert.equal(c.cmp( - {x: buildScalarCell(sizeInBytes_smallerIsBetter, - [999, undefined, 1001])}, - {x: buildScalarCell(sizeInBytes_smallerIsBetter, - [undefined, 5, 2])}), 0); - }); - - test('checkNumericMemoryColumn_compareSingleFields', function() { - var c = new NumericMemoryColumn('test_column', ['x'], - undefined /* aggregation mode */); - - assert.isBelow(c.compareSingleFields( - new ScalarNumeric( - tr.v.Unit.byName.timeDurationInMs_smallerIsBetter, 99), - new ScalarNumeric( - tr.v.Unit.byName.timeDurationInMs_smallerIsBetter, 100)), 0); - assert.equal(c.compareSingleFields( - new ScalarNumeric(tr.v.Unit.byName.unitlessNumber, 0xEEE), - new ScalarNumeric(tr.v.Unit.byName.unitlessNumber, 0xEEE)), 0); - assert.isAbove(c.compareSingleFields( - new ScalarNumeric(sizeInBytes_smallerIsBetter, 10), - new ScalarNumeric(sizeInBytes_smallerIsBetter, 2)), 0); - }); - - test('checkNumericMemoryColumn_compareMultipleFields_diff', function() { - var c = new NumericMemoryColumn('test_column', ['x'], - AggregationMode.DIFF); - - assert.isBelow(c.compareMultipleFields( - buildScalarCell(sizeInBytes_smallerIsBetter, - [10000, 10001, 10002] /* diff +2 */).fields, - buildScalarCell(sizeInBytes_smallerIsBetter, - [5, 7, 8] /* diff +3 */).fields), 0); - assert.equal(c.compareMultipleFields( - buildScalarCell(tr.v.Unit.byName.timeDurationInMs_smallerIsBetter, - [4, undefined] /* diff -4 */).fields, - buildScalarCell(tr.v.Unit.byName.timeDurationInMs_smallerIsBetter, - [999, 995] /* diff -4 */).fields), 0); - assert.isAbove(c.compareMultipleFields( - buildScalarCell(sizeInBytes_smallerIsBetter, - [10, undefined, 12] /* diff +2 */).fields, - buildScalarCell(sizeInBytes_smallerIsBetter, - [11, 50, 12] /* diff +1 */).fields), 0); - assert.equal(c.compareMultipleFields( - buildScalarCell(tr.v.Unit.byName.powerInWatts_smallerIsBetter, - [17, undefined, 17] /* diff 0 */).fields, - buildScalarCell(tr.v.Unit.byName.powerInWatts_smallerIsBetter, - [undefined, 100, undefined] /* diff 0 */).fields), 0); - assert.equal(c.compareMultipleFields( - buildScalarCell(sizeInBytes_smallerIsBetter, - [3.14159, undefined, 3.14160] /* diff within epsilon */).fields, - buildScalarCell(sizeInBytes_smallerIsBetter, - [100, 100, 100] /* diff 0 */).fields), 0); - }); - - test('checkNumericMemoryColumn_compareMultipleFields_max', function() { - var c = new NumericMemoryColumn('test_column', ['x'], - AggregationMode.MAX); - - assert.isBelow(c.compareMultipleFields( - buildScalarCell(sizeInBytes_smallerIsBetter, - [10, undefined, 12]).fields, - buildScalarCell(sizeInBytes_smallerIsBetter, [11, 50, 12]).fields), 0); - assert.equal(c.compareMultipleFields( - buildScalarCell(tr.v.Unit.byName.timeDurationInMs_smallerIsBetter, - [999, undefined, -8888]).fields, - buildScalarCell(tr.v.Unit.byName.timeDurationInMs_smallerIsBetter, - [undefined, 999, undefined]).fields), 0); - assert.isAbove(c.compareMultipleFields( - buildScalarCell(sizeInBytes_smallerIsBetter, - [10000, 10001, 10002]).fields, - buildScalarCell(sizeInBytes_smallerIsBetter, [5, 7, 8]).fields), 0); - assert.isBelow(c.compareMultipleFields( - buildScalarCell(tr.v.Unit.byName.powerInWatts_smallerIsBetter, - [17, undefined, 17]).fields, - buildScalarCell(tr.v.Unit.byName.powerInWatts_smallerIsBetter, - [undefined, 100, undefined]).fields), 0); - }); - - test('checkNumericMemoryColumn_getDiffFieldValue', function() { - var c = new NumericMemoryColumn('test_column', ['x'], - AggregationMode.MAX); - function checkDiffValue(first, last, expectedDiffValue) { - var actualDiffValue = c.getDiffFieldValue_( - first === undefined ? undefined : - new ScalarNumeric(sizeInBytes_smallerIsBetter, first), - last === undefined ? undefined : - new ScalarNumeric(sizeInBytes_smallerIsBetter, last)); - assert.closeTo(actualDiffValue, expectedDiffValue, 1e-8); - } - - // Diff outside epsilon range. - checkDiffValue(0, 0.0002, 0.0002); - checkDiffValue(undefined, 0.0003, 0.0003); - checkDiffValue(0.3334, 0.3332, -0.0002); - checkDiffValue(0.0005, undefined, -0.0005); - - // Diff inside epsilon range. - checkDiffValue(5, 5.00009, 0); - checkDiffValue(undefined, 0.0000888, 0); - checkDiffValue(0.29999, 0.3, 0); - checkDiffValue(0.00009, undefined, 0); - checkDiffValue(0.777777, 0.777777, 0); - checkDiffValue(undefined, undefined, 0); - }); - - test('checkExpandTableRowsRecursively', function() { - var columns = [ - { - title: 'Single column', - value: function(row) { return row.data; }, - width: '100px' - } - ]; - - var rows = [ - { - data: 'allocated', - subRows: [ - { - data: 'v8', - subRows: [] - }, - { - data: 'oilpan', - subRows: [ - { - data: 'still_visible', - subRows: [ - { - data: 'not_visible_any_more' - } - ] - }, - { - data: 'also_visible' - } - ] - } - ] - }, - { - data: 'no_sub_rows' - }, - { - data: 'fragmentation', - subRows: [ - { - data: 'internal' - }, - { - data: 'external', - subRows: [ - { - data: 'unexpanded' - } - ] - } - ] - } - ]; - - var table = document.createElement('tr-ui-b-table'); - table.tableColumns = columns; - table.tableRows = rows; - table.rebuild(); - - expandTableRowsRecursively(table); - - function isExpanded(row) { return table.getExpandedForTableRow(row); } - - // Level 0 (3 rows) should be expanded (except for nodes which have no - // sub-rows). - assert.isTrue(isExpanded(rows[0] /* allocated */)); - assert.isFalse(isExpanded(rows[1] /* no_sub_rows */)); - assert.isTrue(isExpanded(rows[2] /* overhead */)); - - // Level 1 (4 rows) should be expanded (except for nodes which have no - // sub-rows). - assert.isFalse(isExpanded(rows[0].subRows[0] /* allocated/v8 */)); - assert.isTrue(isExpanded(rows[0].subRows[1] /* allocated/oilpan */)); - assert.isFalse(isExpanded(rows[2].subRows[0] /* fragmentation/internal */)); - assert.isTrue(isExpanded(rows[2].subRows[1] /* fragmentation/external */)); - - // Level 2 (3 rows) should not be expanded any more. - assert.isFalse(isExpanded( - rows[0].subRows[1].subRows[0] /* allocated/oilpan/still_visible */)); - assert.isFalse(isExpanded( - rows[0].subRows[1].subRows[1] /* allocated/oilpan/also_visible */)); - assert.isFalse(isExpanded( - rows[2].subRows[1].subRows[0] /* fragmentation/external/unexpanded */)); - }); - - test('checkMemoryCell_extractFields', function() { - assert.isUndefined(MemoryCell.extractFields(undefined)); - - assert.isUndefined(MemoryCell.extractFields(new MemoryCell(undefined))); - - var fields = [new ScalarNumeric(sizeInBytes_smallerIsBetter, 1024)]; - assert.strictEqual( - MemoryCell.extractFields(new MemoryCell(fields)), fields); - }); - - test('checkAggregateTableRowCellsRecursively', function() { - var row = { - testCells: { - a: buildScalarCell(sizeInBytes_smallerIsBetter, [17]) - }, - subRows: [ - { - // Intentionally no testCells. - subRows: [ - { - testCells: { - b: buildScalarCell(sizeInBytes_smallerIsBetter, [103]), - c: new MemoryCell(['should-not-propagate-upwards']), - d: buildScalarCell(sizeInBytes_smallerIsBetter, [-200]) - } - // Intentionally no subRows. - }, - { - testCells: {}, - subRows: [] - } - ], - contexts: ['skip-row-when-using-predicate'] - }, - { - testCells: { - b: buildScalarCell(sizeInBytes_smallerIsBetter, [20]), - a: buildScalarCell(sizeInBytes_smallerIsBetter, [13]), - e: buildScalarCell(sizeInBytes_smallerIsBetter, [-300]) - }, - contexts: ['don\'t-skip'] - } - ] - }; - - // Without a predicate. - var ca = new NumericMemoryColumn('column_a', ['testCells', 'a']); - var cb = new NumericMemoryColumn('column_b', ['testCells', 'b']); - var cc = new StringMemoryColumn('column_c', ['testCells', 'c']); - aggregateTableRowCellsRecursively(row, [ca, cb, cc]); - checkSizeNumericFields(row, ca, [17]); - checkSizeNumericFields(row, cb, [123]); - checkStringFields(row, cc, undefined); - - // With a predicate. - var cd = new NumericMemoryColumn('column_d', ['testCells', 'd']); - var ce = new NumericMemoryColumn('column_e', ['testCells', 'e']); - aggregateTableRowCellsRecursively(row, [cd, ce], function(contexts) { - return contexts === undefined || !contexts[0].startsWith('skip'); - }); - checkSizeNumericFields(row, cd, undefined); - checkSizeNumericFields(row, ce, [-300]); - }); - - test('checkAggregateTableRowCells', function() { - var row = { - // Intentionally no testCells. - otherCells: { - a: buildScalarCell(tr.v.Unit.byName.unitlessNumber, - [5, undefined, undefined]) - } - }; - var subRows = [ - { - testCells: { - a: buildScalarCell(sizeInBytes_smallerIsBetter, [1, 9]) - }, - subRows: [ - { - testCells: { - c: buildScalarCell(sizeInBytes_smallerIsBetter, [13]) - } - } - ] - }, - { - testCells: { - a: buildScalarCell(sizeInBytes_smallerIsBetter, [2, 17]), - b: buildScalarCell(sizeInBytes_smallerIsBetter, [5]) - }, - otherCells: { - a: buildScalarCell(tr.v.Unit.byName.unitlessNumber, - [153, undefined, 257]), - b: new MemoryCell(['field-should-not-propagate-upwards', '']) - } - } - ]; - - var cta = new NumericMemoryColumn('column_test_a', ['testCells', 'a']); - var ctb = new NumericMemoryColumn('column_test_b', ['testCells', 'b']); - var ctc = new NumericMemoryColumn('column_test_c', ['testCells', 'c']); - var coa = new NumericMemoryColumn('column_other_a', ['otherCells', 'a']); - var cob = new StringMemoryColumn('column_other_b', ['otherCells', 'b']); - - aggregateTableRowCells(row, subRows, [cta, ctb, ctc, coa, cob]); - - checkSizeNumericFields(row, cta, [3, 26]); - checkSizeNumericFields(row, ctb, [5]); - checkSizeNumericFields(row, ctc, undefined); - - checkNumericFields(row, coa, [5, undefined, 257], - tr.v.Unit.byName.unitlessNumber); - checkStringFields(row, cob, undefined); - }); - - test('checkCreateCells', function() { - var values = [ - { - a: 9, - b: 314 - }, - { - b: 159, - c: undefined - }, - undefined, - { - b: 265, - d: 0 - } - ]; - - var mockColumn = new MemoryColumn('', [], undefined); - - var cells = createCells(values, function(dict) { - var fields = {}; - tr.b.iterItems(dict, function(key, value) { - if (value === undefined) - return; - fields[key] = new ScalarNumeric(sizeInBytes_smallerIsBetter, value); - }); - return fields; - }); - assert.deepEqual(Object.keys(cells), ['a', 'b', 'd']); - checkSizeNumericFields( - cells.a, mockColumn, [9, undefined, undefined, undefined]); - checkSizeNumericFields(cells.b, mockColumn, [314, 159, undefined, 265]); - checkSizeNumericFields( - cells.d, mockColumn, [undefined, undefined, undefined, 0]); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/memory_dump_vm_regions_details_pane.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/memory_dump_vm_regions_details_pane.html deleted file mode 100644 index c16df525127..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/memory_dump_vm_regions_details_pane.html +++ /dev/null @@ -1,379 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/iteration_helpers.html"> -<link rel="import" href="/tracing/ui/analysis/memory_dump_sub_view_util.html"> -<link rel="import" href="/tracing/ui/analysis/stacked_pane.html"> -<link rel="import" href="/tracing/ui/base/table.html"> -<link rel="import" href="/tracing/value/numeric.html"> -<link rel="import" href="/tracing/value/unit.html"> - -<polymer-element name="tr-ui-a-memory-dump-vm-regions-details-pane" - extends="tr-ui-a-stacked-pane"> - <template> - <style> - :host { - display: flex; - flex-direction: column; - } - - #label { - flex: 0 0 auto; - padding: 8px; - - background-color: #eee; - border-bottom: 1px solid #8e8e8e; - border-top: 1px solid white; - - font-size: 15px; - font-weight: bold; - } - - #contents { - flex: 1 0 auto; - align-self: stretch; - font-size: 12px; - } - - #info_text { - padding: 8px; - color: #666; - font-style: italic; - text-align: center; - } - - #table { - display: none; /* Hide until memory dumps are set. */ - flex: 1 0 auto; - align-self: stretch; - } - </style> - <div id="label">Memory maps</div> - <div id="contents"> - <div id="info_text">No memory maps selected</div> - <tr-ui-b-table id="table"></tr-ui-b-table> - </div> - </template> -</polymer-element> -<script> -'use strict'; - -tr.exportTo('tr.ui.analysis', function() { - - var ScalarNumeric = tr.v.ScalarNumeric; - var sizeInBytes_smallerIsBetter = - tr.v.Unit.byName.sizeInBytes_smallerIsBetter; - - var CONSTANT_COLUMN_RULES = [ - { - condition: 'Start address', - importance: 0, - columnConstructor: tr.ui.analysis.StringMemoryColumn - } - ]; - - var VARIABLE_COLUMN_RULES = [ - { - condition: 'Virtual size', - importance: 7, - columnConstructor: tr.ui.analysis.DetailsNumericMemoryColumn - }, - { - condition: 'Protection flags', - importance: 6, - columnConstructor: tr.ui.analysis.StringMemoryColumn - }, - { - condition: 'PSS', - importance: 5, - columnConstructor: tr.ui.analysis.DetailsNumericMemoryColumn - }, - { - condition: 'Private dirty', - importance: 4, - columnConstructor: tr.ui.analysis.DetailsNumericMemoryColumn - }, - { - condition: 'Private clean', - importance: 3, - columnConstructor: tr.ui.analysis.DetailsNumericMemoryColumn - }, - { - condition: 'Shared dirty', - importance: 2, - columnConstructor: tr.ui.analysis.DetailsNumericMemoryColumn - }, - { - condition: 'Shared clean', - importance: 1, - columnConstructor: tr.ui.analysis.DetailsNumericMemoryColumn - }, - { - condition: 'Swapped', - importance: 0, - columnConstructor: tr.ui.analysis.DetailsNumericMemoryColumn - } - ]; - - var BYTE_STAT_COLUMN_MAP = { - 'proportionalResident': 'PSS', - 'privateDirtyResident': 'Private dirty', - 'privateCleanResident': 'Private clean', - 'sharedDirtyResident': 'Shared dirty', - 'sharedCleanResident': 'Shared clean', - 'swapped': 'Swapped' - }; - - function hexString(address, is64BitAddress) { - if (address === undefined) - return undefined; - var hexPadding = is64BitAddress ? '0000000000000000' : '00000000'; - return (hexPadding + address.toString(16)).substr(-hexPadding.length); - } - - function pruneEmptyRuleRows(row) { - if (row.subRows === undefined || row.subRows.length === 0) - return; - - // Either all sub-rows are rule rows, or all sub-rows are VM region rows. - if (row.subRows[0].rule === undefined) { - // VM region rows: Early out to avoid filtering a large array for - // performance reasons (no sub-rows would be removed, but the whole array - // would be unnecessarily copied to a new array). - return; - } - - row.subRows.forEach(pruneEmptyRuleRows); - row.subRows = row.subRows.filter(function(subRow) { - return subRow.subRows.length > 0; - }); - } - - Polymer('tr-ui-a-memory-dump-vm-regions-details-pane', { - created: function() { - this.vmRegions_ = undefined; - this.aggregationMode_ = undefined; - }, - - ready: function() { - this.$.table.selectionMode = tr.ui.b.TableFormat.SelectionMode.ROW; - }, - - /** - * Sets the VM regions and schedules rebuilding the pane. - * - * The provided value should be a chronological list of lists of VM - * regions. All VM regions are assumed to belong to the same process. - * Example: - * - * [ - * [ - * // VM regions at timestamp 1. - * tr.model.VMRegion {}, - * tr.model.VMRegion {}, - * tr.model.VMRegion {} - * ], - * undefined, // No VM regions provided at timestamp 2. - * [ - * // VM regions at timestamp 3. - * tr.model.VMRegion {}, - * tr.model.VMRegion {} - * ] - * ] - */ - set vmRegions(vmRegions) { - this.vmRegions_ = vmRegions; - this.scheduleRebuildPane_(); - }, - - get vmRegions() { - return this.vmRegions_; - }, - - set aggregationMode(aggregationMode) { - this.aggregationMode_ = aggregationMode; - this.scheduleRebuildPane_(); - }, - - get aggregationMode() { - return this.aggregationMode_; - }, - - rebuildPane_: function() { - if (this.vmRegions_ === undefined || this.vmRegions_.length === 0) { - // Show the info text (hide the table). - this.$.info_text.style.display = 'block'; - this.$.table.style.display = 'none'; - - this.$.table.clear(); - this.$.table.rebuild(); - return; - } - - // Show the table (hide the info text). - this.$.info_text.style.display = 'none'; - this.$.table.style.display = 'block'; - - var rows = this.createRows_(this.vmRegions_); - var columns = this.createColumns_(rows); - - // Note: There is no need to aggregate fields of the VM regions because - // the classification tree already takes care of that. - - this.$.table.tableRows = rows; - this.$.table.tableColumns = columns; - - // TODO(petrcermak): This can be quite slow. Consider doing this somehow - // asynchronously. - this.$.table.rebuild(); - - tr.ui.analysis.expandTableRowsRecursively(this.$.table); - }, - - createRows_: function(timeToVmRegionTree) { - // Determine if any start address is outside the 32-bit range. - var is64BitAddress = timeToVmRegionTree.some(function(vmRegionTree) { - if (vmRegionTree === undefined) - return false; - return vmRegionTree.someRegion(function(region) { - if (region.startAddress === undefined) - return false; - return region.startAddress >= 4294967296 /* 2^32 */; - }); - }); - - return [ - this.createClassificationNodeRow(timeToVmRegionTree, is64BitAddress) - ]; - }, - - createClassificationNodeRow: function(timeToNode, is64BitAddress) { - // Get any defined classification node so that we can extract the - // properties which don't change over time. - var definedNode = tr.b.findFirstInArray(timeToNode); - - // Child node ID (list index) -> Timestamp (list index) -> - // VM region classification node. - var childNodeIdToTimeToNode = tr.b.dictionaryValues( - tr.b.invertArrayOfDicts(timeToNode, function(node) { - var children = node.children; - if (children === undefined) - return undefined; - var childMap = {}; - children.forEach(function(childNode) { - if (!childNode.hasRegions) - return; - childMap[childNode.title] = childNode; - }); - return childMap; - })); - var childNodeSubRows = childNodeIdToTimeToNode.map( - function(timeToChildNode) { - return this.createClassificationNodeRow( - timeToChildNode, is64BitAddress); - }, this); - - // Region ID (list index) -> Timestamp (list index) -> VM region. - var regionIdToTimeToRegion = tr.b.dictionaryValues( - tr.b.invertArrayOfDicts(timeToNode, function(node) { - var regions = node.regions; - if (regions === undefined) - return undefined; - return tr.b.arrayToDict(regions, function(region) { - return region.uniqueIdWithinProcess; - }); - })); - var regionSubRows = regionIdToTimeToRegion.map(function(timeToRegion) { - return this.createRegionRow_(timeToRegion, is64BitAddress); - }, this); - - var subRows = childNodeSubRows.concat(regionSubRows); - - return { - title: definedNode.title, - contexts: timeToNode, - variableCells: this.createVariableCells_(timeToNode), - subRows: subRows - }; - }, - - createRegionRow_: function(timeToRegion, is64BitAddress) { - // Get any defined VM region so that we can extract the properties which - // don't change over time. - var definedRegion = tr.b.findFirstInArray(timeToRegion); - - return { - title: definedRegion.mappedFile, - contexts: timeToRegion, - constantCells: this.createConstantCells_(definedRegion, is64BitAddress), - variableCells: this.createVariableCells_(timeToRegion) - }; - }, - - /** - * Create cells for VM region properties which DON'T change over time. - * - * Note that there are currently no such properties of classification nodes. - */ - createConstantCells_: function(definedRegion, is64BitAddress) { - return tr.ui.analysis.createCells([definedRegion], function(region) { - var startAddress = region.startAddress; - if (startAddress === undefined) - return undefined; - return { 'Start address': hexString(startAddress, is64BitAddress) }; - }); - }, - - /** - * Create cells for VM region (classification node) properties which DO - * change over time. - */ - createVariableCells_: function(timeToRegion) { - return tr.ui.analysis.createCells(timeToRegion, function(region) { - var fields = {}; - - var sizeInBytes = region.sizeInBytes; - if (sizeInBytes !== undefined) { - fields['Virtual size'] = new ScalarNumeric( - sizeInBytes_smallerIsBetter, sizeInBytes); - } - var protectionFlags = region.protectionFlagsToString; - if (protectionFlags !== undefined) - fields['Protection flags'] = protectionFlags; - - tr.b.iterItems(BYTE_STAT_COLUMN_MAP, - function(byteStatName, columnName) { - var byteStat = region.byteStats[byteStatName]; - if (byteStat === undefined) - return; - fields[columnName] = new ScalarNumeric( - sizeInBytes_smallerIsBetter, byteStat); - }); - - return fields; - }); - }, - - createColumns_: function(rows) { - var titleColumn = new tr.ui.analysis.TitleColumn('Mapped file'); - titleColumn.width = '200px'; - - var constantColumns = tr.ui.analysis.MemoryColumn.fromRows( - rows, 'constantCells', undefined, CONSTANT_COLUMN_RULES); - var variableColumns = tr.ui.analysis.MemoryColumn.fromRows( - rows, 'variableCells', this.aggregationMode_, VARIABLE_COLUMN_RULES); - var fieldColumns = constantColumns.concat(variableColumns); - tr.ui.analysis.MemoryColumn.spaceEqually(fieldColumns); - - var columns = [titleColumn].concat(fieldColumns); - return columns; - } - }); - - return {}; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/memory_dump_vm_regions_details_pane_test.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/memory_dump_vm_regions_details_pane_test.html deleted file mode 100644 index 9c79c1b5753..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/memory_dump_vm_regions_details_pane_test.html +++ /dev/null @@ -1,489 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/iteration_helpers.html"> -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/container_memory_dump.html"> -<link rel="import" href="/tracing/model/memory_dump_test_utils.html"> -<link rel="import" href="/tracing/model/vm_region.html"> -<link rel="import" - href="/tracing/ui/analysis/memory_dump_sub_view_test_utils.html"> -<link rel="import" href="/tracing/ui/analysis/memory_dump_sub_view_util.html"> -<link rel="import" - href="/tracing/ui/analysis/memory_dump_vm_regions_details_pane.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var newAllocatorDump = tr.model.MemoryDumpTestUtils.newAllocatorDump; - var VMRegion = tr.model.VMRegion; - var VMRegionClassificationNode = tr.model.VMRegionClassificationNode; - var TitleColumn = tr.ui.analysis.TitleColumn; - var StringMemoryColumn = tr.ui.analysis.StringMemoryColumn; - var NumericMemoryColumn = tr.ui.analysis.NumericMemoryColumn; - var AggregationMode = tr.ui.analysis.MemoryColumn.AggregationMode; - var addGlobalMemoryDump = tr.model.MemoryDumpTestUtils.addGlobalMemoryDump; - var addProcessMemoryDump = tr.model.MemoryDumpTestUtils.addProcessMemoryDump; - var checkSizeNumericFields = tr.ui.analysis.checkSizeNumericFields; - var checkStringFields = tr.ui.analysis.checkStringFields; - var checkColumns = tr.ui.analysis.checkColumns; - var isElementDisplayed = tr.ui.analysis.isElementDisplayed; - var DETAILED = tr.model.ContainerMemoryDump.LevelOfDetail.DETAILED; - - function createVMRegions() { - var model = tr.c.TestUtils.newModel(function(model) { - var process = model.getOrCreateProcess(1); - - // First timestamp. - var gmd1 = addGlobalMemoryDump(model, 42, DETAILED); - var pmd1 = addProcessMemoryDump(gmd1, process, 42); - pmd1.vmRegions = VMRegionClassificationNode.fromRegions([ - VMRegion.fromDict({ - mappedFile: '/lib/chrome.so', - startAddress: 65536, - sizeInBytes: 536870912, - protectionFlags: VMRegion.PROTECTION_FLAG_READ | - VMRegion.PROTECTION_FLAG_EXECUTE, - byteStats: { - proportionalResident: 8192 - } - }), - VMRegion.fromDict({ - mappedFile: '/usr/lib/x86_64-linux-gnu/libX11.so.6.3.0', - startAddress: 140296983150592, - sizeInBytes: 2097152, - protectionFlags: 0, - byteStats: { - proportionalResident: 0 - } - }), - VMRegion.fromDict({ - startAddress: 10995116277760, - sizeInBytes: 2147483648, - protectionFlags: VMRegion.PROTECTION_FLAG_READ | - VMRegion.PROTECTION_FLAG_WRITE, - byteStats: { - privateDirtyResident: 0, - swapped: 0 - } - }), - VMRegion.fromDict({ - startAddress: 12094627905536, - sizeInBytes: 2147483648, - protectionFlags: VMRegion.PROTECTION_FLAG_READ | - VMRegion.PROTECTION_FLAG_WRITE, - byteStats: { - privateDirtyResident: 0, - swapped: 0 - } - }), - VMRegion.fromDict({ - mappedFile: '/dev/ashmem/dalvik-zygote space', - startAddress: 13194139533312, - sizeInBytes: 100, - protectionFlags: VMRegion.PROTECTION_FLAG_READ | - VMRegion.PROTECTION_FLAG_EXECUTE, - byteStats: { - proportionalResident: 100, - privateDirtyResident: 0, - swapped: 0 - } - }), - VMRegion.fromDict({ - mappedFile: '/dev/ashmem/libc malloc', - startAddress: 14293651161088, - sizeInBytes: 200, - protectionFlags: VMRegion.PROTECTION_FLAG_READ | - VMRegion.PROTECTION_FLAG_EXECUTE, - byteStats: { - proportionalResident: 200, - privateDirtyResident: 96, - swapped: 0 - } - }) - ]); - - // This is here so that we could test that tracing is discounted from the - // 'Native heap' category. - pmd1.memoryAllocatorDumps = [ - newAllocatorDump(pmd1, 'tracing', { size: 500, resident_size: 32 }) - ]; - - // Second timestamp. - var gmd2 = addGlobalMemoryDump(model, 42, DETAILED); - var pmd2 = addProcessMemoryDump(gmd2, process, 42); - pmd2.vmRegions = VMRegionClassificationNode.fromRegions([ - VMRegion.fromDict({ - mappedFile: '/lib/chrome.so', - startAddress: 65536, - sizeInBytes: 536870912, - protectionFlags: VMRegion.PROTECTION_FLAG_READ | - VMRegion.PROTECTION_FLAG_EXECUTE, - byteStats: { - proportionalResident: 9216 - } - }), - VMRegion.fromDict({ - mappedFile: '/lib/chrome.so', - startAddress: 140296983150592, - sizeInBytes: 536870912, - protectionFlags: VMRegion.PROTECTION_FLAG_READ | - VMRegion.PROTECTION_FLAG_EXECUTE, - byteStats: { - proportionalResident: 10240 - } - }), - VMRegion.fromDict({ - startAddress: 10995116277760, - sizeInBytes: 2147483648, - protectionFlags: VMRegion.PROTECTION_FLAG_READ | - VMRegion.PROTECTION_FLAG_WRITE, - byteStats: { - privateDirtyResident: 0, - swapped: 32 - } - }), - VMRegion.fromDict({ - startAddress: 12094627905536, - sizeInBytes: 2147483648, - protectionFlags: VMRegion.PROTECTION_FLAG_READ | - VMRegion.PROTECTION_FLAG_WRITE, - byteStats: { - privateDirtyResident: 0, - swapped: 0 - } - }), - VMRegion.fromDict({ - mappedFile: '/dev/ashmem/dalvik-zygote space', - startAddress: 13194139533312, - sizeInBytes: 100, - protectionFlags: VMRegion.PROTECTION_FLAG_READ | - VMRegion.PROTECTION_FLAG_EXECUTE, - byteStats: { - proportionalResident: 0, - privateDirtyResident: 100, - swapped: 0 - } - }), - VMRegion.fromDict({ - mappedFile: '/dev/ashmem/libc malloc', - startAddress: 14293651161088, - sizeInBytes: 200, - protectionFlags: VMRegion.PROTECTION_FLAG_READ | - VMRegion.PROTECTION_FLAG_EXECUTE, - byteStats: { - proportionalResident: 100, - privateDirtyResident: 96, - swapped: 0 - } - }), - VMRegion.fromDict({ - mappedFile: '/usr/share/fonts/DejaVuSansMono.ttf', - startAddress: 140121259503616, - sizeInBytes: 335872, - protectionFlags: VMRegion.PROTECTION_FLAG_READ, - byteStats: { - proportionalResident: 22528 - } - }), - VMRegion.fromDict({ - mappedFile: 'another-map', - startAddress: 52583094233905872, - sizeInBytes: 1, - byteStats: { - proportionalResident: 1, - privateDirtyResident: 1, - swapped: 1 - } - }) - ]); - }); - - return model.processes[1].memoryDumps.map(function(pmd) { - return pmd.mostRecentVmRegions; - }); - } - - var EXPECTED_COLUMNS = [ - { title: 'Mapped file', type: TitleColumn, noAggregation: true }, - { title: 'Start address', type: StringMemoryColumn, noAggregation: true }, - { title: 'Virtual size', type: NumericMemoryColumn }, - { title: 'Protection flags', type: StringMemoryColumn }, - { title: 'PSS', type: NumericMemoryColumn }, - { title: 'Private dirty', type: NumericMemoryColumn }, - { title: 'Swapped', type: NumericMemoryColumn } - ]; - - function checkRow(columns, row, expectedTitle, expectedStartAddress, - expectedVirtualSize, expectedProtectionFlags, - expectedProportionalResidentValues, expectedPrivateDirtyResidentValues, - expectedSwappedValues, expectedSubRowCount, expectedContexts) { - assert.equal(columns[0].formatTitle(row), expectedTitle); - checkStringFields(row, columns[1], expectedStartAddress); - checkSizeNumericFields(row, columns[2], expectedVirtualSize); - checkStringFields(row, columns[3], expectedProtectionFlags); - checkSizeNumericFields(row, columns[4], expectedProportionalResidentValues); - checkSizeNumericFields(row, columns[5], expectedPrivateDirtyResidentValues); - checkSizeNumericFields(row, columns[6], expectedSwappedValues); - - if (expectedSubRowCount === undefined) - assert.isUndefined(row.subRows); - else - assert.lengthOf(row.subRows, expectedSubRowCount); - - if (typeof expectedContexts === 'function') - expectedContexts(row.contexts); - else if (expectedContexts !== undefined) - assert.deepEqual(tr.b.asArray(row.contexts), expectedContexts); - else - assert.isUndefined(row.contexts); - } - - function genericMatcher(callback, defined) { - return function(actualValues) { - assert.lengthOf(actualValues, defined.length); - for (var i = 0; i < defined.length; i++) { - var actualValue = actualValues[i]; - if (defined[i]) - callback(actualValue); - else - assert.isUndefined(actualValue); - } - } - } - - function vmRegionsMatcher(expectedMappedFile, expectedStartAddress, defined) { - return genericMatcher(function(actualRegion) { - assert.instanceOf(actualRegion, VMRegion); - assert.strictEqual(actualRegion.mappedFile, expectedMappedFile); - assert.strictEqual(actualRegion.startAddress, expectedStartAddress); - }, defined); - } - - function classificationNodesMatcher(expectedTitle, defined) { - return genericMatcher(function(actualNode) { - assert.instanceOf(actualNode, VMRegionClassificationNode); - assert.strictEqual(actualNode.title, expectedTitle); - }, defined); - } - - test('instantiate_empty', function() { - tr.ui.analysis.createAndCheckEmptyPanes(this, - 'tr-ui-a-memory-dump-vm-regions-details-pane', 'vmRegions', - function(viewEl) { - // Check that the info text is shown. - assert.isTrue(isElementDisplayed(viewEl.$.info_text)); - assert.isFalse(isElementDisplayed(viewEl.$.table)); - }); - }); - - test('instantiate_single', function() { - var vmRegions = createVMRegions().slice(0, 1); - - var viewEl = document.createElement( - 'tr-ui-a-memory-dump-vm-regions-details-pane'); - viewEl.vmRegions = vmRegions; - viewEl.rebuild(); - this.addHTMLOutput(viewEl); - - // Check that the table is shown. - assert.isTrue(isElementDisplayed(viewEl.$.table)); - assert.isFalse(isElementDisplayed(viewEl.$.info_text)); - - var table = viewEl.$.table; - var columns = table.tableColumns; - checkColumns(columns, EXPECTED_COLUMNS, undefined /* no aggregation */); - var rows = table.tableRows; - assert.lengthOf(rows, 1); - - // Check the rows of the table. - var totalRow = rows[0]; - checkRow(columns, totalRow, 'Total', undefined, [4833935160], undefined, - [8460], [64], [0], 3, vmRegions); - - var androidRow = totalRow.subRows[0]; - checkRow(columns, androidRow, 'Android', undefined, [100], undefined, - [100], [0], [0], 1, classificationNodesMatcher('Android', [true])); - - var javaRuntimeRow = androidRow.subRows[0]; - checkRow(columns, javaRuntimeRow, 'Java runtime', undefined, [100], - undefined, [100], [0], [0], 1, - classificationNodesMatcher('Java runtime', [true])); - - var spacesRow = javaRuntimeRow.subRows[0]; - checkRow(columns, spacesRow, 'Spaces', undefined, [100], undefined, [100], - [0], [0], 1, classificationNodesMatcher('Spaces', [true])); - - var nativeHeapRow = totalRow.subRows[1]; - checkRow(columns, nativeHeapRow, 'Native heap', undefined, [4294966996], - undefined, [168], [64], [0], 4, - classificationNodesMatcher('Native heap', [true])); - - var discountedTracingOverheadRow = nativeHeapRow.subRows[3]; - checkRow(columns, discountedTracingOverheadRow, - '[discounted tracing overhead]', undefined, [-500], undefined, [-32], - [-32], undefined, undefined, - vmRegionsMatcher('[discounted tracing overhead]', undefined, [true])); - - var filesRow = totalRow.subRows[2]; - checkRow(columns, filesRow, 'Files', undefined, [538968064], undefined, - [8192], undefined, undefined, 1, - classificationNodesMatcher('Files', [true])); - - var soRow = filesRow.subRows[0]; - checkRow(columns, soRow, 'so', undefined, [538968064], undefined, - [8192], undefined, undefined, 2, - classificationNodesMatcher('so', [true])); - - var mmapChromeRow = soRow.subRows[0]; - checkRow(columns, mmapChromeRow, '/lib/chrome.so', ['0000000000010000'], - [536870912], ['r-xp'], [8192], undefined, undefined, undefined, - vmRegionsMatcher('/lib/chrome.so', 65536, [true])); - - var mmapLibX11Row = soRow.subRows[1]; - checkRow(columns, mmapLibX11Row, - '/usr/lib/x86_64-linux-gnu/libX11.so.6.3.0', ['00007f996fd80000'], - [2097152], ['---p'], [0], undefined, undefined, undefined, - vmRegionsMatcher('/usr/lib/x86_64-linux-gnu/libX11.so.6.3.0', - 140296983150592, [true])); - }); - - test('instantiate_multipleDiff', function() { - var vmRegions = createVMRegions(); - - var viewEl = document.createElement( - 'tr-ui-a-memory-dump-vm-regions-details-pane'); - viewEl.vmRegions = vmRegions; - viewEl.aggregationMode = AggregationMode.DIFF; - viewEl.rebuild(); - this.addHTMLOutput(viewEl); - - // Check that the table is shown. - assert.isTrue(isElementDisplayed(viewEl.$.table)); - assert.isFalse(isElementDisplayed(viewEl.$.info_text)); - - var table = viewEl.$.table; - var columns = table.tableColumns; - checkColumns(columns, EXPECTED_COLUMNS, AggregationMode.DIFF); - var rows = table.tableRows; - assert.lengthOf(rows, 1); - - // Check the rows of the table. - var totalRow = rows[0]; - checkRow(columns, totalRow, 'Total', undefined, [4833935160, 5369045293], - undefined, [8460, 42085], [64, 197], [0, 33], 4, vmRegions); - - var androidRow = totalRow.subRows[0]; - checkRow(columns, androidRow, 'Android', undefined, [100, 100], undefined, - [100, 0], [0, 100], [0, 0], 1, - classificationNodesMatcher('Android', [true, true])); - - var javaRuntimeRow = androidRow.subRows[0]; - checkRow(columns, javaRuntimeRow, 'Java runtime', undefined, [100, 100], - undefined, [100, 0], [0, 100], [0, 0], 1, - classificationNodesMatcher('Java runtime', [true, true])); - - var spacesRow = javaRuntimeRow.subRows[0]; - checkRow(columns, spacesRow, 'Spaces', undefined, [100, 100], undefined, - [100, 0], [0, 100], [0, 0], 1, - classificationNodesMatcher('Spaces', [true, true])); - - var nativeHeapRow = totalRow.subRows[1]; - checkRow(columns, nativeHeapRow, 'Native heap', undefined, - [4294966996, 4294967496], undefined, [168, 100], [64, 96], [0, 32], 4, - classificationNodesMatcher('Native heap', [true, true])); - - var discountedTracingOverheadRow = nativeHeapRow.subRows[3]; - checkRow(columns, discountedTracingOverheadRow, - '[discounted tracing overhead]', undefined, [-500, undefined], - undefined, [-32, undefined], [-32, undefined], undefined, undefined, - vmRegionsMatcher('[discounted tracing overhead]', undefined, - [true, false])); - - var filesRow = totalRow.subRows[2]; - checkRow(columns, filesRow, 'Files', undefined, [538968064, 1074077696], - undefined, [8192, 41984], undefined, undefined, 2, - classificationNodesMatcher('Files', [true, true])); - - var soRow = filesRow.subRows[0]; - checkRow(columns, soRow, 'so', undefined, [538968064, 1073741824], - undefined, [8192, 19456], undefined, undefined, 3, - classificationNodesMatcher('so', [true, true])); - - var mmapChromeRow = soRow.subRows[0]; - checkRow(columns, mmapChromeRow, '/lib/chrome.so', ['0000000000010000'], - [536870912, 536870912], ['r-xp', 'r-xp'], [8192, 9216], undefined, - undefined, undefined, - vmRegionsMatcher('/lib/chrome.so', 65536, [true, true])); - - var mmapLibX11Row = soRow.subRows[1]; - checkRow(columns, mmapLibX11Row, - '/usr/lib/x86_64-linux-gnu/libX11.so.6.3.0', ['00007f996fd80000'], - [2097152, undefined], ['---p', undefined], [0, undefined], undefined, - undefined, undefined, - vmRegionsMatcher('/usr/lib/x86_64-linux-gnu/libX11.so.6.3.0', - 140296983150592, [true, false])); - - var otherRow = totalRow.subRows[3]; - checkRow(columns, otherRow, 'Other', undefined, [undefined, 1], undefined, - [undefined, 1], [undefined, 1], [undefined, 1], 1, - classificationNodesMatcher('Other', [false, true])); - - var anotherMapRow = otherRow.subRows[0]; - checkRow(columns, anotherMapRow, 'another-map', ['00bad00bad00bad0'], - [undefined, 1], undefined, [undefined, 1], [undefined, 1], - [undefined, 1], undefined, - vmRegionsMatcher('another-map', 52583094233905872, [false, true])); - }); - - test('instantiate_multipleMax', function() { - var vmRegions = createVMRegions(); - - var viewEl = document.createElement( - 'tr-ui-a-memory-dump-vm-regions-details-pane'); - viewEl.vmRegions = vmRegions; - viewEl.aggregationMode = AggregationMode.MAX; - viewEl.rebuild(); - this.addHTMLOutput(viewEl); - - // Check that the table is shown. - assert.isTrue(isElementDisplayed(viewEl.$.table)); - assert.isFalse(isElementDisplayed(viewEl.$.info_text)); - - // Just check that the aggregation mode was propagated to the columns. - var table = viewEl.$.table; - var columns = table.tableColumns; - checkColumns(columns, EXPECTED_COLUMNS, AggregationMode.MAX); - var rows = table.tableRows; - assert.lengthOf(rows, 1); - }); - - test('instantiate_multipleWithUndefined', function() { - var vmRegions = createVMRegions(); - vmRegions.splice(1, 0, undefined); - - var viewEl = document.createElement( - 'tr-ui-a-memory-dump-vm-regions-details-pane'); - viewEl.vmRegions = vmRegions; - viewEl.aggregationMode = AggregationMode.DIFF; - viewEl.rebuild(); - this.addHTMLOutput(viewEl); - - // Check that the table is shown. - assert.isTrue(isElementDisplayed(viewEl.$.table)); - assert.isFalse(isElementDisplayed(viewEl.$.info_text)); - - // Just check that the table has the right shape. - var table = viewEl.$.table; - var columns = table.tableColumns; - checkColumns(columns, EXPECTED_COLUMNS, AggregationMode.DIFF); - var rows = table.tableRows; - assert.lengthOf(rows, 1); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_async_slice_sub_view.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_async_slice_sub_view.html deleted file mode 100644 index f062aca2336..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_async_slice_sub_view.html +++ /dev/null @@ -1,72 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/ui/analysis/analysis_sub_view.html"> -<link rel="import" href="/tracing/ui/analysis/multi_event_sub_view.html"> -<link rel="import" href="/tracing/ui/analysis/related_events.html"> - -<polymer-element name="tr-ui-a-multi-async-slice-sub-view" - extends="tr-ui-a-sub-view"> - <template> - <style> - :host { - display: flex; - } - #container { - display: flex; - flex: 1 1 auto; - } - #events { - margin-left: 8px; - flex: 0 1 200px; - } - </style> - <div id="container"> - <tr-ui-a-multi-event-sub-view id="content"></tr-ui-a-multi-event-sub-view> - <div id="events"> - <tr-ui-a-related-events id="relatedEvents"></tr-ui-a-related-events> - </div> - </div> - </template> - - <script> - 'use strict'; - - Polymer({ - get selection() { - return this.$.content.selection; - }, - - set selection(selection) { - this.$.content.selection = selection; - this.$.relatedEvents.setRelatedEvents(selection); - if (this.$.relatedEvents.hasRelatedEvents()) { - this.$.relatedEvents.style.display = ''; - } else { - this.$.relatedEvents.style.display = 'none'; - } - }, - - get relatedEventsToHighlight() { - if (!this.$.content.selection) - return undefined; - var selection = new tr.model.EventSet(); - this.$.content.selection.forEach(function(asyncEvent) { - if (!asyncEvent.associatedEvents) - return; - asyncEvent.associatedEvents.forEach(function(event) { - selection.push(event); - }); - }); - if (selection.length) - return selection; - return undefined; - } - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_async_slice_sub_view_test.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_async_slice_sub_view_test.html deleted file mode 100644 index f3db7675156..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_async_slice_sub_view_test.html +++ /dev/null @@ -1,48 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/ui/analysis/multi_async_slice_sub_view.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var newAsyncSliceEx = tr.c.TestUtils.newAsyncSliceEx; - - test('instantiate', function() { - var model = new tr.Model(); - var p1 = model.getOrCreateProcess(1); - var t1 = p1.getOrCreateThread(1); - t1.asyncSliceGroup.push(newAsyncSliceEx({ - title: 'a', - start: 10, - end: 20, - startThread: t1, - endThread: t1 - })); - t1.asyncSliceGroup.push(newAsyncSliceEx({ - title: 'b', - start: 25, - end: 40, - startThread: t1, - endThread: t1 - })); - - var selection = new tr.model.EventSet(); - selection.push(t1.asyncSliceGroup.slices[0]); - selection.push(t1.asyncSliceGroup.slices[1]); - - var viewEl = document.createElement('tr-ui-a-multi-async-slice-sub-view'); - viewEl.selection = selection; - this.addHTMLOutput(viewEl); - }); - -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_cpu_slice_sub_view.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_cpu_slice_sub_view.html deleted file mode 100644 index f4f5215a004..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_cpu_slice_sub_view.html +++ /dev/null @@ -1,42 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/analysis/analysis_sub_view.html"> -<link rel="import" href="/tracing/ui/analysis/multi_event_sub_view.html"> - -<polymer-element name="tr-ui-a-multi-cpu-slice-sub-view" - extends="tr-ui-a-sub-view"> - <template> - <style> - :host { - display: flex; - } - #content { - flex: 1 1 auto; - } - </style> - <tr-ui-a-multi-event-sub-view id="content"></tr-ui-a-multi-event-sub-view> - </template> - - <script> - 'use strict'; - - Polymer({ - ready: function() { - this.$.content.eventsHaveSubRows = false; - }, - - get selection() { - return this.$.content.selection; - }, - - set selection(selection) { - this.$.content.setSelectionWithoutErrorChecks(selection); - } - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_cpu_slice_sub_view_test.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_cpu_slice_sub_view_test.html deleted file mode 100644 index b0f8eb266a2..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_cpu_slice_sub_view_test.html +++ /dev/null @@ -1,49 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/extras/importer/linux_perf/ftrace_importer.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/ui/analysis/multi_cpu_slice_sub_view.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - function createBasicModel() { - var lines = [ - 'Android.launcher-584 [001] d..3 12622.506890: sched_switch: prev_comm=Android.launcher prev_pid=584 prev_prio=120 prev_state=R+ ==> next_comm=Binder_1 next_pid=217 next_prio=120', // @suppress longLineCheck - ' Binder_1-217 [001] d..3 12622.506918: sched_switch: prev_comm=Binder_1 prev_pid=217 prev_prio=120 prev_state=D ==> next_comm=Android.launcher next_pid=584 next_prio=120', // @suppress longLineCheck - 'Android.launcher-584 [001] d..4 12622.506936: sched_wakeup: comm=Binder_1 pid=217 prio=120 success=1 target_cpu=001', // @suppress longLineCheck - 'Android.launcher-584 [001] d..3 12622.506950: sched_switch: prev_comm=Android.launcher prev_pid=584 prev_prio=120 prev_state=R+ ==> next_comm=Binder_1 next_pid=217 next_prio=120', // @suppress longLineCheck - ' Binder_1-217 [001] ...1 12622.507057: tracing_mark_write: B|128|queueBuffer', // @suppress longLineCheck - ' Binder_1-217 [001] ...1 12622.507175: tracing_mark_write: E', - ' Binder_1-217 [001] d..3 12622.507253: sched_switch: prev_comm=Binder_1 prev_pid=217 prev_prio=120 prev_state=S ==> next_comm=Android.launcher next_pid=584 next_prio=120' // @suppress longLineCheck - ]; - - return tr.c.TestUtils.newModelWithEvents([lines.join('\n')], { - shiftWorldToZero: false - }); - } - - test('instantiate', function() { - var m = createBasicModel(); - var cpu = m.kernel.cpus[1]; - assert.isDefined(cpu); - - var selection = new tr.model.EventSet(); - selection.push(cpu.slices[0]); - selection.push(cpu.slices[1]); - - var viewEl = document.createElement('tr-ui-a-multi-cpu-slice-sub-view'); - viewEl.selection = selection; - this.addHTMLOutput(viewEl); - }); - -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_event_details_table.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_event_details_table.html deleted file mode 100644 index 101137cdcb6..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_event_details_table.html +++ /dev/null @@ -1,333 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/base.html"> -<link rel="import" href="/tracing/base/iteration_helpers.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/ui/analysis/generic_object_view.html"> -<link rel="import" href="/tracing/ui/analysis/multi_event_summary.html"> -<link rel="import" href="/tracing/ui/base/table.html"> -<link rel="import" href="/tracing/value/ui/scalar_span.html"> -<link rel="import" href="/tracing/value/unit.html"> - -<polymer-element name='tr-ui-a-multi-event-details-table'> - <template> - <style> - :host { - display: flex; - flex-direction: column; - } - #table { - flex: 1 1 auto; - align-self: stretch; - } - - #titletable { - font-weight: bold; - } - - #title-info { - font-size: 12px; - } - </style> - <tr-ui-b-table id="titletable"> - </tr-ui-b-table> - <tr-ui-b-table id="table"> - </tr-ui-b-table> - </template> - - <script> - 'use strict'; - - Polymer({ - created: function() { - this.selection_ = undefined; - this.eventsHaveDuration_ = true; - this.eventsHaveSubRows_ = true; - }, - - ready: function() { - this.initTitleTable_(); - }, - - get eventsHaveDuration() { - return this.eventsHaveDuration_; - }, - - set eventsHaveDuration(eventsHaveDuration) { - this.eventsHaveDuration_ = eventsHaveDuration; - this.updateContents_(); - }, - - get eventsHaveSubRows() { - return this.eventsHaveSubRows_; - }, - - set eventsHaveSubRows(eventsHaveSubRows) { - this.eventsHaveSubRows_ = eventsHaveSubRows; - this.updateContents_(); - }, - - get selection() { - return this.selection_; - }, - - set selection(selection) { - this.selection_ = selection; - this.updateContents_(); - }, - - updateContents_: function() { - var selection = this.selection_; - - this.updateTitleTable_(); - - if (this.selection_ === undefined) { - this.$.table.tableRows = []; - this.$.table.tableFooterRows = []; - this.$.table.rebuild(); - return; - } - - var summary = new tr.ui.analysis.MultiEventSummary( - 'Totals', this.selection_); - this.updateColumns_(summary); - this.updateRows_(summary); - this.$.table.rebuild(); - }, - - initTitleTable_: function() { - var table = this.$.titletable; - - table.showHeader = false; - table.tableColumns = [ - { - title: 'Title', - value: function(row) { return row.title; }, - width: '350px' - }, - { - title: 'Value', - width: '100%', - value: function(row) { - return row.value; - } - } - ]; - }, - - getSelectionTitle_: function() { - if (!this.selection || !this.selection.length) - return '<No selection>'; - - var firstTitle = tr.b.getFirstElement(this.selection).title; - if (!tr.b.every(this.selection, (event) => event.title === firstTitle)) - return '<Different titles>'; - - return firstTitle; - }, - - updateTitleTable_: function() { - this.$.titletable.tableRows = [{ - title: 'Title', - value: this.getSelectionTitle_() - }]; - }, - - updateColumns_: function(summary) { - var hasCpuData; - if (summary.cpuDuration !== undefined) - hasCpuData = true; - if (summary.cpuSelfTime !== undefined) - hasCpuData = true; - - var colWidthPercentage; - if (hasCpuData) - colWidthPercentage = '20%'; - else - colWidthPercentage = '33.3333%'; - - var ownerDocument = this.ownerDocument; - var columns = []; - - columns.push({ - title: 'Start', - value: function(row) { - if (row.__proto__ === tr.ui.analysis.MultiEventSummary.prototype) { - return row.title; - } - - var linkEl = document.createElement('tr-ui-a-analysis-link'); - linkEl.setSelectionAndContent(function() { - return new tr.model.EventSet(row.event); - }); - linkEl.appendChild(tr.v.ui.createScalarSpan(row.start, { - unit: tr.v.Unit.byName.timeStampInMs, - ownerDocument: ownerDocument - })); - return linkEl; - }, - width: '350px', - cmp: function(rowA, rowB) { - return rowA.start - rowB.start; - } - }); - - if (this.eventsHaveDuration_) { - columns.push({ - title: 'Wall Duration (ms)', - value: function(row) { - return tr.v.ui.createScalarSpan(row.duration, { - unit: tr.v.Unit.byName.timeDurationInMs, - ownerDocument: ownerDocument - }); - }, - width: '<upated further down>', - cmp: function(rowA, rowB) { - return rowA.duration - rowB.duration; - } - }); - } - - if (this.eventsHaveDuration_ && hasCpuData) { - columns.push({ - title: 'CPU Duration (ms)', - value: function(row) { - return tr.v.ui.createScalarSpan(row.cpuDuration, { - unit: tr.v.Unit.byName.timeDurationInMs, - ownerDocument: ownerDocument - }); - }, - width: '<upated further down>', - cmp: function(rowA, rowB) { - return rowA.cpuDuration - rowB.cpuDuration; - } - }); - } - - if (this.eventsHaveSubRows_ && this.eventsHaveDuration_) { - columns.push({ - title: 'Self time (ms)', - value: function(row) { - return tr.v.ui.createScalarSpan(row.selfTime, { - unit: tr.v.Unit.byName.timeDurationInMs, - ownerDocument: ownerDocument - }); - }, - width: '<upated further down>', - cmp: function(rowA, rowB) { - return rowA.selfTime - rowB.selfTime; - } - }); - } - - if (this.eventsHaveSubRows_ && this.eventsHaveDuration_ && hasCpuData) { - columns.push({ - title: 'CPU Self Time (ms)', - value: function(row) { - return tr.v.ui.createScalarSpan(row.cpuSelfTime, { - unit: tr.v.Unit.byName.timeDurationInMs, - ownerDocument: ownerDocument - }); - }, - width: '<upated further down>', - cmp: function(rowA, rowB) { - return rowA.cpuSelfTime - rowB.cpuSelfTime; - } - }); - } - - var argKeys = tr.b.dictionaryKeys(summary.totalledArgs); - argKeys.sort(); - - var otherKeys = summary.untotallableArgs.slice(0); - otherKeys.sort(); - - argKeys.push.apply(argKeys, otherKeys); - var keysWithColumns = argKeys.slice(0, 4); - var keysInOtherColumn = argKeys.slice(4); - - keysWithColumns.forEach(function(argKey) { - - var hasTotal = summary.totalledArgs[argKey]; - var colDesc = { - title: 'Arg: ' + argKey, - value: function(row) { - if (row.__proto__ !== tr.ui.analysis.MultiEventSummary.prototype) { - var argView = - document.createElement('tr-ui-a-generic-object-view'); - argView.object = row.args[argKey]; - return argView; - } - if (hasTotal) - return row.totalledArgs[argKey]; - return ''; - }, - width: '<upated further down>' - }; - if (hasTotal) { - colDesc.cmp = function(rowA, rowB) { - return rowA.args[argKey] - rowB.args[argKey]; - }; - } - columns.push(colDesc); - }); - - if (keysInOtherColumn.length) { - columns.push({ - title: 'Other Args', - value: function(row) { - if (row.__proto__ === tr.ui.analysis.MultiEventSummary.prototype) - return ''; - var argView = - document.createElement('tr-ui-a-generic-object-view'); - var obj = {}; - for (var i = 0; i < keysInOtherColumn.length; i++) - obj[keysInOtherColumn[i]] = row.args[keysInOtherColumn[i]]; - argView.object = obj; - return argView; - }, - width: '<upated further down>' - }); - } - - var colWidthPercentage; - if (columns.length == 1) - colWidthPercentage = '100%'; - else - colWidthPercentage = (100 / (columns.length - 1)).toFixed(3) + '%'; - - for (var i = 1; i < columns.length; i++) - columns[i].width = colWidthPercentage; - - this.$.table.tableColumns = columns; - }, - - updateRows_: function(summary) { - this.$.table.sortColumnIndex = 0; - function Row(event) { - this.event = event; - } - Row.prototype = { - get start() { return this.event.start; }, - get duration() { return this.event.duration; }, - get cpuDuration() { return this.event.cpuDuration; }, - get selfTime() { return this.event.selfTime; }, - get cpuSelfTime() { return this.event.cpuSelfTime; }, - get args() { return this.event.args; } - }; - - this.$.table.tableRows = this.selection_.map(function(event) { - return new Row(event); - }); - this.$.table.footerRows = [summary]; - } - }); -</script> -</polymer-element> - - diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_event_details_table_test.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_event_details_table_test.html deleted file mode 100644 index 0bf2d13e081..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_event_details_table_test.html +++ /dev/null @@ -1,171 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/ui/analysis/multi_event_details_table.html"> -<link rel="import" href="/tracing/ui/base/deep_utils.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var Model = tr.Model; - var Thread = tr.model.Thread; - var EventSet = tr.model.EventSet; - var newSliceEx = tr.c.TestUtils.newSliceEx; - - test('sortingOfFirstColumn', function() { - var model = new Model(); - var thread = model.getOrCreateProcess(1).getOrCreateThread(2); - var tsg = thread.sliceGroup; - var sA = tsg.pushSlice(newSliceEx({title: 'a', start: 1, end: 2, - cpuStart: 1, cpuEnd: 1.75})); - var sB = tsg.pushSlice(newSliceEx({title: 'a', start: 0, end: 3, - cpuStart: 0, cpuEnd: 3})); - var sC = tsg.pushSlice(newSliceEx({title: 'a', start: 4, end: 5, - cpuStart: 3, cpuEnd: 3.75})); - tsg.createSubSlices(); - - var threadTrack = {}; - threadTrack.thread = thread; - - var selection = new EventSet(tsg.slices); - - var viewEl = document.createElement('tr-ui-a-multi-event-details-table'); - viewEl.selection = selection; - this.addHTMLOutput(viewEl); - - var table = viewEl.$.table; - var cmpResult = table.tableColumns[0].cmp(sA, sB); - assert.equal(cmpResult, 1); - }); - - test('withCpuTime', function() { - var model = new Model(); - var thread = model.getOrCreateProcess(1).getOrCreateThread(2); - var tsg = thread.sliceGroup; - tsg.pushSlice(newSliceEx({title: 'a', start: 0, end: 3, - cpuStart: 0, cpuEnd: 3})); - tsg.pushSlice(newSliceEx({title: 'a', start: 1, end: 2, - cpuStart: 1, cpuEnd: 1.75})); - tsg.pushSlice(newSliceEx({title: 'a', start: 4, end: 5, - cpuStart: 3, cpuEnd: 3.75})); - tsg.createSubSlices(); - - var threadTrack = {}; - threadTrack.thread = thread; - - var selection = new EventSet(tsg.slices); - - var viewEl = document.createElement('tr-ui-a-multi-event-details-table'); - viewEl.selection = selection; - this.addHTMLOutput(viewEl); - }); - - test('withoutCpuTime', function() { - var model = new Model(); - var thread = model.getOrCreateProcess(1).getOrCreateThread(2); - var tsg = thread.sliceGroup; - tsg.pushSlice(newSliceEx({title: 'a', start: 0, end: 3})); - tsg.pushSlice(newSliceEx({title: 'a', start: 1, end: 2})); - tsg.pushSlice(newSliceEx({title: 'a', start: 4, end: 5})); - tsg.createSubSlices(); - - var threadTrack = {}; - threadTrack.thread = thread; - - var selection = new EventSet(tsg.slices); - - var viewEl = document.createElement('tr-ui-a-multi-event-details-table'); - viewEl.selection = selection; - this.addHTMLOutput(viewEl); - }); - - - test('withFewerThanFourArgs', function() { - var model = new Model(); - var thread = model.getOrCreateProcess(1).getOrCreateThread(2); - var tsg = thread.sliceGroup; - tsg.pushSlice(newSliceEx({title: 'a', start: 0, end: 3, - args: {value1: 3, value2: 'x', value3: 1}})); - tsg.pushSlice(newSliceEx({title: 'b', start: 1, end: 2, - args: {value1: 3.1, value2: 'y', value3: 2}})); - tsg.pushSlice(newSliceEx({title: 'b', start: 4, end: 5, - args: {value1: 3.2, value2: 'z', value3: 'x'}})); - tsg.createSubSlices(); - - var threadTrack = {}; - threadTrack.thread = thread; - - var selection = new EventSet(tsg.slices); - - var viewEl = document.createElement('tr-ui-a-multi-event-details-table'); - viewEl.selection = selection; - this.addHTMLOutput(viewEl); - }); - - test('withExtraArgs', function() { - var model = new Model(); - var thread = model.getOrCreateProcess(1).getOrCreateThread(2); - var tsg = thread.sliceGroup; - tsg.pushSlice(newSliceEx({title: 'a', start: 0, end: 3, - args: {value1: 3, value2: 'x', value3: 1, - value4: 4, value5: 5, value6: 6}})); - tsg.pushSlice(newSliceEx({title: 'b', start: 1, end: 2, - args: {value1: 3.1, value2: 'y', value3: 2, - value4: 4, value5: 5, value6: 6}})); - tsg.pushSlice(newSliceEx({title: 'b', start: 4, end: 5, - args: {value1: 3.2, value2: 'z', value3: 'x', - value4: 4, value5: 'whoops', value6: 6}})); - tsg.createSubSlices(); - - var threadTrack = {}; - threadTrack.thread = thread; - - var selection = new EventSet(tsg.slices); - - var viewEl = document.createElement('tr-ui-a-multi-event-details-table'); - viewEl.selection = selection; - this.addHTMLOutput(viewEl); - }); - - test('noDuration', function() { - var model = new Model(); - - var fe1 = new tr.model.FlowEvent('cat', 1234, 'title', 7, 10, {}); - var fe2 = new tr.model.FlowEvent('cat', 1234, 'title', 8, 20, {}); - - // Make reading some properties an explosion, as a way to ensure that they - // aren't read. - var failProp = { - get: function() { - throw new Error('Should not be called'); - } - }; - Object.defineProperty(fe1, 'duration', failProp); - Object.defineProperty(fe2, 'duration', failProp); - - Object.defineProperty(fe1, 'subRows', failProp); - Object.defineProperty(fe2, 'subRows', failProp); - - Object.defineProperty(fe1, 'selfTime', failProp); - Object.defineProperty(fe2, 'selfTime', failProp); - - model.flowEvents.push(fe1); - model.flowEvents.push(fe2); - - var selection = new EventSet([fe1, fe2]); - - var viewEl = document.createElement('tr-ui-a-multi-event-details-table'); - viewEl.eventsHaveDuration = false; - viewEl.selection = selection; - this.addHTMLOutput(viewEl); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_event_sub_view.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_event_sub_view.html deleted file mode 100644 index c6333dce9a6..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_event_sub_view.html +++ /dev/null @@ -1,128 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/base.html"> -<link rel="import" href="/tracing/ui/analysis/analysis_sub_view.html"> -<link rel="import" href="/tracing/ui/analysis/selection_summary_table.html"> -<link rel="import" href="/tracing/ui/analysis/multi_event_summary_table.html"> -<link rel="import" href="/tracing/ui/analysis/multi_event_details_table.html"> -<link rel="import" href="/tracing/ui/base/ui.html"> -<link rel="import" href="/tracing/ui/base/table.html"> - -<polymer-element name="tr-ui-a-multi-event-sub-view" - extends="tr-ui-a-sub-view"> - <template> - <style> - :host { - display: flex; - overflow: auto; - } - #content { - display: flex; - flex-direction: column; - flex: 0 1 auto; - align-self: stretch; - } - #content > * { - flex: 0 0 auto; - align-self: stretch; - } - tr-ui-a-multi-event-summary-table { - border-bottom: 1px solid #aaa; - } - - tr-ui-a-selection-summary-table { - margin-top: 1.25em; - border-top: 1px solid #aaa; - background-color: #eee; - font-weight: bold; - margin-bottom: 1.25em; - border-bottom: 1px solid #aaa; - } - </style> - <div id="content"></div> - </template> - <script> - 'use strict'; - - Polymer({ - created: function() { - this.currentSelection_ = undefined; - this.eventsHaveDuration_ = true; - this.eventsHaveSubRows_ = true; - }, - - set selection(selection) { - if (selection.length <= 1) - throw new Error('Only supports multiple items'); - this.setSelectionWithoutErrorChecks(selection); - }, - - get selection() { - return this.currentSelection_; - }, - - setSelectionWithoutErrorChecks: function(selection) { - this.currentSelection_ = selection; - this.updateContents_(); - }, - - get eventsHaveDuration() { - return this.eventsHaveDuration_; - }, - - set eventsHaveDuration(eventsHaveDuration) { - this.eventsHaveDuration_ = eventsHaveDuration; - this.updateContents_(); - }, - - get eventsHaveSubRows() { - return this.eventsHaveSubRows_; - }, - - set eventsHaveSubRows(eventsHaveSubRows) { - this.eventsHaveSubRows_ = eventsHaveSubRows; - this.updateContents_(); - }, - - updateContents_: function() { - var selection = this.currentSelection_; - - this.$.content.textContent = ''; - if (!selection) - return; - - var eventsByTitle = selection.getEventsOrganizedByTitle(); - var numTitles = tr.b.dictionaryLength(eventsByTitle); - - var summaryTableEl = document.createElement( - 'tr-ui-a-multi-event-summary-table'); - summaryTableEl.configure({ - showTotals: numTitles > 1, - eventsByTitle: eventsByTitle, - eventsHaveDuration: this.eventsHaveDuration_, - eventsHaveSubRows: this.eventsHaveSubRows_ - }); - this.$.content.appendChild(summaryTableEl); - - var selectionSummaryTableEl = document.createElement( - 'tr-ui-a-selection-summary-table'); - selectionSummaryTableEl.selection = this.currentSelection_; - this.$.content.appendChild(selectionSummaryTableEl); - - if (numTitles === 1) { - var detailsTableEl = document.createElement( - 'tr-ui-a-multi-event-details-table'); - detailsTableEl.eventsHaveDuration = this.eventsHaveDuration_; - detailsTableEl.eventsHaveSubRows = this.eventsHaveSubRows_; - detailsTableEl.selection = selection; - this.$.content.appendChild(detailsTableEl); - } - } - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_event_sub_view_test.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_event_sub_view_test.html deleted file mode 100644 index 5c26a864b78..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_event_sub_view_test.html +++ /dev/null @@ -1,103 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/ui/analysis/multi_event_sub_view.html"> -<link rel="import" href="/tracing/ui/base/deep_utils.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var Model = tr.Model; - var Thread = tr.model.Thread; - var EventSet = tr.model.EventSet; - var newSliceEx = tr.c.TestUtils.newSliceEx; - var Slice = tr.model.Slice; - - test('differentTitles', function() { - var model = new Model(); - var t53 = model.getOrCreateProcess(52).getOrCreateThread(53); - t53.sliceGroup.pushSlice(newSliceEx( - {title: 'a', start: 0.0, duration: 0.04})); - t53.sliceGroup.pushSlice(newSliceEx( - {title: 'a', start: 0.12, duration: 0.06})); - t53.sliceGroup.pushSlice(newSliceEx( - {title: 'aa', start: 0.5, duration: 0.5})); - t53.sliceGroup.createSubSlices(); - - var t53track = {}; - t53track.thread = t53; - - var selection = new EventSet(); - selection.push(t53.sliceGroup.slices[0]); - selection.push(t53.sliceGroup.slices[1]); - selection.push(t53.sliceGroup.slices[2]); - - var viewEl = document.createElement('tr-ui-a-multi-event-sub-view'); - viewEl.selection = selection; - this.addHTMLOutput(viewEl); - - var summaryTableEl = tr.b.findDeepElementMatching( - viewEl, 'tr-ui-a-multi-event-summary-table'); - assert.isDefined(summaryTableEl); - - assert.isTrue(summaryTableEl.showTotals); - assert.equal(tr.b.dictionaryLength(summaryTableEl.eventsByTitle), 2); - - var selectionSummaryTableEl = tr.b.findDeepElementMatching( - viewEl, 'tr-ui-a-selection-summary-table'); - assert.isDefined(selectionSummaryTableEl); - assert.equal(selectionSummaryTableEl.selection, selection); - - var detailsTableEl = tr.b.findDeepElementMatching( - viewEl, 'tr-ui-a-multi-event-details-table'); - assert.isUndefined(detailsTableEl); - }); - - test('sameTitles', function() { - var model = new Model(); - var t53 = model.getOrCreateProcess(52).getOrCreateThread(53); - t53.sliceGroup.pushSlice(newSliceEx( - {title: 'c', start: 0.0, duration: 0.04})); - t53.sliceGroup.pushSlice(newSliceEx( - {title: 'c', start: 0.12, duration: 0.06})); - t53.sliceGroup.createSubSlices(); - - var t53track = {}; - t53track.thread = t53; - - var selection = new EventSet(); - selection.push(t53.sliceGroup.slices[0]); - selection.push(t53.sliceGroup.slices[1]); - - var viewEl = document.createElement('tr-ui-a-multi-event-sub-view'); - viewEl.selection = selection; - this.addHTMLOutput(viewEl); - - var summaryTableEl = tr.b.findDeepElementMatching( - viewEl, 'tr-ui-a-multi-event-summary-table'); - assert.isDefined(summaryTableEl); - - assert.isFalse(summaryTableEl.showTotals); - assert.equal(tr.b.dictionaryLength(summaryTableEl.eventsByTitle), 1); - - var selectionSummaryTableEl = tr.b.findDeepElementMatching( - viewEl, 'tr-ui-a-selection-summary-table'); - assert.isDefined(selectionSummaryTableEl); - assert.equal(selectionSummaryTableEl.selection, selection); - - var detailsTableEl = tr.b.findDeepElementMatching( - viewEl, 'tr-ui-a-multi-event-details-table'); - assert.isDefined(detailsTableEl); - assert.equal(detailsTableEl.selection, selection); - }); - -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_event_summary.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_event_summary.html deleted file mode 100644 index 64cd636efcc..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_event_summary.html +++ /dev/null @@ -1,205 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/base.html"> -<link rel="import" href="/tracing/base/iteration_helpers.html"> -<link rel="import" href="/tracing/base/statistics.html"> - -<script> -'use strict'; -tr.exportTo('tr.ui.analysis', function() { - function MultiEventSummary(title, events) { - this.title = title; - this.duration_ = undefined; - this.selfTime_ = undefined; - this.events_ = events; - - this.cpuTimesComputed_ = false; - this.cpuSelfTime_ = undefined; - this.cpuDuration_ = undefined; - - this.maxDuration_ = undefined; - this.maxCpuDuration_ = undefined; - this.maxSelfTime_ = undefined; - this.maxCpuSelfTime_ = undefined; - - this.untotallableArgs_ = []; - this.totalledArgs_ = undefined; - }; - MultiEventSummary.prototype = { - - set title(title) { - if (title == 'Totals') - this.totalsRow = true; - this.title_ = title; - }, - - get title() { - return this.title_; - }, - - get duration() { - if (this.duration_ === undefined) { - this.duration_ = tr.b.Statistics.sum( - this.events_, function(event) { - return event.duration; - }); - } - return this.duration_; - }, - - get cpuSelfTime() { - this.computeCpuTimesIfNeeded_(); - return this.cpuSelfTime_; - }, - - get cpuDuration() { - this.computeCpuTimesIfNeeded_(); - return this.cpuDuration_; - }, - - computeCpuTimesIfNeeded_: function() { - if (this.cpuTimesComputed_) - return; - this.cpuTimesComputed_ = true; - - var cpuSelfTime = 0; - var cpuDuration = 0; - var hasCpuData = false; - for (var event of this.events_) { - if (event.cpuDuration !== undefined) { - cpuDuration += event.cpuDuration; - hasCpuData = true; - } - - if (event.cpuSelfTime !== undefined) { - cpuSelfTime += event.cpuSelfTime; - hasCpuData = true; - } - } - if (hasCpuData) { - this.cpuDuration_ = cpuDuration; - this.cpuSelfTime_ = cpuSelfTime; - } - }, - - get selfTime() { - if (this.selfTime_ === undefined) { - this.selfTime_ = 0; - for (var event of this.events_) - if (event.selfTime !== undefined) - this.selfTime_ += event.selfTime; - } - return this.selfTime_; - }, - - get events() { - return this.events_; - }, - - get numEvents() { - return this.events_.length; - }, - - get numAlerts() { - if (this.numAlerts_ === undefined) { - this.numAlerts_ = tr.b.Statistics.sum(this.events_, function(event) { - return event.associatedAlerts.length; - }); - } - return this.numAlerts_; - }, - - get untotallableArgs() { - this.updateArgsIfNeeded_(); - return this.untotallableArgs_; - }, - - get totalledArgs() { - this.updateArgsIfNeeded_(); - return this.totalledArgs_; - }, - - - get maxDuration() { - if (this.maxDuration_ === undefined) { - this.maxDuration_ = tr.b.Statistics.max( - this.events_, function(event) { - return event.duration; - }); - } - return this.maxDuration_; - }, - - - get maxCpuDuration() { - if (this.maxCpuDuration_ === undefined) { - this.maxCpuDuration_ = tr.b.Statistics.max( - this.events_, function(event) { - return event.cpuDuration; - }); - } - return this.maxCpuDuration_; - }, - - - get maxSelfTime() { - if (this.maxSelfTime_ === undefined) { - this.maxSelfTime_ = tr.b.Statistics.max( - this.events_, function(event) { - return event.selfTime; - }); - } - return this.maxSelfTime_; - }, - - - get maxCpuSelfTime() { - if (this.maxCpuSelfTime_ === undefined) { - this.maxCpuSelfTime_ = tr.b.Statistics.max( - this.events_, function(event) { - return event.cpuSelfTime; - }); - } - return this.maxCpuSelfTime_; - }, - - - updateArgsIfNeeded_: function() { - if (this.totalledArgs_ !== undefined) - return; - - var untotallableArgs = {}; - var totalledArgs = {}; - for (var event of this.events_) { - for (var argName in event.args) { - var argVal = event.args[argName]; - var type = typeof argVal; - if (type !== 'number') { - untotallableArgs[argName] = true; - delete totalledArgs[argName]; - continue; - } - if (untotallableArgs[argName]) { - continue; - } - - if (totalledArgs[argName] === undefined) - totalledArgs[argName] = 0; - totalledArgs[argName] += argVal; - } - } - this.untotallableArgs_ = tr.b.dictionaryKeys(untotallableArgs); - this.totalledArgs_ = totalledArgs; - } - }; - - return { - MultiEventSummary: MultiEventSummary - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_event_summary_table.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_event_summary_table.html deleted file mode 100644 index 06ec9cbc17c..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_event_summary_table.html +++ /dev/null @@ -1,316 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/base.html"> -<link rel="import" href="/tracing/base/iteration_helpers.html"> -<link rel="import" href="/tracing/base/statistics.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/ui/analysis/analysis_link.html"> -<link rel="import" href="/tracing/ui/analysis/multi_event_summary.html"> -<link rel="import" href="/tracing/ui/base/table.html"> -<link rel="import" href="/tracing/value/ui/scalar_span.html"> -<link rel="import" href="/tracing/value/unit.html"> - -</script> -<polymer-element name='tr-ui-a-multi-event-summary-table'> - <template> - <style> - :host { - display: flex; - } - #table { - flex: 1 1 auto; - align-self: stretch; - } - </style> - <tr-ui-b-table id="table"> - </tr-ui-b-table> - </div> - </template> - <script> - 'use strict'; - - Polymer({ - ready: function() { - this.showTotals_ = false; - this.eventsHaveDuration_ = true; - this.eventsHaveSubRows_ = true; - this.eventsByTitle_ = undefined; - }, - - updateTableColumns_: function(rows, maxValues) { - var hasCpuData = false; - var hasAlerts = false; - rows.forEach(function(row) { - if (row.cpuDuration !== undefined) - hasCpuData = true; - if (row.cpuSelfTime !== undefined) - hasCpuData = true; - if (row.numAlerts) - hasAlerts = true; - }); - - var ownerDocument = this.ownerDocument; - - var columns = []; - - columns.push({ - title: 'Name', - value: function(row) { - if (row.title === 'Totals') - return 'Totals'; - - var linkEl = document.createElement('tr-ui-a-analysis-link'); - linkEl.setSelectionAndContent(function() { - return new tr.model.EventSet(row.events); - }, row.title); - return linkEl; - }, - width: '350px', - cmp: function(rowA, rowB) { - return rowA.title.localeCompare(rowB.title); - } - }); - if (this.eventsHaveDuration_) { - columns.push({ - title: 'Wall Duration', - value: function(row) { - return tr.v.ui.createScalarSpan(row.duration, { - unit: tr.v.Unit.byName.timeDurationInMs, - total: row.totalsRow ? undefined : maxValues.duration, - ownerDocument: ownerDocument, - rightAlign: true - }); - }, - width: '<upated further down>', - cmp: function(rowA, rowB) { - return rowA.duration - rowB.duration; - } - }); - } - - if (this.eventsHaveDuration_ && hasCpuData) { - columns.push({ - title: 'CPU Duration', - value: function(row) { - return tr.v.ui.createScalarSpan(row.cpuDuration, { - unit: tr.v.Unit.byName.timeDurationInMs, - total: row.totalsRow ? undefined : maxValues.cpuDuration, - ownerDocument: ownerDocument, - rightAlign: true - }); - }, - width: '<upated further down>', - cmp: function(rowA, rowB) { - return rowA.cpuDuration - rowB.cpuDuration; - } - }); - } - - if (this.eventsHaveSubRows_ && this.eventsHaveDuration_) { - columns.push({ - title: 'Self time', - value: function(row) { - return tr.v.ui.createScalarSpan(row.selfTime, { - unit: tr.v.Unit.byName.timeDurationInMs, - total: row.totalsRow ? undefined : maxValues.selfTime, - ownerDocument: ownerDocument, - rightAlign: true - }); - }, - width: '<upated further down>', - cmp: function(rowA, rowB) { - return rowA.selfTime - rowB.selfTime; - } - }); - } - - if (this.eventsHaveSubRows_ && this.eventsHaveDuration_ && hasCpuData) { - columns.push({ - title: 'CPU Self Time', - value: function(row) { - return tr.v.ui.createScalarSpan(row.cpuSelfTime, { - unit: tr.v.Unit.byName.timeDurationInMs, - total: row.totalsRow ? undefined : maxValues.cpuSelfTime, - ownerDocument: ownerDocument, - rightAlign: true - }); - }, - width: '<upated further down>', - cmp: function(rowA, rowB) { - return rowA.cpuSelfTime - rowB.cpuSelfTime; - } - }); - } - columns.push({ - title: 'Occurrences', - value: function(row) { - return row.numEvents; - }, - width: '<upated further down>', - cmp: function(rowA, rowB) { - return rowA.numEvents - rowB.numEvents; - } - }); - - var alertsColumnIndex; - if (hasAlerts) { - columns.push({ - title: 'Num Alerts', - value: function(row) { - return row.numAlerts; - }, - width: '<upated further down>', - cmp: function(rowA, rowB) { - return rowA.numAlerts - rowB.numAlerts; - } - }); - alertsColumnIndex = columns.length - 1; - } - var colWidthPercentage; - if (columns.length == 1) - colWidthPercentage = '100%'; - else - colWidthPercentage = (100 / (columns.length - 1)).toFixed(3) + '%'; - - for (var i = 1; i < columns.length; i++) - columns[i].width = colWidthPercentage; - - this.$.table.tableColumns = columns; - - if (hasAlerts) { - this.$.table.sortColumnIndex = alertsColumnIndex; - this.$.table.sortDescending = true; - } - }, - - configure: function(config) { - if (config.eventsByTitle === undefined) - throw new Error('Required: eventsByTitle'); - - if (config.showTotals !== undefined) - this.showTotals_ = config.showTotals; - else - this.showTotals_ = true; - - if (config.eventsHaveDuration !== undefined) - this.eventsHaveDuration_ = config.eventsHaveDuration; - else - this.eventsHaveDuration_ = true; - - if (config.eventsHaveSubRows !== undefined) - this.eventsHaveSubRows_ = config.eventsHaveSubRows; - else - this.eventsHaveSubRows_ = true; - - this.eventsByTitle_ = config.eventsByTitle; - this.updateContents_(); - }, - - get showTotals() { - return this.showTotals_; - }, - - set showTotals(showTotals) { - this.showTotals_ = showTotals; - this.updateContents_(); - }, - - get eventsHaveDuration() { - return this.eventsHaveDuration_; - }, - - set eventsHaveDuration(eventsHaveDuration) { - this.eventsHaveDuration_ = eventsHaveDuration; - this.updateContents_(); - }, - - get eventsHaveSubRows() { - return this.eventsHaveSubRows_; - }, - - set eventsHaveSubRows(eventsHaveSubRows) { - this.eventsHaveSubRows_ = eventsHaveSubRows; - this.updateContents_(); - }, - - get eventsByTitle() { - return this.eventsByTitle_; - }, - - set eventsByTitle(eventsByTitle) { - this.eventsByTitle_ = eventsByTitle; - this.updateContents_(); - }, - - get selectionBounds() { - return this.selectionBounds_; - }, - - set selectionBounds(selectionBounds) { - this.selectionBounds_ = selectionBounds; - this.updateContents_(); - }, - - updateContents_: function() { - var eventsByTitle; - if (this.eventsByTitle_ !== undefined) - eventsByTitle = this.eventsByTitle_; - else - eventsByTitle = []; - - var allEvents = []; - var rows = []; - tr.b.iterItems( - eventsByTitle, - function(title, eventsOfSingleTitle) { - allEvents.push.apply(allEvents, eventsOfSingleTitle); - var row = new tr.ui.analysis.MultiEventSummary( - title, eventsOfSingleTitle); - rows.push(row); - }); - - this.updateTableColumns_(rows); - this.$.table.tableRows = rows; - - var maxValues = { - duration: undefined, - selfTime: undefined, - cpuSelfTime: undefined, - cpuDuration: undefined - }; - - if (this.eventsHaveDuration) { - for (var column in maxValues) { - maxValues[column] = tr.b.Statistics.max(rows, function(event) { - return event[column]; - }); - } - } - - var footerRows = []; - - if (this.showTotals_) { - var multiEventSummary = new tr.ui.analysis.MultiEventSummary( - 'Totals', allEvents); - footerRows.push(multiEventSummary); - } - - - this.updateTableColumns_(rows, maxValues); - this.$.table.tableRows = rows; - - // TODO(selection bounds). - - // TODO(sorting) - - this.$.table.footerRows = footerRows; - this.$.table.rebuild(); - } - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_event_summary_table_test.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_event_summary_table_test.html deleted file mode 100644 index ebef452ab9e..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_event_summary_table_test.html +++ /dev/null @@ -1,110 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/ui/analysis/multi_event_summary_table.html"> -<link rel="import" href="/tracing/ui/base/deep_utils.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var Model = tr.Model; - var EventSet = tr.model.EventSet; - var newSliceEx = tr.c.TestUtils.newSliceEx; - - test('basicNoCpu', function() { - var model = new Model(); - var thread = model.getOrCreateProcess(1).getOrCreateThread(2); - var tsg = thread.sliceGroup; - tsg.pushSlice(newSliceEx({title: 'a', start: 0, duration: 0.5})); - tsg.pushSlice(newSliceEx({title: 'b', start: 1, duration: 0.5})); - tsg.pushSlice(newSliceEx({title: 'b', start: 2, duration: 0.5})); - tsg.createSubSlices(); - - var threadTrack = {}; - threadTrack.thread = thread; - - var selection = new EventSet(tsg.slices); - - var viewEl = document.createElement('tr-ui-a-multi-event-summary-table'); - viewEl.configure({ - showTotals: true, - eventsHaveDuration: true, - eventsByTitle: selection.getEventsOrganizedByTitle() - }); - this.addHTMLOutput(viewEl); - }); - - test('basicWithCpu', function() { - var model = new Model(); - var thread = model.getOrCreateProcess(1).getOrCreateThread(2); - var tsg = thread.sliceGroup; - tsg.pushSlice(newSliceEx({title: 'a', start: 0, end: 3, - cpuStart: 0, cpuEnd: 3})); - tsg.pushSlice(newSliceEx({title: 'b', start: 1, end: 2, - cpuStart: 1, cpuEnd: 1.75})); - tsg.pushSlice(newSliceEx({title: 'b', start: 4, end: 5, - cpuStart: 3, cpuEnd: 3.75})); - tsg.createSubSlices(); - - var threadTrack = {}; - threadTrack.thread = thread; - - var selection = new EventSet(tsg.slices); - - var viewEl = document.createElement('tr-ui-a-multi-event-summary-table'); - viewEl.configure({ - showTotals: true, - eventsHaveDuration: true, - eventsByTitle: selection.getEventsOrganizedByTitle() - }); - this.addHTMLOutput(viewEl); - }); - - test('noDurationNoSubRows', function() { - var model = new Model(); - - var fe1 = new tr.model.FlowEvent('cat', 1234, 'title', 7, 10, {}); - var fe2 = new tr.model.FlowEvent('cat', 1234, 'title', 8, 20, {}); - - // Make reading some properties an explosion, as a way to ensure that they - // aren't read. - var failProp = { - get: function() { - throw new Error('Should not be called'); - } - }; - Object.defineProperty(fe1, 'duration', failProp); - Object.defineProperty(fe2, 'duration', failProp); - - Object.defineProperty(fe1, 'subRows', failProp); - Object.defineProperty(fe2, 'subRows', failProp); - - Object.defineProperty(fe1, 'selfTime', failProp); - Object.defineProperty(fe2, 'selfTime', failProp); - - model.flowEvents.push(fe1); - model.flowEvents.push(fe2); - - var selection = new EventSet([fe1, fe2]); - - var viewEl = document.createElement('tr-ui-a-multi-event-summary-table'); - viewEl.configure({ - showTotals: true, - eventsHaveDuration: false, - eventsHaveSubRows: false, - eventsByTitle: selection.getEventsOrganizedByTitle() - }); - this.addHTMLOutput(viewEl); - }); - - // TODO(nduca): Tooltippish stuff. -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_event_summary_test.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_event_summary_test.html deleted file mode 100644 index 5f7782b1438..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_event_summary_test.html +++ /dev/null @@ -1,112 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/ui/analysis/multi_event_summary.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var Model = tr.Model; - var newSliceEx = tr.c.TestUtils.newSliceEx; - - test('summaryRowNoCpu', function() { - var model = new Model(); - var thread = model.getOrCreateProcess(1).getOrCreateThread(2); - var tsg = thread.sliceGroup; - - tsg.pushSlice(newSliceEx({title: 'a', start: 0, end: 3})); - tsg.pushSlice(newSliceEx({title: 'bb', start: 1, end: 2})); - tsg.pushSlice(newSliceEx({title: 'bb', start: 4, end: 5})); - tsg.createSubSlices(); - - var row = new tr.ui.analysis.MultiEventSummary('x', tsg.slices.slice(0)); - assert.equal(row.duration, 5); - assert.equal(row.selfTime, 4); - assert.isUndefined(row.cpuDuration); - assert.isUndefined(row.cpuSelfTime); - }); - - test('summaryRowWithCpu', function() { - var model = new Model(); - var thread = model.getOrCreateProcess(1).getOrCreateThread(2); - var tsg = thread.sliceGroup; - - tsg.pushSlice(newSliceEx({title: 'a', start: 0, end: 3, - cpuStart: 0, cpuEnd: 3})); - tsg.pushSlice(newSliceEx({title: 'b', start: 1, end: 2, - cpuStart: 1, cpuEnd: 1.75})); - tsg.pushSlice(newSliceEx({title: 'b', start: 4, end: 5, - cpuStart: 3, cpuEnd: 3.75})); - tsg.createSubSlices(); - - var row = new tr.ui.analysis.MultiEventSummary('x', tsg.slices.slice(0)); - assert.equal(row.duration, 5); - assert.equal(row.selfTime, 4); - assert.equal(row.cpuDuration, 4.5); - assert.equal(row.cpuSelfTime, 3.75); - assert.equal(row.maxDuration, 3); - assert.equal(row.maxSelfTime, 2); - assert.equal(row.maxCpuDuration, 3); - assert.equal(row.maxCpuSelfTime, 2.25); - }); - - test('summaryRowNonSlice', function() { - var model = new Model(); - var thread = model.getOrCreateProcess(1).getOrCreateThread(2); - var tsg = thread.sliceGroup; - - var fe1 = new tr.model.FlowEvent('cat', 1234, 'title', 7, 10, {}); - var fe2 = new tr.model.FlowEvent('cat', 1234, 'title', 8, 20, {}); - model.flowEvents.push(fe1); - model.flowEvents.push(fe2); - - var row = new tr.ui.analysis.MultiEventSummary('a', [fe1, fe2]); - assert.equal(row.duration, 0); - assert.equal(row.selfTime, 0); - assert.isUndefined(row.cpuDuration); - assert.isUndefined(row.cpuSelfTime); - assert.equal(row.maxDuration, 0); - }); - - test('summaryNumAlerts', function() { - var slice = newSliceEx({title: 'b', start: 0, duration: 0.002}); - - var ALERT_INFO_1 = new tr.model.EventInfo( - 'Alert 1', 'Critical alert'); - - var alert = new tr.model.Alert(ALERT_INFO_1, 5, [slice]); - - var row = new tr.ui.analysis.MultiEventSummary('a', [slice]); - assert.equal(row.numAlerts, 1); - }); - - test('argSummary', function() { - var model = new Model(); - var thread = model.getOrCreateProcess(1).getOrCreateThread(2); - var tsg = thread.sliceGroup; - - tsg.pushSlice(newSliceEx({title: 'a', start: 0, end: 3, - args: {value1: 3, value2: 'x', value3: 1}})); - tsg.pushSlice(newSliceEx({title: 'b', start: 1, end: 2, - args: {value1: 3, value2: 'y', value3: 2}})); - tsg.pushSlice(newSliceEx({title: 'b', start: 4, end: 5, - args: {value1: 3, value2: 'z', value3: 'x'}})); - tsg.createSubSlices(); - - var row = new tr.ui.analysis.MultiEventSummary('x', tsg.slices.slice(0)); - assert.deepEqual(row.totalledArgs, {value1: 9}); - assert.deepEqual(row.untotallableArgs, ['value2', 'value3']); - assert.equal(row.maxDuration, 3); - assert.equal(row.maxSelfTime, 2); - }); - -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_flow_event_sub_view.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_flow_event_sub_view.html deleted file mode 100644 index ec185d1844b..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_flow_event_sub_view.html +++ /dev/null @@ -1,40 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/analysis/analysis_sub_view.html"> -<link rel="import" href="/tracing/ui/analysis/multi_event_sub_view.html"> - -<polymer-element name="tr-ui-a-multi-flow-event-sub-view" - extends="tr-ui-a-sub-view"> - <template> - <style> - :host { - display: flex; - } - </style> - <tr-ui-a-multi-event-sub-view id="content"></tr-ui-a-multi-event-sub-view> - </template> - - <script> - 'use strict'; - - Polymer({ - ready: function() { - this.$.content.eventsHaveDuration = false; - this.$.content.eventsHaveSubRows = false; - }, - - set selection(selection) { - this.$.content.selection = selection; - }, - - get selection() { - return this.$.content.selection; - } - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_flow_event_sub_view_test.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_flow_event_sub_view_test.html deleted file mode 100644 index 6a95a25d524..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_flow_event_sub_view_test.html +++ /dev/null @@ -1,39 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/ui/analysis/analysis_view.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var Model = tr.Model; - var EventSet = tr.model.EventSet; - - test('analyzeSelectionWithSingleEvent', function() { - var model = new Model(); - - var fe1 = new tr.model.FlowEvent('cat', 1234, 'title', 7, 10, {}); - var fe2 = new tr.model.FlowEvent('cat', 1234, 'title', 8, 20, {}); - model.flowEvents.push(fe1); - model.flowEvents.push(fe2); - - var selection = new EventSet(); - selection.push(fe1); - selection.push(fe2); - assert.equal(selection.length, 2); - - var subView = document.createElement('tr-ui-a-multi-flow-event-sub-view'); - subView.selection = selection; - - this.addHTMLOutput(subView); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_frame_sub_view.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_frame_sub_view.html deleted file mode 100644 index 1ecf2d02e35..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_frame_sub_view.html +++ /dev/null @@ -1,51 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/ui/analysis/multi_event_sub_view.html"> -<link rel="import" href="/tracing/ui/analysis/analysis_sub_view.html"> - -<polymer-element name="tr-ui-a-multi-frame-sub-view" - extends="tr-ui-a-sub-view"> - <script> - 'use strict'; - - Polymer({ - created: function() { - this.currentSelection_ = undefined; - }, - - set selection(selection) { - this.textContent = ''; - var realView = document.createElement('tr-ui-a-multi-event-sub-view'); - realView.eventsHaveDuration = false; - realView.eventsHaveSubRows = false; - - this.appendChild(realView); - realView.setSelectionWithoutErrorChecks(selection); - - this.currentSelection_ = selection; - }, - - get selection() { - return this.currentSelection_; - }, - - get relatedEventsToHighlight() { - if (!this.currentSelection_) - return undefined; - var selection = new tr.model.EventSet(); - this.currentSelection_.forEach(function(frameEvent) { - frameEvent.associatedEvents.forEach(function(event) { - selection.push(event); - }); - }); - return selection; - } - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_instant_event_sub_view.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_instant_event_sub_view.html deleted file mode 100644 index 7d6adb91c4e..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_instant_event_sub_view.html +++ /dev/null @@ -1,47 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/analysis/analysis_sub_view.html"> -<link rel="import" href="/tracing/ui/analysis/multi_event_sub_view.html"> - -<polymer-element name="tr-ui-a-multi-instant-event-sub-view" - extends="tr-ui-a-sub-view"> - <template> - <style> - :host { - display: block; - } - </style> - <div id='content'></div> - </template> - - <script> - 'use strict'; - - Polymer({ - created: function() { - this.currentSelection_ = undefined; - }, - - set selection(selection) { - this.$.content.textContent = ''; - var realView = document.createElement('tr-ui-a-multi-event-sub-view'); - realView.eventsHaveDuration = false; - realView.eventsHaveSubRows = false; - - this.$.content.appendChild(realView); - realView.setSelectionWithoutErrorChecks(selection); - - this.currentSelection_ = selection; - }, - - get selection() { - return this.currentSelection_; - } - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_instant_event_sub_view_test.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_instant_event_sub_view_test.html deleted file mode 100644 index ba70217fe79..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_instant_event_sub_view_test.html +++ /dev/null @@ -1,43 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/ui/analysis/analysis_view.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var Model = tr.Model; - var EventSet = tr.model.EventSet; - - test('analyzeSelectionWithSingleEvent', function() { - var model = new Model(); - var p52 = model.getOrCreateProcess(52); - var t53 = p52.getOrCreateThread(53); - - var ie1 = new tr.model.ProcessInstantEvent('cat', 'title', 7, 10, {}); - var ie2 = new tr.model.ProcessInstantEvent('cat', 'title', 7, 20, {}); - p52.instantEvents.push(ie1); - p52.instantEvents.push(ie2); - - - var selection = new EventSet(); - selection.push(ie1); - selection.push(ie2); - assert.equal(selection.length, 2); - - var subView = - document.createElement('tr-ui-a-multi-instant-event-sub-view'); - subView.selection = selection; - - this.addHTMLOutput(subView); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_object_sub_view.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_object_sub_view.html deleted file mode 100644 index 8241ab16aa2..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_object_sub_view.html +++ /dev/null @@ -1,93 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/ui/analysis/analysis_link.html"> -<link rel="import" href="/tracing/ui/analysis/analysis_sub_view.html"> -<link rel="import" href="/tracing/ui/base/dom_helpers.html"> -<link rel="import" href="/tracing/ui/base/table.html"> -<link rel="import" href="/tracing/value/ui/scalar_span.html"> -<link rel="import" href="/tracing/value/unit.html"> - -<polymer-element name="tr-ui-a-multi-object-sub-view" - extends="tr-ui-a-sub-view"> - <template> - <style> - :host { - display: flex; - } - </style> - <tr-ui-b-table id="content"></tr-ui-b-table> - </template> - <script> - 'use strict'; - - Polymer({ - created: function() { - this.currentSelection_ = undefined; - }, - - ready: function() { - this.$.content.showHeader = false; - }, - - get selection() { - return this.currentSelection_; - }, - - set selection(selection) { - this.currentSelection_ = selection; - - var objectEvents = tr.b.asArray(selection).sort( - tr.b.Range.compareByMinTimes); - - var timeSpanConfig = { - unit: tr.v.Unit.byName.timeStampInMs, - ownerDocument: this.ownerDocument - }; - var table = this.$.content; - table.tableColumns = [ - { - title: 'First', - value: function(event) { - if (event instanceof tr.model.ObjectSnapshot) - return tr.v.ui.createScalarSpan(event.ts, timeSpanConfig); - - var spanEl = document.createElement('span'); - spanEl.appendChild(tr.v.ui.createScalarSpan( - event.creationTs, timeSpanConfig)); - spanEl.appendChild(tr.ui.b.createSpan({ - textContent: '-', - marginLeft: '4px', - marginRight: '4px' - })); - if (event.deletionTs != Number.MAX_VALUE) { - spanEl.appendChild(tr.v.ui.createScalarSpan( - event.deletionTs, timeSpanConfig)); - } - return spanEl; - }, - width: '200px' - }, - { - title: 'Second', - value: function(event) { - var linkEl = document.createElement('tr-ui-a-analysis-link'); - linkEl.setSelectionAndContent(function() { - return new tr.model.EventSet(event); - }, event.userFriendlyName); - return linkEl; - }, - width: '100%' - } - ]; - table.tableRows = objectEvents; - table.rebuild(); - } - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_object_sub_view_test.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_object_sub_view_test.html deleted file mode 100644 index bcc58afd230..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_object_sub_view_test.html +++ /dev/null @@ -1,47 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/ui/analysis/analysis_view.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var EventSet = tr.model.EventSet; - var ObjectInstance = tr.model.ObjectInstance; - - test('instantiate_analysisWithObjects', function() { - var model = new tr.Model(); - var p1 = model.getOrCreateProcess(1); - var objects = p1.objects; - var i10 = objects.idWasCreated( - '0x1000', 'tr.e.cc', 'LayerTreeHostImpl', 10); - var s10 = objects.addSnapshot('0x1000', 'tr.e.cc', 'LayerTreeHostImpl', 10, - 'snapshot-1'); - var s25 = objects.addSnapshot('0x1000', 'tr.e.cc', 'LayerTreeHostImpl', 25, - 'snapshot-2'); - var s40 = objects.addSnapshot('0x1000', 'tr.e.cc', 'LayerTreeHostImpl', 40, - 'snapshot-3'); - objects.idWasDeleted('0x1000', 'tr.e.cc', 'LayerTreeHostImpl', 45); - - var track = {}; - var selection = new EventSet(); - selection.push(i10); - selection.push(s10); - selection.push(s25); - selection.push(s40); - - var analysisEl = document.createElement('tr-ui-a-multi-object-sub-view'); - analysisEl.selection = selection; - this.addHTMLOutput(analysisEl); - }); - -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_power_sample_sub_view.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_power_sample_sub_view.html deleted file mode 100644 index 2fc86530efb..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_power_sample_sub_view.html +++ /dev/null @@ -1,67 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/iteration_helpers.html"> -<link rel="import" href="/tracing/ui/analysis/analysis_sub_view.html"> -<link rel="import" href="/tracing/ui/analysis/frame_power_usage_chart.html"> -<link rel="import" href="/tracing/ui/analysis/power_sample_summary_table.html"> - -<polymer-element name="tr-ui-a-multi-power-sample-sub-view" - extends="tr-ui-a-sub-view"> - <template> - <style> - :host { - display: flex; - flex-direction: row; - } - #tables { - display: flex; - flex-direction: column; - width: 50%; - } - #chart { - width: 50%; - } - </style> - <div id="tables"> - <tr-ui-a-power-sample-summary-table id="summaryTable"> - </tr-ui-a-power-sample-summary-table> - </div> - <tr-ui-a-frame-power-usage-chart id="chart"> - </tr-ui-a-frame-power-usage-chart> - </template> -</polymer-element> - -<script> -'use strict'; - -// TODO(charliea): Add a dropdown that allows the user to select which type of -// power sample analysis view they want (e.g. table of samples, graph). -Polymer('tr-ui-a-multi-power-sample-sub-view', { - ready: function() { - this.currentSelection_ = undefined; - }, - - get selection() { - return this.currentSelection_; - }, - - set selection(selection) { - this.currentSelection_ = selection; - this.updateContents_(); - }, - - updateContents_: function() { - var samples = this.selection; - var vSyncTimestamps = (!samples ? [] : - tr.b.getFirstElement(samples).series.device.vSyncTimestamps); - - this.$.summaryTable.samples = samples; - this.$.chart.setData(this.selection, vSyncTimestamps); - } -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_power_sample_sub_view_test.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_power_sample_sub_view_test.html deleted file mode 100644 index d22083b29db..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_power_sample_sub_view_test.html +++ /dev/null @@ -1,63 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/model/power_series.html"> -<link rel="import" href="/tracing/ui/analysis/multi_power_sample_sub_view.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - test('instantiate_noSamplesOrVSyncs', function() { - var viewEl = document.createElement('tr-ui-a-multi-power-sample-sub-view'); - viewEl.selection = undefined; - this.addHTMLOutput(viewEl); - }); - - test('instantiate_noVSyncs', function() { - var model = new tr.Model(); - var series = new tr.model.PowerSeries(model.device); - - model.device.vSyncTimestamps = []; - series.addPowerSample(1, 1); - series.addPowerSample(2, 2); - series.addPowerSample(3, 3); - series.addPowerSample(4, 2); - - var view = document.createElement('tr-ui-a-multi-power-sample-sub-view'); - var eventSet = new tr.model.EventSet(series.samples); - view.selection = eventSet; - - this.addHTMLOutput(view); - - assert.deepEqual(view.$.chart.samples, eventSet); - assert.sameDeepMembers(view.$.chart.vSyncTimestamps, []); - }); - - test('instantiate', function() { - var model = new tr.Model(); - var series = new tr.model.PowerSeries(model.device); - - model.device.vSyncTimestamps = [0]; - series.addPowerSample(1, 1); - series.addPowerSample(2, 2); - series.addPowerSample(3, 3); - series.addPowerSample(4, 2); - - var view = document.createElement('tr-ui-a-multi-power-sample-sub-view'); - var eventSet = new tr.model.EventSet(series.samples); - view.selection = eventSet; - - this.addHTMLOutput(view); - - assert.deepEqual(view.$.chart.samples, eventSet); - assert.sameDeepMembers(view.$.chart.vSyncTimestamps, [0]); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_sample_sub_view.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_sample_sub_view.html deleted file mode 100644 index ab570d12da7..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_sample_sub_view.html +++ /dev/null @@ -1,268 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/multi_dimensional_view.html"> -<link rel="import" href="/tracing/ui/analysis/analysis_sub_view.html"> -<link rel="import" href="/tracing/ui/base/table.html"> -<link rel="import" href="/tracing/value/ui/scalar_span.html"> -<link rel="import" href="/tracing/value/unit.html"> - -<polymer-element name="tr-ui-a-multi-sample-sub-view" - extends="tr-ui-a-sub-view"> - <template> - <style> - :host { display: block; } - #control { - background-color: #e6e6e6; - background-image: -webkit-gradient(linear, 0 0, 0 100%, - from(#E5E5E5), to(#D1D1D1)); - flex: 0 0 auto; - overflow-x: auto; - } - #control::-webkit-scrollbar { height: 0px; } - #control { - font-size: 12px; - display: flex; - flex-direction: row; - align-items: stretch; - margin: 1px; - margin-right: 2px; - } - </style> - <div id="control"> - Sample View Option - </div> - <tr-ui-b-table id="table"> - </tr-ui-b-table> - </template> - - <script> - 'use strict'; - - (function() { - var MultiDimensionalViewBuilder = tr.b.MultiDimensionalViewBuilder; - var SAMPLE_TYPE = { - COMPILER: 'compiler', - EXTERNAL: 'external', - GC: 'gc', - NATIVEV8: '[native v8]', - OTHER: 'other', - UNKNOWN: 'unknown' - }; - - Polymer({ - created: function() { - this.viewOption_ = undefined; - this.selection_ = undefined; - }, - - ready: function() { - var viewSelector = tr.ui.b.createSelector( - this, 'viewOption', 'tracing.ui.analysis.multi_sample_sub_view', - MultiDimensionalViewBuilder.ViewType.TOP_DOWN_TREE_VIEW, - [ - { - label: 'Top-down (Tree)', - value: MultiDimensionalViewBuilder.ViewType.TOP_DOWN_TREE_VIEW - }, - { - label: 'Top-down (Heavy)', - value: MultiDimensionalViewBuilder.ViewType.TOP_DOWN_HEAVY_VIEW - }, - { - label: 'Bottom-up (Heavy)', - value: MultiDimensionalViewBuilder.ViewType.BOTTOM_UP_HEAVY_VIEW - } - ]); - this.$.control.appendChild(viewSelector); - this.$.table.selectionMode = tr.ui.b.TableFormat.SelectionMode.ROW; - }, - - get selection() { - return this.selection_; - }, - - set selection(selection) { - this.selection_ = selection; - this.updateContents_(); - }, - - get viewOption() { - return this.viewOption_; - }, - - set viewOption(viewOption) { - this.viewOption_ = viewOption; - this.updateContents_(); - }, - - createSamplingSummary_: function(selection, viewOption) { - var builder = new MultiDimensionalViewBuilder( - 1 /* dimensions */, 1 /* valueCount */); - var samples = selection.getEventsOrganizedByBaseType().sample; - - samples.forEach(function(sample) { - builder.addPath([sample.getUserFriendlyStackTrace().reverse()], - [1], MultiDimensionalViewBuilder.ValueKind.SELF); - }); - - return builder.buildView(viewOption); - }, - - // Constructs function name and file name of sample - // if it is compiler, external, gc, other, or unknown. - processTypedSampleRow_: function(row) { - var title = row.title[0]; - switch (title) { - case SAMPLE_TYPE.COMPILER: - case SAMPLE_TYPE.EXTERNAL: - case SAMPLE_TYPE.GC: - case SAMPLE_TYPE.OTHER: - row.functionName = title; - row.fileName = 'N/A'; - return true; - case SAMPLE_TYPE.UNKNOWN: - row.functionName = SAMPLE_TYPE.UNKNOWN; - row.fileName = SAMPLE_TYPE.UNKNOWN; - return true; - default: - return false; - } - }, - - // Constructs function name and file name of native v8 sample. - processNativeV8SampleRow_: function(row) { - var title = row.title[0]; - if (!title.includes(SAMPLE_TYPE.NATIVEV8)) - return false; - var arr = title.split(SAMPLE_TYPE.NATIVEV8); - row.functionName = arr[0].trim(); - if (row.functionName === '') - row.functionName = '(anonymous function)'; - row.fileName = SAMPLE_TYPE.NATIVEV8; - var fileNameSuffix = arr[1].trim(); - if (fileNameSuffix !== '') - row.fileName += ' ' + fileNameSuffix; - return true; - }, - - // Constructs function name and file name for sample. - processGeneralSampleRow_: function(row) { - var title = row.title[0]; - var idx = title.lastIndexOf(' '); - if (idx === -1) { - row.functionName = title; - row.fileName = 'unknown'; - return; - } - var prefix = title.substr(0, idx); - var suffix = title.substr(idx + 1); - if (suffix.startsWith('v8/')) { - row.functionName = suffix; - row.fileName = 'unknown'; - } else if (suffix === '') { - row.functionName = prefix; - row.fileName = 'unknown'; - } else if (prefix === '') { - row.functionName = '(anonymous function)'; - row.fileName = suffix.substr(suffix.lastIndexOf('/') + 1); - } else { - row.functionName = prefix; - row.fileName = suffix.substr(suffix.lastIndexOf('/') + 1); - } - }, - - processSampleRows_: function(rows) { - rows.forEach(function(row) { - if (!this.processTypedSampleRow_(row) && - !this.processNativeV8SampleRow_(row)) - this.processGeneralSampleRow_(row); - this.processSampleRows_(row.subRows); - }, this); - }, - - updateContents_: function() { - if (this.selection === undefined) { - this.$.table.tableColumns = []; - this.$.table.tableRows = []; - this.$.table.rebuild(); - return; - } - - var samplingData = this.createSamplingSummary_( - this.selection, this.viewOption); - var total = samplingData.values[0].total; - var columns = [ - this.createPercentColumn_('Total', total), - this.createSamplesColumn_('Total'), - this.createPercentColumn_('Self', total), - this.createSamplesColumn_('Self'), - { - title: 'Function Name', - value: function(row) { return row.functionName; }, - width: '150px', - cmp: function(a, b) { - return a.functionName.localeCompare(b.functionName); - }, - showExpandButtons: true - }, - { - title: 'Location', - value: function(row) { return row.fileName; }, - width: '250px', - cmp: function(a, b) { - return a.fileName.localeCompare(b.fileName); - } - } - ]; - - this.processSampleRows_(samplingData.subRows); - this.$.table.tableColumns = columns; - this.$.table.sortColumnIndex = 1 /* Total samples */; - this.$.table.sortDescending = true; - this.$.table.tableRows = samplingData.subRows; - this.$.table.rebuild(); - }, - - createPercentColumn_: function(title, samplingDataTotal) { - var field = title.toLowerCase(); - return { - title: title + ' percent', - value: function(row) { - var percent = row.values[0][field] / samplingDataTotal; - - var span = document.createElement('tr-v-ui-scalar-span'); - span.value = (percent * 100).toFixed(2); - span.percentage = percent; - span.unit = tr.v.Unit.byName.unitlessNumber; - return span; - - }.bind(this), - width: '60px', - cmp: function(a, b) { - return a.values[0][field] - b.values[0][field]; - } - }; - }, - - createSamplesColumn_: function(title) { - var field = title.toLowerCase(); - return { - title: title + ' samples', - value: function(row) { - return row.values[0][field]; - }, - width: '60px', - cmp: function(a, b) { - return a.values[0][field] - b.values[0][field]; - } - }; - } - }); - })(); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_sample_sub_view_test.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_sample_sub_view_test.html deleted file mode 100644 index 4eca3673357..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_sample_sub_view_test.html +++ /dev/null @@ -1,118 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/ui/analysis/multi_sample_sub_view.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var newSampleNamed = tr.c.TestUtils.newSampleNamed; - - function instantiateWithTraces(traces) { - var t53; - var m = tr.c.TestUtils.newModelWithEvents([], { - shiftWorldToZero: false, - pruneContainers: false, - customizeModelCallback: function(model) { - t53 = model.getOrCreateProcess(52).getOrCreateThread(53); - traces.forEach(function(trace, index) { - model.samples.push( - newSampleNamed(t53, 'X', 'cat', trace, index * 0.02)); - }); - } - }); - - var t53track = {}; - t53track.thread = t53; - - var selection = new tr.model.EventSet(); - for (var i = 0; i < t53.samples.length; i++) - selection.push(t53.samples[i]); - - var view = document.createElement('tr-ui-a-multi-sample-sub-view'); - view.style.height = '500px'; - this.addHTMLOutput(view); - view.selection = selection; - return view; - } - - test('instantiate_flat', function() { - instantiateWithTraces.call(this, [ - ['BBB'], - ['AAA'], - ['AAA'], - ['Sleeping'], - ['BBB'], - ['AAA'], - ['CCC'], - ['Sleeping'] - ]); - }); - - test('instantiate_nested', function() { - instantiateWithTraces.call(this, [ - ['AAA', 'BBB'], - ['AAA', 'BBB', 'CCC'], - ['AAA', 'BBB'], - ['BBB', 'AAA', 'BBB'], - ['BBB', 'AAA', 'BBB'], - ['BBB', 'AAA', 'BBB'] - ]); - }); - - test('processSampleRows', function() { - var view = instantiateWithTraces.call(this, [ - ['gc'], - ['external'], - ['compiler'], - ['other'], - ['unknown'], - [' [native v8] promise.js:1'], - ['dispatch [native v8] promise.js:2'], - ['onDispatch http://google.com/a.js:1'], - [' http://google.com/a.js:2'], - ['f '], - ['v8/LoadTime'], - ['f'] - ]); - var rows = view.$.table.tableRows; - - assert.deepEqual(rows.map(r => r.functionName), [ - 'gc', - 'external', - 'compiler', - 'other', - 'unknown', - '(anonymous function)', - 'dispatch', - 'onDispatch', - '(anonymous function)', - 'f', - 'v8/LoadTime', - 'f' - ]); - - assert.deepEqual(rows.map(r => r.fileName), [ - 'N/A', - 'N/A', - 'N/A', - 'N/A', - 'unknown', - '[native v8] promise.js:1', - '[native v8] promise.js:2', - 'a.js:1', - 'a.js:2', - 'unknown', - 'unknown', - 'unknown' - ]); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_thread_slice_sub_view.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_thread_slice_sub_view.html deleted file mode 100644 index 54c1c324ab2..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_thread_slice_sub_view.html +++ /dev/null @@ -1,94 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/analysis/analysis_sub_view.html"> -<link rel="import" href="/tracing/ui/analysis/multi_event_sub_view.html"> -<link rel="import" href="/tracing/ui/analysis/related_events.html"> - -<polymer-element name="tr-ui-a-multi-thread-slice-sub-view" - extends="tr-ui-a-sub-view"> - <template> - <style> - :host { - display: flex; - } - #content { - display: flex; - flex: 1 1 auto; - } - #content > tr-ui-a-related-events { - margin-left: 8px; - flex: 0 1 200px; - } - </style> - <div id="content"></div> - </template> - - <script> - 'use strict'; - - Polymer({ - created: function() { - this.selection_ = undefined; - }, - - get selection() { - return this.selection_; - }, - - set selection(selection) { - this.selection_ = selection; - - // TODO(nduca): This is a gross hack for cc Frame Viewer, but its only - // the frame viewer that needs this feature, so ~shrug~. - // We check for its presence so that we do not have a hard dependency - // on frame viewer. - if (tr.isExported('tr.ui.e.chrome.cc.RasterTaskSelection')) { - if (tr.ui.e.chrome.cc.RasterTaskSelection.supports(selection)) { - var ltvSelection = new tr.ui.e.chrome.cc.RasterTaskSelection( - selection); - - var ltv = new tr.ui.e.chrome.cc.LayerTreeHostImplSnapshotView(); - ltv.objectSnapshot = ltvSelection.containingSnapshot; - ltv.selection = ltvSelection; - ltv.extraHighlightsByLayerId = ltvSelection.extraHighlightsByLayerId; - - this.$.content.textContent = ''; - this.$.content.appendChild(ltv); - - this.requiresTallView_ = true; - return; - } - } - - this.$.content.textContent = ''; - - var mesv = document.createElement('tr-ui-a-multi-event-sub-view'); - mesv.selection = selection; - this.$.content.appendChild(mesv); - - var relatedEvents = document.createElement('tr-ui-a-related-events'); - relatedEvents.setRelatedEvents(selection); - - if (relatedEvents.hasRelatedEvents()) { - this.$.content.appendChild(relatedEvents); - } - }, - - get requiresTallView() { - if (this.$.content.children.length === 0) - return false; - var childTagName = this.$.content.children[0].tagName; - if (childTagName === 'TR-UI-A-MULTI-EVENT-SUB-VIEW') - return false; - - // Using raster task view. - return true; - } - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_thread_slice_sub_view_test.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_thread_slice_sub_view_test.html deleted file mode 100644 index ce8e070aa3e..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_thread_slice_sub_view_test.html +++ /dev/null @@ -1,85 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/model/thread_slice.html"> -<link rel="import" href="/tracing/ui/analysis/multi_thread_slice_sub_view.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var newSliceEx = tr.c.TestUtils.newSliceEx; - var newFlowEventEx = tr.c.TestUtils.newFlowEventEx; - - test('instantiate', function() { - var model = new tr.Model(); - var t53 = model.getOrCreateProcess(52).getOrCreateThread(53); - t53.sliceGroup.pushSlice( - newSliceEx({title: 'a', start: 0.0, duration: 0.5, - type: tr.model.ThreadSlice})); - t53.sliceGroup.pushSlice( - newSliceEx({title: 'b', start: 1.0, duration: 2, - type: tr.model.ThreadSlice})); - t53.sliceGroup.createSubSlices(); - - var selection = new tr.model.EventSet(); - selection.push(t53.sliceGroup.slices[0]); - selection.push(t53.sliceGroup.slices[1]); - - var viewEl = document.createElement('tr-ui-a-multi-thread-slice-sub-view'); - viewEl.selection = selection; - this.addHTMLOutput(viewEl); - }); - - test('withFlows', function() { - var m = tr.c.TestUtils.newModel(function(m) { - m.p1 = m.getOrCreateProcess(1); - - m.t2 = m.p1.getOrCreateThread(2); - m.t3 = m.p1.getOrCreateThread(3); - m.t4 = m.p1.getOrCreateThread(4); - - m.sA = m.t2.sliceGroup.pushSlice( - newSliceEx({title: 'a', start: 0, end: 5, - type: tr.model.ThreadSlice})); - m.sB = m.t3.sliceGroup.pushSlice( - newSliceEx({title: 'b', start: 10, end: 15, - type: tr.model.ThreadSlice})); - m.sC = m.t4.sliceGroup.pushSlice( - newSliceEx({title: 'c', start: 20, end: 20, - type: tr.model.ThreadSlice})); - - m.t2.createSubSlices(); - m.t3.createSubSlices(); - m.t4.createSubSlices(); - - m.f1 = newFlowEventEx({ - 'title': 'flowish', start: 0, end: 10, - startSlice: m.sA, - endSlice: m.sB - }); - m.f2 = newFlowEventEx({ - 'title': 'flowish', start: 15, end: 21, - startSlice: m.sB, - endSlice: m.sC - }); - }); - - var selection = new tr.model.EventSet(); - selection.push(m.sA); - selection.push(m.sB); - selection.push(m.sC); - - var viewEl = document.createElement('tr-ui-a-multi-thread-slice-sub-view'); - viewEl.selection = selection; - this.addHTMLOutput(viewEl); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_thread_time_slice_sub_view.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_thread_time_slice_sub_view.html deleted file mode 100644 index 6fba8d2e857..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_thread_time_slice_sub_view.html +++ /dev/null @@ -1,42 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/analysis/analysis_sub_view.html"> -<link rel="import" href="/tracing/ui/analysis/multi_event_sub_view.html"> - -<polymer-element name="tr-ui-a-multi-thread-time-slice-sub-view" - extends="tr-ui-a-sub-view"> - <template> - <style> - :host { - display: flex; - } - #content { - flex: 1 1 auto; - } - </style> - <tr-ui-a-multi-event-sub-view id="content"></tr-ui-a-multi-event-sub-view> - </template> - - <script> - 'use strict'; - - Polymer({ - ready: function() { - this.$.content.eventsHaveSubRows = false; - }, - - get selection() { - return this.$.content.selection; - }, - - set selection(selection) { - this.$.content.setSelectionWithoutErrorChecks(selection); - } - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_thread_time_slice_sub_view_test.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_thread_time_slice_sub_view_test.html deleted file mode 100644 index a0b88c033c9..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_thread_time_slice_sub_view_test.html +++ /dev/null @@ -1,50 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/extras/importer/linux_perf/ftrace_importer.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/ui/analysis/multi_thread_time_slice_sub_view.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - function createBasicModel() { - var lines = [ - 'Android.launcher-584 [001] d..3 12622.506890: sched_switch: prev_comm=Android.launcher prev_pid=584 prev_prio=120 prev_state=R+ ==> next_comm=Binder_1 next_pid=217 next_prio=120', // @suppress longLineCheck - ' Binder_1-217 [001] d..3 12622.506918: sched_switch: prev_comm=Binder_1 prev_pid=217 prev_prio=120 prev_state=D ==> next_comm=Android.launcher next_pid=584 next_prio=120', // @suppress longLineCheck - 'Android.launcher-584 [001] d..4 12622.506936: sched_wakeup: comm=Binder_1 pid=217 prio=120 success=1 target_cpu=001', // @suppress longLineCheck - 'Android.launcher-584 [001] d..3 12622.506950: sched_switch: prev_comm=Android.launcher prev_pid=584 prev_prio=120 prev_state=R+ ==> next_comm=Binder_1 next_pid=217 next_prio=120', // @suppress longLineCheck - ' Binder_1-217 [001] ...1 12622.507057: tracing_mark_write: B|128|queueBuffer', // @suppress longLineCheck - ' Binder_1-217 [001] ...1 12622.507175: tracing_mark_write: E', - ' Binder_1-217 [001] d..3 12622.507253: sched_switch: prev_comm=Binder_1 prev_pid=217 prev_prio=120 prev_state=S ==> next_comm=Android.launcher next_pid=584 next_prio=120' // @suppress longLineCheck - ]; - - return tr.c.TestUtils.newModelWithEvents([lines.join('\n')], { - shiftWorldToZero: false - }); - } - - test('instantiate', function() { - var m = createBasicModel(); - - var thread = m.findAllThreadsNamed('Binder_1')[0]; - - var selection = new tr.model.EventSet(); - selection.push(thread.timeSlices[0]); - selection.push(thread.timeSlices[1]); - - var viewEl = document.createElement( - 'tr-ui-a-multi-thread-time-slice-sub-view'); - viewEl.selection = selection; - this.addHTMLOutput(viewEl); - }); - -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_user_expectation_sub_view.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_user_expectation_sub_view.html deleted file mode 100644 index 34b70762345..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/multi_user_expectation_sub_view.html +++ /dev/null @@ -1,70 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/ui/analysis/analysis_sub_view.html"> -<link rel="import" href="/tracing/ui/analysis/multi_event_sub_view.html"> -<link rel="import" - href="/tracing/ui/analysis/user_expectation_related_samples_table.html"> - -<polymer-element name="tr-ui-a-multi-user-expectation-sub-view" - extends="tr-ui-a-sub-view"> - <template> - <style> - :host { - display: flex; - flex: 1 1 auto; - } - #events { - margin-left: 8px; - flex: 0 1 200px; - } - </style> - <tr-ui-a-multi-event-sub-view id="realView"></tr-ui-a-multi-event-sub-view> - <div id="events"> - <tr-ui-a-user-expectation-related-samples-table id="relatedSamples"></tr-ui-a-user-expectation-related-samples-table> - </div> - </template> - <script> - 'use strict'; - - Polymer({ - created: function() { - this.currentSelection_ = undefined; - }, - - set selection(selection) { - this.currentSelection_ = selection; - this.$.realView.setSelectionWithoutErrorChecks(selection); - - this.currentSelection_ = selection; - - this.$.relatedSamples.selection = selection; - if (this.$.relatedSamples.hasRelatedSamples()) - this.$.events.style.display = ''; - else - this.$.events.style.display = 'none'; - }, - - get selection() { - return this.currentSelection_; - }, - - get relatedEventsToHighlight() { - if (!this.currentSelection_) - return undefined; - var selection = new tr.model.EventSet(); - this.currentSelection_.forEach(function(ir) { - ir.associatedEvents.forEach(function(event) { - selection.push(event); - }); - }); - return selection; - } - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/object_instance_view.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/object_instance_view.html deleted file mode 100644 index f94aa245f6e..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/object_instance_view.html +++ /dev/null @@ -1,62 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/extension_registry.html"> -<link rel="import" href="/tracing/ui/base/ui.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.analysis', function() { - var ObjectInstanceView = tr.ui.b.define('object-instance-view'); - - ObjectInstanceView.prototype = { - __proto__: HTMLUnknownElement.prototype, - - decorate: function() { - this.objectInstance_ = undefined; - }, - - get requiresTallView() { - return true; - }, - - set modelEvent(obj) { - this.objectInstance = obj; - }, - - get modelEvent() { - return this.objectInstance; - }, - - get objectInstance() { - return this.objectInstance_; - }, - - set objectInstance(i) { - this.objectInstance_ = i; - this.updateContents(); - }, - - updateContents: function() { - throw new Error('Not implemented'); - } - }; - - var options = new tr.b.ExtensionRegistryOptions( - tr.b.TYPE_BASED_REGISTRY_MODE); - options.mandatoryBaseClass = ObjectInstanceView; - options.defaultMetadata = { - showInTrackView: true - }; - tr.b.decorateExtensionRegistry(ObjectInstanceView, options); - - return { - ObjectInstanceView: ObjectInstanceView - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/object_snapshot_view.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/object_snapshot_view.html deleted file mode 100644 index a50747beefa..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/object_snapshot_view.html +++ /dev/null @@ -1,63 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/extension_registry.html"> -<link rel="import" href="/tracing/ui/base/ui.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.analysis', function() { - var ObjectSnapshotView = tr.ui.b.define('object-snapshot-view'); - - ObjectSnapshotView.prototype = { - __proto__: HTMLUnknownElement.prototype, - - decorate: function() { - this.objectSnapshot_ = undefined; - }, - - get requiresTallView() { - return true; - }, - - set modelEvent(obj) { - this.objectSnapshot = obj; - }, - - get modelEvent() { - return this.objectSnapshot; - }, - - get objectSnapshot() { - return this.objectSnapshot_; - }, - - set objectSnapshot(i) { - this.objectSnapshot_ = i; - this.updateContents(); - }, - - updateContents: function() { - throw new Error('Not implemented'); - } - }; - - var options = new tr.b.ExtensionRegistryOptions( - tr.b.TYPE_BASED_REGISTRY_MODE); - options.mandatoryBaseClass = ObjectSnapshotView; - options.defaultMetadata = { - showInstances: true, - showInTrackView: true - }; - tr.b.decorateExtensionRegistry(ObjectSnapshotView, options); - - return { - ObjectSnapshotView: ObjectSnapshotView - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/power_sample_summary_table.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/power_sample_summary_table.html deleted file mode 100644 index ab314e42589..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/power_sample_summary_table.html +++ /dev/null @@ -1,129 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/iteration_helpers.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/ui/base/table.html"> -<link rel="import" href="/tracing/value/unit.html"> - -<polymer-element name="tr-ui-a-power-sample-summary-table"> - <template> - <tr-ui-b-table id="table"></tr-ui-b-table> - </template> - <script> - 'use strict'; - - Polymer({ - ready: function() { - this.$.table.tableColumns = [ - { - title: 'Min power', - width: '100px', - value: function(row) { - return tr.v.Unit.byName.powerInWatts.format(row.min); - } - }, - { - title: 'Max power', - width: '100px', - value: function(row) { - return tr.v.Unit.byName.powerInWatts.format(row.max); - } - }, - { - title: 'Time-weighted average', - width: '100px', - value: function(row) { - return tr.v.Unit.byName.powerInWatts.format( - row.timeWeightedAverage); - } - }, - { - title: 'Energy consumed', - width: '100px', - value: function(row) { - return tr.v.Unit.byName.energyInJoules.format(row.energyConsumed); - } - }, - { - title: 'Sample count', - width: '100%', - value: function(row) { return row.sampleCount; } - } - ]; - this.samples = new tr.model.EventSet(); - }, - - get samples() { - return this.samples_; - }, - - set samples(samples) { - if (samples === this.samples) - return; - - this.samples_ = - (samples === undefined) ? new tr.model.EventSet() : samples; - this.updateContents_(); - }, - - updateContents_: function() { - if (this.samples.length === 0) { - this.$.table.tableRows = []; - } else { - this.$.table.tableRows = [{ - min: this.getMin(), - max: this.getMax(), - timeWeightedAverage: this.getTimeWeightedAverage(), - energyConsumed: this.getEnergyConsumed(), - sampleCount: this.samples.length - }]; - } - - this.$.table.rebuild(); - }, - - getMin: function() { - return Math.min.apply(null, this.samples.map(function(sample) { - return sample.power; - })); - }, - - getMax: function() { - return Math.max.apply(null, this.samples.map(function(sample) { - return sample.power; - })); - }, - - /** - * Returns a time-weighted average of the power consumption (Watts) - * in between the first sample (inclusive) and last sample (exclusive). - */ - getTimeWeightedAverage: function() { - var energyConsumed = this.getEnergyConsumed(); - - if (energyConsumed === 'N/A') - return 'N/A'; - - // Divide by 1000 to convert milliseconds to seconds. - var durationInSeconds = this.samples.bounds.duration / 1000; - - // Convert energy to power in milliwatts by dividing by time in seconds. - return this.getEnergyConsumed() / durationInSeconds; - }, - - getEnergyConsumed: function() { - if (this.samples.length < 2) - return 'N/A'; - - var bounds = this.samples.bounds; - var series = tr.b.getFirstElement(this.samples).series; - return series.getEnergyConsumed(bounds.min, bounds.max); - } - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/power_sample_summary_table_test.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/power_sample_summary_table_test.html deleted file mode 100644 index 82cc98dc1fb..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/power_sample_summary_table_test.html +++ /dev/null @@ -1,137 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/model/power_series.html"> -<link rel="import" href="/tracing/ui/analysis/power_sample_summary_table.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - - var EventSet = tr.model.EventSet; - var Model = tr.Model; - var PowerSeries = tr.model.PowerSeries; - - test('instantiate', function() { - var series = new PowerSeries(new Model().device); - - series.addPowerSample(0, 1); - series.addPowerSample(1000, 2); - series.addPowerSample(2000, 3); - series.addPowerSample(3000, 4); - - var table = document.createElement('tr-ui-a-power-sample-summary-table'); - table.samples = new EventSet(series.samples); - - this.addHTMLOutput(table); - }); - - test('setSamples_undefinedPowerSamples', function() { - var table = document.createElement('tr-ui-a-power-sample-summary-table'); - table.samples = undefined; - - assert.lengthOf(table.$.table.tableRows, 0); - }); - - test('setSamples_noPowerSamples', function() { - var table = document.createElement('tr-ui-a-power-sample-summary-table'); - table.samples = new EventSet([]); - - assert.lengthOf(table.$.table.tableRows, 0); - }); - - test('setSamples_onePowerSample', function() { - var series = new PowerSeries(new Model().device); - - series.addPowerSample(0, 1); - - var table = document.createElement('tr-ui-a-power-sample-summary-table'); - table.samples = new EventSet(series.samples); - - assert.lengthOf(table.$.table.tableRows, 1); - assert.equal(table.$.table.tableRows[0].min, 1); - assert.equal(table.$.table.tableRows[0].max, 1); - assert.equal(table.$.table.tableRows[0].timeWeightedAverage, 'N/A'); - assert.equal(table.$.table.tableRows[0].energyConsumed, 'N/A'); - assert.equal(table.$.table.tableRows[0].sampleCount, 1); - }); - - test('setSamples_twoPowerSamples', function() { - var series = new PowerSeries(new Model().device); - - series.addPowerSample(0, 1); - series.addPowerSample(1000, 2); - - var table = document.createElement('tr-ui-a-power-sample-summary-table'); - table.samples = new EventSet(series.samples); - - assert.lengthOf(table.$.table.tableRows, 1); - assert.equal(table.$.table.tableRows[0].min, 1); - assert.equal(table.$.table.tableRows[0].max, 2); - assert.equal(table.$.table.tableRows[0].timeWeightedAverage, 1); - assert.equal(table.$.table.tableRows[0].energyConsumed, 1); - assert.equal(table.$.table.tableRows[0].sampleCount, 2); - }); - - test('setSamples_threePowerSamples', function() { - var series = new PowerSeries(new Model().device); - - series.addPowerSample(0, 1); - series.addPowerSample(1000, 2); - series.addPowerSample(2000, 3); - - var table = document.createElement('tr-ui-a-power-sample-summary-table'); - table.samples = new EventSet(series.samples); - - assert.lengthOf(table.$.table.tableRows, 1); - assert.equal(table.$.table.tableRows[0].min, 1); - assert.equal(table.$.table.tableRows[0].max, 3); - assert.equal(table.$.table.tableRows[0].timeWeightedAverage, 1.5); - assert.equal(table.$.table.tableRows[0].energyConsumed, 3); - assert.equal(table.$.table.tableRows[0].sampleCount, 3); - }); - - test('setSamples_columnsInitialized', function() { - var series = new PowerSeries(new Model().device); - - series.addPowerSample(0, 1); - series.addPowerSample(1000, 2); - series.addPowerSample(2000, 3); - - var table = document.createElement('tr-ui-a-power-sample-summary-table'); - table.samples = new EventSet(series.samples); - - var row = table.$.table.tableRows[0]; - var columns = table.$.table.tableColumns; - - assert.lengthOf(columns, 5); - - assert.equal(columns[0].title, 'Min power'); - assert.equal(columns[0].width, '100px'); - assert.equal(columns[0].value(row), '1.000 W'); - - assert.equal(columns[1].title, 'Max power'); - assert.equal(columns[1].width, '100px'); - assert.equal(columns[1].value(row), '3.000 W'); - - assert.equal(columns[2].title, 'Time-weighted average'); - assert.equal(columns[2].width, '100px'); - assert.equal(columns[2].value(row), '1.500 W'); - - assert.equal(columns[3].title, 'Energy consumed'); - assert.equal(columns[3].width, '100px'); - assert.equal(columns[3].value(row), '3.000 J'); - - assert.equal(columns[4].title, 'Sample count'); - assert.equal(columns[4].width, '100%'); - assert.equal(columns[4].value(row), 3); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/related_events.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/related_events.html deleted file mode 100644 index faec4d0471e..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/related_events.html +++ /dev/null @@ -1,263 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/range.html"> -<link rel="import" href="/tracing/base/task.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/ui/analysis/analysis_link.html"> -<link rel="import" href="/tracing/ui/analysis/flow_classifier.html"> -<link rel="import" href="/tracing/ui/base/dom_helpers.html"> -<link rel="import" href="/tracing/ui/base/table.html"> - -<polymer-element name="tr-ui-a-related-events"> - <template> - <style> - :host { - display: flex; - flex-direction: column; - } - #table { - flex: 1 1 auto; - align-self: stretch; - } - </style> - <tr-ui-b-table id="table"></tr-ui-b-table> - </template> - - <script> - 'use strict'; - - Polymer({ - ready: function() { - this.eventGroups_ = []; - this.cancelFunctions_ = []; - - this.$.table.tableColumns = [ - { - title: 'Event(s)', - value: function(row) { - var typeEl = document.createElement('span'); - typeEl.innerText = row.type; - if (row.tooltip) - typeEl.title = row.tooltip; - return typeEl; - }, - width: '150px' - }, - { - title: 'Link', - width: '100%', - value: function(row) { - var linkEl = document.createElement('tr-ui-a-analysis-link'); - if (row.name) - linkEl.setSelectionAndContent(row.selection, row.name); - else - linkEl.selection = row.selection; - return linkEl; - } - } - ]; - }, - - hasRelatedEvents: function() { - return (this.eventGroups_ && this.eventGroups_.length > 0); - }, - - setRelatedEvents: function(eventSet) { - this.cancelAllTasks_(); - this.eventGroups_ = []; - this.addConnectedFlows_(eventSet); - this.addConnectedEvents_(eventSet); - this.addOverlappingSamples_(eventSet); - this.updateContents_(); - }, - - addConnectedFlows_: function(eventSet) { - var classifier = new tr.ui.analysis.FlowClassifier(); - eventSet.forEach(function(slice) { - if (slice.inFlowEvents) { - slice.inFlowEvents.forEach(function(flow) { - classifier.addInFlow(flow); - }); - } - if (slice.outFlowEvents) { - slice.outFlowEvents.forEach(function(flow) { - classifier.addOutFlow(flow); - }); - } - }); - if (!classifier.hasEvents()) - return; - - var addToEventGroups = function(type, flowEvent) { - this.eventGroups_.push({ - type: type, - selection: new tr.model.EventSet(flowEvent), - name: flowEvent.title - }); - }; - - classifier.inFlowEvents.forEach( - addToEventGroups.bind(this, 'Incoming flow')); - classifier.outFlowEvents.forEach( - addToEventGroups.bind(this, 'Outgoing flow')); - classifier.internalFlowEvents.forEach( - addToEventGroups.bind(this, 'Internal flow')); - }, - - cancelAllTasks_: function() { - this.cancelFunctions_.forEach(function(cancelFunction) { - cancelFunction(); - }); - this.cancelFunctions_ = []; - }, - - addConnectedEvents_: function(eventSet) { - this.cancelFunctions_.push(this.createEventsLinkIfNeeded_( - 'Preceding events', - 'Add all events that have led to the selected one(s), connected by ' + - 'flow arrows or by call stack.', - eventSet, - function(event, events) { - this.addInFlowEvents_(event, events); - this.addAncestors_(event, events); - if (event.startSlice) - events.push(event.startSlice); - }.bind(this))); - this.cancelFunctions_.push(this.createEventsLinkIfNeeded_( - 'Following events', - 'Add all events that have been caused by the selected one(s), ' + - 'connected by flow arrows or by call stack.', - eventSet, - function(event, events) { - this.addOutFlowEvents_(event, events); - this.addDescendents_(event, events); - if (event.endSlice) - events.push(event.endSlice); - }.bind(this))); - this.cancelFunctions_.push(this.createEventsLinkIfNeeded_( - 'All connected events', - 'Add all events connected to the selected one(s) by flow arrows or ' + - 'by call stack.', - eventSet, - function(event, events) { - this.addInFlowEvents_(event, events); - this.addOutFlowEvents_(event, events); - this.addAncestors_(event, events); - this.addDescendents_(event, events); - if (event.startSlice) - events.push(event.startSlice); - if (event.endSlice) - events.push(event.endSlice); - }.bind(this))); - }, - - createEventsLinkIfNeeded_: function(title, tooltip, events, addFunction) { - events = new tr.model.EventSet(events); - var lengthBefore = events.length; - var task; - var isCanceled = false; - function addEventsUntilTimeout(startingIndex) { - if (isCanceled) - return; - var startingTime = window.performance.now(); - while (startingIndex < events.length) { - addFunction(events[startingIndex], events); - startingIndex++; - // Let's grant ourselves a budget of 8ms. - if (window.performance.now() - startingTime > 8) { - var newTask = new tr.b.Task( - addEventsUntilTimeout.bind(this, startingIndex), this); - task.after(newTask); - task = newTask; - return; - } - } - // Went through all events, add the link. - if (lengthBefore === events.length) - return; - this.eventGroups_.push({ - type: title, - tooltip: tooltip, - selection: events - }); - this.updateContents_(); - }; - function cancelTask() { - isCanceled = true; - } - task = new tr.b.Task(addEventsUntilTimeout.bind(this, 0), this); - tr.b.Task.RunWhenIdle(task); - return cancelTask; - }, - - addInFlowEvents_: function(event, eventSet) { - if (!event.inFlowEvents) - return; - event.inFlowEvents.forEach(function(e) { - eventSet.push(e); - }); - }, - - addOutFlowEvents_: function(event, eventSet) { - if (!event.outFlowEvents) - return; - event.outFlowEvents.forEach(function(e) { - eventSet.push(e); - }); - }, - - addAncestors_: function(event, eventSet) { - if (!event.iterateAllAncestors) - return; - event.iterateAllAncestors(function(e) { - eventSet.push(e); - }); - }, - - addDescendents_: function(event, eventSet) { - if (!event.iterateAllDescendents) - return; - event.iterateAllDescendents(function(e) { - eventSet.push(e); - }); - }, - - addOverlappingSamples_: function(eventSet) { - var samples = new tr.model.EventSet; - eventSet.forEach(function(slice) { - if (!slice.parentContainer || !slice.parentContainer.samples) - return; - var candidates = slice.parentContainer.samples; - var range = tr.b.Range.fromExplicitRange( - slice.start, slice.start + slice.duration); - var filteredSamples = range.filterArray( - candidates, function(value) {return value.start;}); - filteredSamples.forEach(function(sample) { - samples.push(sample); - }); - }.bind(this)); - if (samples.length > 0) { - this.eventGroups_.push({ - type: 'Overlapping samples', - tooltip: 'All samples overlapping the selected slice(s).', - selection: samples - }); - } - }, - - updateContents_: function() { - var table = this.$.table; - if (this.eventGroups_ === undefined) - table.tableRows = []; - else - table.tableRows = this.eventGroups_.slice(); - table.rebuild(); - } - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/related_events_test.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/related_events_test.html deleted file mode 100644 index d7b0107c145..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/related_events_test.html +++ /dev/null @@ -1,217 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/iteration_helpers.html"> -<link rel="import" href="/tracing/base/raf.html"> -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/model/sample.html"> -<link rel="import" href="/tracing/model/thread_slice.html"> -<link rel="import" href="/tracing/ui/analysis/related_events.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var newSliceEx = tr.c.TestUtils.newSliceEx; - var newFlowEventEx = tr.c.TestUtils.newFlowEventEx; - - function createModel() { - var m = tr.c.TestUtils.newModel(function(m) { - m.p1 = m.getOrCreateProcess(1); - - m.t2 = m.p1.getOrCreateThread(2); - m.t3 = m.p1.getOrCreateThread(3); - m.t4 = m.p1.getOrCreateThread(4); - - // Setup samples and slices in this way: - // 0 5 10 15 20 - // _____________________________ - // t2 * - // [ a ][ ]aa - // ----------------------------- - // t3 * * * * * - // * * - // [ b ] - // [bb] - // []bbb - // ----------------------------- - // t4 |c - // ----------------------------- - m.samples.push( - new tr.model.Sample(null, m.t3, 'b10_1', 10), - new tr.model.Sample(null, m.t3, 'b7', 7), - new tr.model.Sample(null, m.t3, 'b12', 12), - new tr.model.Sample(null, m.t3, 'b20', 20), - new tr.model.Sample(null, m.t3, 'b10_2', 10), - new tr.model.Sample(null, m.t3, 'b15_1', 15), - new tr.model.Sample(null, m.t3, 'b15_2', 15), - new tr.model.Sample(null, m.t2, 'a12', 12) - ); - - m.sA = m.t2.sliceGroup.pushSlice( - newSliceEx({title: 'a', start: 0, end: 5, - type: tr.model.ThreadSlice})); - m.sAA = m.t2.sliceGroup.pushSlice( - newSliceEx({title: 'aa', start: 6, end: 8, - type: tr.model.ThreadSlice})); - m.sB = m.t3.sliceGroup.pushSlice( - newSliceEx({title: 'b', start: 10, end: 15, - type: tr.model.ThreadSlice})); - m.sBB = m.t3.sliceGroup.pushSlice( - newSliceEx({title: 'bb', start: 11, end: 14, - type: tr.model.ThreadSlice})); - m.sBBB = m.t3.sliceGroup.pushSlice( - newSliceEx({title: 'bbb', start: 12, end: 13, - type: tr.model.ThreadSlice})); - m.sC = m.t4.sliceGroup.pushSlice( - newSliceEx({title: 'c', start: 20, end: 20, - type: tr.model.ThreadSlice})); - - m.t2.createSubSlices(); - m.t3.createSubSlices(); - m.t4.createSubSlices(); - - // Add flow events. - m.f0 = newFlowEventEx({ - 'title': 'a_aa', start: 5, end: 6, - startSlice: m.sA, - endSlice: m.sAA - }); - m.f1 = newFlowEventEx({ - 'title': 'a_b', start: 0, end: 10, - startSlice: m.sA, - endSlice: m.sB - }); - m.f2 = newFlowEventEx({ - 'title': 'b_bbb', start: 10, end: 12, - startSlice: m.sB, - endSlice: m.sBBB - }); - m.f3 = newFlowEventEx({ - 'title': 'bbb_c', start: 13, end: 20, - startSlice: m.sBBB, - endSlice: m.sC - }); - }); - return m; - }; - - test('instantiate', function() { - var m = createModel(); - - var viewEl = document.createElement('tr-ui-a-related-events'); - var selection = new tr.model.EventSet( - [m.sA, m.f0, m.sAA, m.f1, m.sB, m.f2, m.sBB, m.sBBB, m.f3, m.sC]); - viewEl.setRelatedEvents(selection); - this.addHTMLOutput(viewEl); - tr.b.forceAllPendingTasksToRunForTest(); - - // Check that the element handles multiple setRelatedEvents calls correctly. - assert.lengthOf(viewEl.$.table.tableRows, 5); - viewEl.setRelatedEvents(selection); - assert.lengthOf(viewEl.$.table.tableRows, 5); - }); - - test('validateFlows', function() { - var m = createModel(); - - var viewEl = document.createElement('tr-ui-a-related-events'); - viewEl.setRelatedEvents(new tr.model.EventSet([m.sB, m.sBB, m.sBBB])); - this.addHTMLOutput(viewEl); - tr.b.forceAllPendingTasksToRunForTest(); - - var inFlows, outFlows, internalFlows; - viewEl.$.table.tableRows.forEach(function(row) { - if (row.type === 'Incoming flow') { - assert.isUndefined(inFlows); - inFlows = row.selection; - } - if (row.type === 'Outgoing flow') { - assert.isUndefined(outFlows); - outFlows = row.selection; - } - if (row.type === 'Internal flow') { - assert.isUndefined(internalFlows); - internalFlows = row.selection; - } - }); - assert.equal(inFlows.length, 1); - assert.equal(tr.b.getOnlyElement(inFlows).title, 'a_b'); - assert.equal(outFlows.length, 1); - assert.equal(tr.b.getOnlyElement(outFlows).title, 'bbb_c'); - assert.equal(internalFlows.length, 1); - assert.equal(tr.b.getOnlyElement(internalFlows).title, 'b_bbb'); - }); - - test('validateConnectedEvents', function() { - var m = createModel(); - - var viewEl = document.createElement('tr-ui-a-related-events'); - viewEl.setRelatedEvents(new tr.model.EventSet([m.sBB])); - this.addHTMLOutput(viewEl); - tr.b.forceAllPendingTasksToRunForTest(); - - var precedingEvents, followingEvents, allEvents; - viewEl.$.table.tableRows.forEach(function(row) { - if (row.type === 'Preceding events') { - assert.isUndefined(precedingEvents); - precedingEvents = row.selection; - } - if (row.type === 'Following events') { - assert.isUndefined(followingEvents); - followingEvents = row.selection; - } - if (row.type === 'All connected events') { - assert.isUndefined(allEvents); - allEvents = row.selection; - } - }); - - var precedingTitles = precedingEvents.map(function(e) { - return e.title; - }); - assert.sameMembers(precedingTitles, ['a', 'a_b', 'b', 'bb']); - - var followingTitles = followingEvents.map(function(e) { - return e.title; - }); - assert.sameMembers(followingTitles, ['bb', 'bbb', 'bbb_c', 'c']); - - var allTitles = allEvents.map(function(e) { - return e.title; - }); - assert.sameMembers(allTitles, - ['a', 'a_aa', 'aa', 'a_b', 'b', 'bb', 'bbb', 'b_bbb', 'bbb_c', 'c']); - }); - - test('validateOverlappingSamples', function() { - var m = createModel(); - - var viewEl = document.createElement('tr-ui-a-related-events'); - viewEl.setRelatedEvents(new tr.model.EventSet([m.sB])); - this.addHTMLOutput(viewEl); - tr.b.forceAllPendingTasksToRunForTest(); - - var overlappingSamples; - viewEl.$.table.tableRows.forEach(function(row) { - if (row.type === 'Overlapping samples') { - assert.isUndefined(overlappingSamples); - overlappingSamples = row.selection; - } - }); - - var samplesTitles = overlappingSamples.map(function(e) { - return e.title; - }); - assert.sameMembers(samplesTitles, - ['b10_1', 'b10_2', 'b12', 'b15_1', 'b15_2']); - }); - -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/selection_summary_table.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/selection_summary_table.html deleted file mode 100644 index cc3c00e410c..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/selection_summary_table.html +++ /dev/null @@ -1,94 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/base.html"> -<link rel="import" href="/tracing/ui/base/table.html"> -<link rel="import" href="/tracing/value/ui/scalar_span.html"> -<link rel="import" href="/tracing/value/unit.html"> - -<polymer-element name='tr-ui-a-selection-summary-table'> - <template> - <style> - :host { - display: flex; - } - #table { - flex: 1 1 auto; - align-self: stretch; - } - </style> - <tr-ui-b-table id="table"> - </tr-ui-b-table> - </div> - </template> - <script> - 'use strict'; - - Polymer({ - created: function() { - this.selection_ = new tr.b.Range(); - }, - - ready: function() { - this.$.table.showHeader = false; - this.$.table.tableColumns = [ - { - title: 'Name', - value: function(row) { return row.title; }, - width: '350px' - }, - { - title: 'Value', - width: '100%', - value: function(row) { - return row.value; - } - } - ]; - }, - - get selection() { - return this.selection_; - }, - - set selection(selection) { - this.selection_ = selection; - this.updateContents_(); - }, - - updateContents_: function() { - var selection = this.selection_; - var rows = []; - var hasRange; - if (this.selection_ && (!selection.bounds.isEmpty)) - hasRange = true; - else - hasRange = false; - - rows.push({ - title: 'Selection start', - value: hasRange ? tr.v.ui.createScalarSpan( - selection.bounds.min, { - unit: tr.v.Unit.byName.timeStampInMs, - ownerDocument: this.ownerDocument - }) : '<empty>' - }); - rows.push({ - title: 'Selection extent', - value: hasRange ? tr.v.ui.createScalarSpan( - selection.bounds.range, { - unit: tr.v.Unit.byName.timeDurationInMs, - ownerDocument: this.ownerDocument - }) : '<empty>' - }); - - this.$.table.tableRows = rows; - this.$.table.rebuild(); - } - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/selection_summary_table_test.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/selection_summary_table_test.html deleted file mode 100644 index 5c1f1691efd..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/selection_summary_table_test.html +++ /dev/null @@ -1,75 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/ui/analysis/selection_summary_table.html"> -<link rel="import" href="/tracing/ui/base/deep_utils.html"> -<link rel="import" href="/tracing/value/unit.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var Model = tr.Model; - var EventSet = tr.model.EventSet; - var newSliceEx = tr.c.TestUtils.newSliceEx; - - test('noSelection', function() { - var summaryTable = - document.createElement('tr-ui-a-selection-summary-table'); - summaryTable.selection = undefined; - this.addHTMLOutput(summaryTable); - - var tableEl = tr.b.findDeepElementMatching( - summaryTable, 'tr-ui-b-table'); - assert.equal(tableEl.tableRows[0].value, '<empty>'); - assert.equal(tableEl.tableRows[1].value, '<empty>'); - }); - - test('emptySelection', function() { - var summaryTable = - document.createElement('tr-ui-a-selection-summary-table'); - var selection = new EventSet(); - summaryTable.selection = selection; - this.addHTMLOutput(summaryTable); - - var tableEl = tr.b.findDeepElementMatching( - summaryTable, 'tr-ui-b-table'); - assert.equal(tableEl.tableRows[0].value, '<empty>'); - assert.equal(tableEl.tableRows[1].value, '<empty>'); - }); - - test('selection', function() { - var model = new Model(); - var thread = model.getOrCreateProcess(1).getOrCreateThread(2); - var tsg = thread.sliceGroup; - - tsg.pushSlice(newSliceEx({title: 'a', start: 0, end: 3})); - tsg.pushSlice(newSliceEx({title: 'b', start: 1, end: 2})); - - var selection = new EventSet(); - selection.push(tsg.slices[0]); - selection.push(tsg.slices[1]); - - var summaryTable = - document.createElement('tr-ui-a-selection-summary-table'); - summaryTable.selection = selection; - this.addHTMLOutput(summaryTable); - - var tableEl = tr.b.findDeepElementMatching( - summaryTable, 'tr-ui-b-table'); - assert.equal(tableEl.tableRows[0].value.value, 0); - assert.strictEqual(tableEl.tableRows[0].value.unit, - tr.v.Unit.byName.timeStampInMs); - assert.equal(tableEl.tableRows[1].value.value, 3); - assert.strictEqual(tableEl.tableRows[1].value.unit, - tr.v.Unit.byName.timeDurationInMs); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_alert_sub_view.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_alert_sub_view.html deleted file mode 100644 index 89d8ade4c5b..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_alert_sub_view.html +++ /dev/null @@ -1,65 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/base/dom_helpers.html"> -<link rel="import" href="/tracing/ui/analysis/analysis_sub_view.html"> -<link rel="import" href="/tracing/ui/analysis/single_event_sub_view.html"> - -<polymer-element name="tr-ui-a-single-alert-sub-view" - extends="tr-ui-a-sub-view"> - <script> - 'use strict'; - - Polymer({ - created: function() { - this.currentSelection_ = undefined; - }, - - set selection(selection) { - this.currentSelection_ = selection; - - this.textContent = ''; - var realView = document.createElement('tr-ui-a-single-event-sub-view'); - realView.addExtraRowsCallback = function(rows) { - // Alert description. - var alert = this.currentSelection_[0]; - - var descriptionEl = tr.ui.b.createSpan({ - textContent: alert.info.description - }); - rows.push({ - name: 'Description', - value: descriptionEl - }); - - // Associated events... - if (alert.associatedEvents.length) { - var eventSubRows = []; - alert.associatedEvents.forEach(function(event, i) { - var linkEl = document.createElement('tr-ui-a-analysis-link'); - linkEl.setSelectionAndContent(function() { - return event; - }, event.userFriendlyName); - eventSubRows.push({ - name: i, - value: linkEl - }); - }); - - rows.push({ - name: 'Alerts', value: '', - isExpanded: true, subRows: eventSubRows - }); - } - }.bind(this); - - this.appendChild(realView); - realView.setSelectionWithoutErrorChecks(selection); - } - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_async_slice_sub_view.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_async_slice_sub_view.html deleted file mode 100644 index 26a47706165..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_async_slice_sub_view.html +++ /dev/null @@ -1,71 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/iteration_helpers.html"> -<link rel="import" href="/tracing/ui/analysis/analysis_sub_view.html"> -<link rel="import" href="/tracing/ui/analysis/related_events.html"> -<link rel="import" href="/tracing/ui/analysis/single_event_sub_view.html"> - -<polymer-element name="tr-ui-a-single-async-slice-sub-view" - extends="tr-ui-a-sub-view"> - <template> - <style> - :host { - display: flex; - flex-direction: row; - } - #events { - display:flex; - flex-direction: column; - } - </style> - <tr-ui-a-single-event-sub-view id="content"></tr-ui-a-single-event-sub-view> - <div id="events"> - <tr-ui-a-related-events id="relatedEvents"></tr-ui-a-related-events> - </div> - </template> - - <script> - 'use strict'; - - Polymer({ - get selection() { - return this.$.content.selection; - }, - - set selection(selection) { - if (selection.length !== 1) - throw new Error('Only supports single slices'); - this.$.content.setSelectionWithoutErrorChecks(selection); - this.$.relatedEvents.setRelatedEvents(selection); - if (this.$.relatedEvents.hasRelatedEvents()) { - this.$.relatedEvents.style.display = ''; - } else { - this.$.relatedEvents.style.display = 'none'; - } - }, - - getEventRows_: function(event) { - // TODO(nduca): Figure out if there is a cleaner way to do this. - var rows = this.__proto__.__proto__.getEventRows_(event); - - // Put the ID up top. - rows.splice(0, 0, { - name: 'ID', - value: event.id - }); - return rows; - }, - - get relatedEventsToHighlight() { - if (!this.currentSelection_) - return undefined; - return tr.b.getOnlyElement(this.currentSelection_).associatedEvents; - } - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_async_slice_sub_view_test.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_async_slice_sub_view_test.html deleted file mode 100644 index cc83a239bab..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_async_slice_sub_view_test.html +++ /dev/null @@ -1,41 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/ui/analysis/single_async_slice_sub_view.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var newAsyncSliceEx = tr.c.TestUtils.newAsyncSliceEx; - - test('instantiate', function() { - var model = new tr.Model(); - var p1 = model.getOrCreateProcess(1); - var t1 = p1.getOrCreateThread(1); - t1.asyncSliceGroup.push(newAsyncSliceEx({ - id: 31415, - title: 'a', - start: 10, - duration: 20, - startThread: t1, - endThread: t1 - })); - - var selection = new tr.model.EventSet(); - selection.push(t1.asyncSliceGroup.slices[0]); - - var viewEl = document.createElement('tr-ui-a-single-async-slice-sub-view'); - viewEl.selection = selection; - this.addHTMLOutput(viewEl); - }); - -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_cpu_slice_sub_view.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_cpu_slice_sub_view.html deleted file mode 100644 index 42081c5baf1..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_cpu_slice_sub_view.html +++ /dev/null @@ -1,139 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/iteration_helpers.html"> -<link rel="import" href="/tracing/base/utils.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/ui/analysis/analysis_link.html"> -<link rel="import" href="/tracing/ui/analysis/analysis_sub_view.html"> -<link rel="import" href="/tracing/value/ui/scalar_span.html"> -<link rel="import" href="/tracing/value/unit.html"> - -<polymer-element name="tr-ui-a-single-cpu-slice-sub-view" - extends="tr-ui-a-sub-view"> - <template> - <style> - table { - border-collapse: collapse; - border-width: 0; - margin-bottom: 25px; - width: 100%; - } - - table tr > td:first-child { - padding-left: 2px; - } - - table tr > td { - padding: 2px 4px 2px 4px; - vertical-align: text-top; - width: 150px; - } - - table td td { - padding: 0 0 0 0; - width: auto; - } - tr { - vertical-align: top; - } - - tr:nth-child(2n+0) { - background-color: #e2e2e2; - } - </style> - <table> - <tr> - <td>Running process:</td><td id="process-name"></td> - </tr> - <tr> - <td>Running thread:</td><td id="thread-name"></td> - </tr> - <tr> - <td>Start:</td> - <td> - <tr-v-ui-scalar-span id="start"> - </tr-v-ui-scalar-span> - </td> - </tr> - <tr> - <td>Duration:</td> - <td> - <tr-v-ui-scalar-span id="duration"> - </tr-v-ui-scalar-span> - </td> - </tr> - <tr> - <td>Active slices:</td><td id="running-thread"></td> - </tr> - <tr> - <td>Args:</td> - <td> - <tr-ui-a-generic-object-view id="args"> - </tr-ui-a-generic-object-view> - </td> - </tr> - </table> - </template> - - <script> - 'use strict'; - Polymer({ - created: function() { - this.currentSelection_ = undefined; - }, - - get selection() { - return this.currentSelection_; - }, - - set selection(selection) { - var cpuSlice = tr.b.getOnlyElement(selection); - if (!(cpuSlice instanceof tr.model.CpuSlice)) - throw new Error('Only supports thread time slices'); - - this.currentSelection_ = selection; - - var thread = cpuSlice.threadThatWasRunning; - - var shadowRoot = this.shadowRoot; - if (thread) { - shadowRoot.querySelector('#process-name').textContent = - thread.parent.userFriendlyName; - shadowRoot.querySelector('#thread-name').textContent = - thread.userFriendlyName; - } else { - shadowRoot.querySelector('#process-name').parentElement.style.display = - 'none'; - shadowRoot.querySelector('#thread-name').textContent = cpuSlice.title; - } - - shadowRoot.querySelector('#start').setValueAndUnit( - cpuSlice.start, tr.v.Unit.byName.timeStampInMs); - shadowRoot.querySelector('#duration').setValueAndUnit( - cpuSlice.duration, tr.v.Unit.byName.timeDurationInMs); - - var runningThreadEl = shadowRoot.querySelector('#running-thread'); - - var timeSlice = cpuSlice.getAssociatedTimeslice(); - if (!timeSlice) { - runningThreadEl.parentElement.style.display = 'none'; - } else { - var threadLink = document.createElement('tr-ui-a-analysis-link'); - threadLink.selection = new tr.model.EventSet(timeSlice); - threadLink.textContent = 'Click to select'; - runningThreadEl.parentElement.style.display = ''; - runningThreadEl.textContent = ''; - runningThreadEl.appendChild(threadLink); - } - - shadowRoot.querySelector('#args').object = cpuSlice.args; - - } - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_cpu_slice_sub_view_test.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_cpu_slice_sub_view_test.html deleted file mode 100644 index ea75afe6dcf..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_cpu_slice_sub_view_test.html +++ /dev/null @@ -1,81 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/extras/importer/linux_perf/ftrace_importer.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/ui/analysis/single_cpu_slice_sub_view.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - function createBasicModel() { - var lines = [ - 'Android.launcher-584 [001] d..3 12622.506890: sched_switch: prev_comm=Android.launcher prev_pid=584 prev_prio=120 prev_state=R+ ==> next_comm=Binder_1 next_pid=217 next_prio=120', // @suppress longLineCheck - ' Binder_1-217 [001] d..3 12622.506918: sched_switch: prev_comm=Binder_1 prev_pid=217 prev_prio=120 prev_state=D ==> next_comm=Android.launcher next_pid=584 next_prio=120', // @suppress longLineCheck - 'Android.launcher-584 [001] d..4 12622.506936: sched_wakeup: comm=Binder_1 pid=217 prio=120 success=1 target_cpu=001', // @suppress longLineCheck - 'Android.launcher-584 [001] d..3 12622.506950: sched_switch: prev_comm=Android.launcher prev_pid=584 prev_prio=120 prev_state=R+ ==> next_comm=Binder_1 next_pid=217 next_prio=120', // @suppress longLineCheck - ' Binder_1-217 [001] ...1 12622.507057: tracing_mark_write: B|128|queueBuffer', // @suppress longLineCheck - ' Binder_1-217 [001] ...1 12622.507175: tracing_mark_write: E', - ' Binder_1-217 [001] d..3 12622.507253: sched_switch: prev_comm=Binder_1 prev_pid=217 prev_prio=120 prev_state=S ==> next_comm=Android.launcher next_pid=584 next_prio=120' // @suppress longLineCheck - ]; - - return tr.c.TestUtils.newModelWithEvents([lines.join('\n')], { - shiftWorldToZero: false - }); - } - - test('cpuSliceView_withCpuSliceOnExistingThread', function() { - var m = createBasicModel(); - - var cpu = m.kernel.cpus[1]; - assert.isDefined(cpu); - var cpuSlice = cpu.slices[0]; - assert.equal('Binder_1', cpuSlice.title); - - var thread = m.findAllThreadsNamed('Binder_1')[0]; - assert.isDefined(thread); - assert.equal(cpuSlice.threadThatWasRunning, thread); - - var view = document.createElement('tr-ui-a-single-cpu-slice-sub-view'); - var selection = new tr.model.EventSet(); - selection.push(cpuSlice); - view.selection = selection; - this.addHTMLOutput(view); - - // Clicking the analysis link should focus the Binder1's timeslice. - var didSelectionChangeHappen = false; - view.addEventListener('requestSelectionChange', function(e) { - assert.isTrue(e.selection.equals( - new tr.model.EventSet(thread.timeSlices[0]))); - didSelectionChangeHappen = true; - }); - view.shadowRoot.querySelector('tr-ui-a-analysis-link').click(); - assert.isTrue(didSelectionChangeHappen); - }); - - test('cpuSliceViewWithCpuSliceOnMissingThread', function() { - var m = createBasicModel(); - - var cpu = m.kernel.cpus[1]; - assert.isDefined(cpu); - var cpuSlice = cpu.slices[1]; - assert.equal('Android.launcher', cpuSlice.title); - assert.isUndefined(cpuSlice.thread); - - var selection = new tr.model.EventSet(); - selection.push(cpuSlice); - - var view = document.createElement('tr-ui-a-single-cpu-slice-sub-view'); - view.selection = selection; - this.addHTMLOutput(view); - }); - -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_event_sub_view.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_event_sub_view.html deleted file mode 100644 index 74a82c95348..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_event_sub_view.html +++ /dev/null @@ -1,286 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/base.html"> -<link rel="import" href="/tracing/base/iteration_helpers.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/ui/analysis/analysis_sub_view.html"> -<link rel="import" href="/tracing/ui/analysis/generic_object_view.html"> -<link rel="import" href="/tracing/ui/analysis/stack_frame.html"> -<link rel="import" href="/tracing/ui/base/table.html"> -<link rel="import" href="/tracing/ui/base/ui.html"> -<link rel="import" href="/tracing/value/ui/scalar_span.html"> -<link rel="import" href="/tracing/value/unit.html"> - -<polymer-element name="tr-ui-a-single-event-sub-view" - extends="tr-ui-a-sub-view"> - <template> - <style> - :host { - display: flex; - flex-direction: column; - } - #table { - flex: 1 1 auto; - align-self: stretch; - } - </style> - <tr-ui-b-table id="table"> - </tr-ui-b-table> - </template> - <script> - 'use strict'; - - Polymer({ - ready: function() { - this.currentSelection_ = undefined; - this.$.table.tableColumns = [ - { - title: 'Label', - value: function(row) { return row.name; }, - width: '150px' - }, - { - title: 'Value', - width: '100%', - value: function(row) { return row.value; } - } - ]; - this.$.table.showHeader = false; - }, - - get selection() { - return this.currentSelection_; - }, - - set selection(selection) { - if (selection.length !== 1) - throw new Error('Only supports single slices'); - this.setSelectionWithoutErrorChecks(selection); - }, - - setSelectionWithoutErrorChecks: function(selection) { - this.currentSelection_ = selection; - this.updateContents_(); - }, - - getEventRows_: function(event) { - var rows = []; - - if (event.error) - rows.push({ name: 'Error', value: event.error }); - - if (event.title) - rows.push({ name: 'Title', value: event.title }); - - if (event.category) - rows.push({ name: 'Category', value: event.category }); - - if (event.model !== undefined) { - var ufc = event.model.getUserFriendlyCategoryFromEvent(event); - if (ufc !== undefined) - rows.push({ name: 'User Friendly Category', value: ufc }); - } - - if (event.name) - rows.push({ name: 'Name', value: event.name }); - - rows.push({ - name: 'Start', - value: tr.v.ui.createScalarSpan(event.start, { - unit: tr.v.Unit.byName.timeStampInMs - }) - }); - - if (event.duration) { - rows.push({ - name: 'Wall Duration', - value: tr.v.ui.createScalarSpan(event.duration, { - unit: tr.v.Unit.byName.timeDurationInMs - }) - }); - } - - if (event.cpuDuration) { - rows.push({ - name: 'CPU Duration', - value: tr.v.ui.createScalarSpan(event.cpuDuration, { - unit: tr.v.Unit.byName.timeDurationInMs - }) - }); - } - - if (event.subSlices !== undefined && event.subSlices.length !== 0) { - if (event.selfTime) { - rows.push({ - name: 'Self Time', - value: tr.v.ui.createScalarSpan(event.selfTime, { - unit: tr.v.Unit.byName.timeDurationInMs - }) - }); - } - - if (event.cpuSelfTime) { - var cpuSelfTimeEl = tr.v.ui.createScalarSpan(event.cpuSelfTime, { - unit: tr.v.Unit.byName.timeDurationInMs - }); - if (event.cpuSelfTime > event.selfTime) { - cpuSelfTimeEl.warning = - ' Note that CPU Self Time is larger than Self Time. ' + - 'This is a known limitation of this system, which occurs ' + - 'due to several subslices, rounding issues, and imprecise ' + - 'time at which we get cpu- and real-time.'; - } - rows.push({ name: 'CPU Self Time', value: cpuSelfTimeEl }); - } - } - - if (event.durationInUserTime) { - rows.push({ - name: 'Duration (U)', - value: tr.v.ui.createScalarSpan(event.durationInUserTime, { - unit: tr.v.Unit.byName.timeDurationInMs - }) - }); - } - - function createStackFrameEl(sf) { - var sfEl = document.createElement('tr-ui-a-stack-frame'); - sfEl.stackFrame = sf; - return sfEl; - } - if (event.startStackFrame && event.endStackFrame) { - if (event.startStackFrame === event.endStackFrame) { - rows.push({name: 'Start+End Stack Trace', - value: createStackFrameEl(event.startStackFrame)}); - - } else { - rows.push({ name: 'Start Stack Trace', - value: createStackFrameEl(event.startStackFrame)}); - rows.push({ name: 'End Stack Trace', - value: createStackFrameEl(event.endStackFrame)}); - } - } else if (event.startStackFrame) { - rows.push({ name: 'Start Stack Trace', - value: createStackFrameEl(event.startStackFrame)}); - - } else if (event.endStackFrame) { - rows.push({ name: 'End Stack Trace', - value: createStackFrameEl(event.endStackFrame)}); - } - - if (event.info) { - var descriptionEl = tr.ui.b.createDiv({ - textContent: event.info.description, - maxWidth: '300px' - }); - rows.push({ - name: 'Description', - value: descriptionEl - }); - - - if (event.info.docLinks) { - event.info.docLinks.forEach(function(linkObject) { - var linkEl = document.createElement('a'); - linkEl.target = '_blank'; - linkEl.href = linkObject.href; - linkEl.textContent = linkObject.textContent; - rows.push({ - name: linkObject.label, - value: linkEl - }); - }); - } - } - - if (event.associatedAlerts.length) { - var alertSubRows = []; - event.associatedAlerts.forEach(function(alert) { - var linkEl = document.createElement('tr-ui-a-analysis-link'); - linkEl.setSelectionAndContent(function() { - return new tr.model.EventSet(alert); - }, alert.info.description); - alertSubRows.push({ - name: alert.title, - value: linkEl - }); - }); - - rows.push({ - name: 'Alerts', value: '', - isExpanded: true, subRows: alertSubRows - }); - } - return rows; - }, - - addArgsToRows_: function(rows, args) { - var n = 0; - for (var argName in args) { - n += 1; - } - if (n > 0) { - var subRows = []; - for (var argName in args) { - var argView = - document.createElement('tr-ui-a-generic-object-view'); - argView.object = args[argName]; - subRows.push({name: argName, value: argView}); - } - rows.push({ - name: 'Args', - value: '', - isExpanded: true, - subRows: subRows - }); - } - }, - - addContextsToRows_: function(rows, contexts) { - if (contexts.length) { - var subRows = contexts.map(function(context) { - var contextView = - document.createElement('tr-ui-a-generic-object-view'); - contextView.object = context; - return {name: 'Context', value: contextView}; - }); - rows.push({ - name: 'Contexts', - value: '', - isExpanded: true, - subRows: subRows - }); - } - }, - - updateContents_: function() { - if (this.currentSelection_ === undefined) { - this.$.table.rows = []; - this.$.table.rebuild(); - return; - } - - var event = tr.b.getOnlyElement(this.currentSelection_); - - var rows = this.getEventRows_(event); - if (event.argsStripped) - rows.push({ name: 'Args', value: 'Stripped' }); - else - this.addArgsToRows_(rows, event.args); - this.addContextsToRows_(rows, event.contexts); - - var event = new tr.b.Event('customize-rows'); - event.rows = rows; - this.dispatchEvent(event); - - this.$.table.tableRows = rows; - this.$.table.rebuild(); - } - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_event_sub_view_test.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_event_sub_view_test.html deleted file mode 100644 index b52ebaa16bc..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_event_sub_view_test.html +++ /dev/null @@ -1,261 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/ui/analysis/single_event_sub_view.html"> -<link rel="import" href="/tracing/ui/base/deep_utils.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var Model = tr.Model; - var Thread = tr.model.Thread; - var EventSet = tr.model.EventSet; - var newSliceEx = tr.c.TestUtils.newSliceEx; - - function createSelection(customizeThreadCallback) { - var model = tr.c.TestUtils.newModelWithEvents([], { - customizeModelCallback: function(model) { - var t53 = model.getOrCreateProcess(52).getOrCreateThread(53); - customizeThreadCallback(t53, model); - } - }); - - var t53 = model.processes[52].threads[53]; - var t53track = {}; - t53track.thread = t53; - - var selection = new EventSet(); - selection.push(t53.sliceGroup.slices[0]); - assert.equal(selection.length, 1); - - return selection; - } - - function createSelectionWithSingleSlice(opt_options) { - var options = opt_options || {}; - return createSelection(function(t53, model) { - if (options.withStartStackFrame || options.withEndStackFrame) { - var fA = tr.c.TestUtils.newStackTrace(model, ['a1', 'a2']); - var fB = tr.c.TestUtils.newStackTrace(model, ['b1', 'b2']); - } - - var slice = newSliceEx({title: 'b', start: 0, duration: 0.002}); - slice.category = options.withCategory ? 'foo' : ''; - - if (options.withStartStackFrame) - slice.startStackFrame = options.withStartStackFrame === 'a' ? fA : fB; - - if (options.withEndStackFrame) - slice.endStackFrame = options.withEndStackFrame === 'a' ? fA : fB; - - t53.sliceGroup.pushSlice(slice); - }); - }; - - test('instantiate_withSingleSlice', function() { - var selection = createSelectionWithSingleSlice(); - - var analysisEl = document.createElement('tr-ui-a-single-event-sub-view'); - analysisEl.selection = selection; - this.addHTMLOutput(analysisEl); - }); - - test('alerts', function() { - var slice = newSliceEx({title: 'b', start: 0, duration: 0.002}); - - var ALERT_INFO_1 = new tr.model.EventInfo( - 'Alert 1', 'Critical alert'); - - var alert = new tr.model.Alert(ALERT_INFO_1, 5, [slice]); - - var selection = new EventSet(); - selection.push(slice); - - var analysisEl = document.createElement('tr-ui-a-single-event-sub-view'); - analysisEl.selection = selection; - this.addHTMLOutput(analysisEl); - }); - - test('instantiate_withSingleSliceWithArg', function() { - var selection = createSelection(function(t53) { - var slice = newSliceEx({title: 'my_slice', start: 0, duration: 1.0}); - slice.args = { - 'complex': { - 'b': '2 as a string', - 'c': [3, 4, 5] - } - }; - t53.sliceGroup.pushSlice(slice); - }); - - var subView = document.createElement('tr-ui-a-single-event-sub-view'); - subView.selection = selection; - this.addHTMLOutput(subView); - - var gov = tr.b.findDeepElementMatching(subView, - 'tr-ui-a-generic-object-view'); - assert.isDefined(gov); - }); - - - test('instantiate_withSingleSliceCategory', function() { - var selection = createSelectionWithSingleSlice({withCategory: true}); - - var analysisEl = document.createElement('tr-ui-a-single-event-sub-view'); - analysisEl.selection = selection; - this.addHTMLOutput(analysisEl); - }); - - test('instantiate_withSingleStartStackFrame', function() { - var selection = createSelectionWithSingleSlice( - {withStartStackFrame: 'a'}); - - var analysisEl = document.createElement('tr-ui-a-single-event-sub-view'); - analysisEl.selection = selection; - this.addHTMLOutput(analysisEl); - - var e = tr.b.findDeepElementWithTextContent( - analysisEl, /Start Stack Trace/); - assert.isDefined(e); - assert.isDefined(e.nextSibling.children[0].stackFrame); - }); - - test('instantiate_withSingleEndStackFrame', function() { - var selection = createSelectionWithSingleSlice( - {withEndStackFrame: 'b'}); - - var analysisEl = document.createElement('tr-ui-a-single-event-sub-view'); - analysisEl.selection = selection; - this.addHTMLOutput(analysisEl); - - var e = tr.b.findDeepElementWithTextContent( - analysisEl, /End Stack Trace/); - assert.isDefined(e); - assert.isDefined(e.nextSibling.children[0].stackFrame); - assert.equal(e.nextSibling.children[0].stackFrame.title, 'b2'); - }); - - test('instantiate_withDifferentStartAndEndStackFrames', function() { - var selection = createSelectionWithSingleSlice( - {withStartStackFrame: 'a', - withEndStackFrame: 'b'}); - - var analysisEl = document.createElement('tr-ui-a-single-event-sub-view'); - analysisEl.selection = selection; - this.addHTMLOutput(analysisEl); - - var eA = tr.b.findDeepElementWithTextContent( - analysisEl, /Start Stack Trace/); - assert.isDefined(eA); - assert.isDefined(eA.nextSibling.children[0].stackFrame); - assert.equal(eA.nextSibling.children[0].stackFrame.title, 'a2'); - - var eB = tr.b.findDeepElementWithTextContent( - analysisEl, /End Stack Trace/); - assert.isDefined(eB); - assert.isDefined(eB.nextSibling.children[0].stackFrame); - assert.equal(eB.nextSibling.children[0].stackFrame.title, 'b2'); - }); - - test('instantiate_withSameStartAndEndStackFrames', function() { - var selection = createSelectionWithSingleSlice( - {withStartStackFrame: 'a', - withEndStackFrame: 'a'}); - - var analysisEl = document.createElement('tr-ui-a-single-event-sub-view'); - analysisEl.selection = selection; - this.addHTMLOutput(analysisEl); - - var e = tr.b.findDeepElementWithTextContent( - analysisEl, /Start\+End Stack Trace/); - assert.isDefined(e); - assert.isDefined(e.nextSibling.children[0].stackFrame); - assert.equal(e.nextSibling.children[0].stackFrame.title, 'a2'); - }); - - test('analyzeSelectionWithSingleSlice', function() { - var selection = createSelectionWithSingleSlice(); - var subView = document.createElement('tr-ui-a-single-event-sub-view'); - subView.selection = selection; - this.addHTMLOutput(subView); - - var table = tr.b.findDeepElementMatching( - subView, 'tr-ui-b-table'); - assert.equal(table.tableRows.length, 3); - assert.equal(table.tableRows[0].value, 'b'); - assert.equal(table.tableRows[1].value.value, 0); - assert.strictEqual(table.tableRows[1].value.unit, - tr.v.Unit.byName.timeStampInMs); - assert.equal(table.tableRows[2].value.value, 0.002); - assert.strictEqual(table.tableRows[2].value.unit, - tr.v.Unit.byName.timeDurationInMs); - }); - - test('analyzeSelectionWithSingleSliceCategory', function() { - var selection = createSelectionWithSingleSlice({withCategory: true}); - - var subView = document.createElement('tr-ui-a-single-event-sub-view'); - subView.selection = selection; - this.addHTMLOutput(subView); - - var table = tr.b.findDeepElementMatching( - subView, 'tr-ui-b-table'); - assert.equal(table.tableRows.length, 4); - assert.equal(table.tableRows[0].value, 'b'); - assert.equal(table.tableRows[1].value, 'foo'); - assert.equal(table.tableRows[2].value.value, 0); - assert.strictEqual(table.tableRows[2].value.unit, - tr.v.Unit.byName.timeStampInMs); - assert.equal(table.tableRows[3].value.value, 0.002); - assert.strictEqual(table.tableRows[3].value.unit, - tr.v.Unit.byName.timeDurationInMs); - }); - - test('instantiate_withSingleSliceContainingIDRef', function() { - var model = new Model(); - var p1 = model.getOrCreateProcess(1); - var myObjectSlice = p1.objects.addSnapshot( - '0x1000', 'cat', 'my_object', 0); - - var t1 = p1.getOrCreateThread(1); - t1.sliceGroup.pushSlice(newSliceEx({title: 'b', start: 0, duration: 2})); - t1.sliceGroup.slices[0].args.my_object = myObjectSlice; - - var t1track = {}; - t1track.thread = t1; - - var selection = new EventSet(); - selection.push(t1.sliceGroup.slices[0]); - assert.equal(selection.length, 1); - - var subView = document.createElement('tr-ui-a-single-event-sub-view'); - subView.selection = selection; - this.addHTMLOutput(subView); - - var analysisLink = tr.b.findDeepElementMatching(subView, - 'tr-ui-a-analysis-link'); - assert.isDefined(analysisLink); - }); - - test('instantiate_withSingleSliceContainingInfo', function() { - var slice = newSliceEx({title: 'b', start: 0, duration: 1}); - slice.info = new tr.model.EventInfo( - 'Info title', 'Description'); - - var selection = new EventSet(); - selection.push(slice); - - var analysisEl = document.createElement('tr-ui-a-single-event-sub-view'); - analysisEl.selection = selection; - this.addHTMLOutput(analysisEl); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_flow_event_sub_view.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_flow_event_sub_view.html deleted file mode 100644 index 899f9f2096e..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_flow_event_sub_view.html +++ /dev/null @@ -1,50 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/ui/analysis/analysis_sub_view.html"> -<link rel="import" href="/tracing/ui/analysis/analysis_link.html"> -<link rel="import" href="/tracing/ui/analysis/single_event_sub_view.html"> - -<polymer-element name="tr-ui-a-single-flow-event-sub-view" - extends="tr-ui-a-single-event-sub-view"> - <script> - 'use strict'; - - Polymer({ - getEventRows_: function(event) { - // TODO(nduca): Figure out if there is a cleaner way to do this. - var rows = this.__proto__.__proto__.getEventRows_(event); - - // Put the ID up top. - rows.splice(0, 0, { - name: 'ID', - value: event.id - }); - - function createLinkTo(slice) { - var linkEl = document.createElement('tr-ui-a-analysis-link'); - linkEl.setSelectionAndContent(function() { - return new tr.model.EventSet(slice); - }); - linkEl.textContent = slice.userFriendlyName; - return linkEl; - } - - rows.push({ - name: 'From', - value: createLinkTo(event.startSlice) - }); - rows.push({ - name: 'To', - value: createLinkTo(event.endSlice) - }); - return rows; - } - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_flow_event_sub_view_test.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_flow_event_sub_view_test.html deleted file mode 100644 index bbd348a1b20..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_flow_event_sub_view_test.html +++ /dev/null @@ -1,52 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/ui/analysis/analysis_view.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var Model = tr.Model; - var EventSet = tr.model.EventSet; - var TestUtils = tr.c.TestUtils; - - test('analyzeSelectionWithSingleEvent', function() { - var model = TestUtils.newModel(function(model) { - model.p1 = model.getOrCreateProcess(1); - model.t2 = model.p1.getOrCreateThread(model.p1); - model.sA = model.t2.sliceGroup.pushSlice(TestUtils.newSliceEx({ - title: 'a', start: 0, end: 2 - })); - model.sB = model.t2.sliceGroup.pushSlice(TestUtils.newSliceEx({ - title: 'b', start: 9, end: 11 - })); - model.fe = TestUtils.newFlowEventEx({ - cat: 'cat', - id: 1234, - title: 'MyFlow', - start: 1, - end: 10, - startSlice: model.sA, - endSlice: model.sB - }); - model.flowEvents.push(model.fe); - }); - - var selection = new EventSet(); - selection.push(model.fe); - assert.equal(selection.length, 1); - - var subView = document.createElement('tr-ui-a-single-flow-event-sub-view'); - subView.selection = selection; - this.addHTMLOutput(subView); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_frame_sub_view.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_frame_sub_view.html deleted file mode 100644 index f58168d1c87..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_frame_sub_view.html +++ /dev/null @@ -1,52 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/iteration_helpers.html"> -<link rel="import" href="/tracing/ui/analysis/alert_sub_view.html"> -<link rel="import" href="/tracing/ui/analysis/analysis_sub_view.html"> - -<polymer-element name="tr-ui-a-single-frame-sub-view" - extends="tr-ui-a-sub-view"> - <template> - <style> - :host { - display: flex; - flex-direction: column; - } - #asv { - flex: 0 0 auto; - align-self: stretch; - } - </style> - <tr-ui-a-alert-sub-view id="asv"> - </tr-ui-a-alert-sub-view> - </template> - <script> - 'use strict'; - - Polymer({ - ready: function() { - this.currentSelection_ = undefined; - }, - - get selection() { - return this.currentSelection_; - }, - - set selection(selection) { - this.currentSelection_ = selection; - this.$.asv.selection = tr.b.getOnlyElement(selection).associatedAlerts; - }, - - get relatedEventsToHighlight() { - if (!this.currentSelection_) - return undefined; - return tr.b.getOnlyElement(this.currentSelection_).associatedEvents; - } - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_instant_event_sub_view.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_instant_event_sub_view.html deleted file mode 100644 index c8ab4aa7389..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_instant_event_sub_view.html +++ /dev/null @@ -1,45 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/analysis/analysis_sub_view.html"> -<link rel="import" href="/tracing/ui/analysis/single_event_sub_view.html"> - -<polymer-element name="tr-ui-a-single-instant-event-sub-view" - extends="tr-ui-a-sub-view"> - <template> - <style> - :host { - display: block; - } - </style> - <div id='content'></div> - </template> - - <script> - 'use strict'; - - Polymer({ - created: function() { - this.currentSelection_ = undefined; - }, - - set selection(selection) { - this.$.content.textContent = ''; - var realView = document.createElement('tr-ui-a-single-event-sub-view'); - realView.setSelectionWithoutErrorChecks(selection); - - this.$.content.appendChild(realView); - - this.currentSelection_ = selection; - }, - - get selection() { - return this.currentSelection_; - } - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_instant_event_sub_view_test.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_instant_event_sub_view_test.html deleted file mode 100644 index f796164669f..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_instant_event_sub_view_test.html +++ /dev/null @@ -1,42 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/ui/analysis/analysis_view.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var Model = tr.Model; - var Thread = tr.model.Thread; - var EventSet = tr.model.EventSet; - - test('analyzeSelectionWithSingleEvent', function() { - var model = new Model(); - var p52 = model.getOrCreateProcess(52); - var t53 = p52.getOrCreateThread(53); - - var ie = new tr.model.ProcessInstantEvent('cat', 'title', 7, 10, {}); - ie.duration = 20; - p52.instantEvents.push(ie); - - - var selection = new EventSet(); - selection.push(ie); - assert.equal(selection.length, 1); - - var subView = document.createElement( - 'tr-ui-a-single-instant-event-sub-view'); - subView.selection = selection; - - this.addHTMLOutput(subView); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_object_instance_sub_view.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_object_instance_sub_view.html deleted file mode 100644 index ca5cd4a730d..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_object_instance_sub_view.html +++ /dev/null @@ -1,116 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/iteration_helpers.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/ui/analysis/analysis_link.html"> -<link rel="import" href="/tracing/ui/analysis/analysis_sub_view.html"> -<link rel="import" href="/tracing/ui/analysis/generic_object_view.html"> -<link rel="import" href="/tracing/ui/analysis/object_instance_view.html"> -<link rel="import" href="/tracing/ui/analysis/single_event_sub_view.html"> - -<polymer-element name="tr-ui-a-single-object-instance-sub-view" - extends="tr-ui-a-sub-view"> - <template> - <style> - :host { - display: block; - } - - #snapshots > * { - display: block; - } - - :host { - overflow: auto; - display: block; - } - - * { - -webkit-user-select: text; - } - - .title { - border-bottom: 1px solid rgb(128, 128, 128); - font-size: 110%; - font-weight: bold; - } - - td, th { - font-family: monospace; - vertical-align: top; - } - </style> - <div id='content'></div> - </template> - <script> - 'use strict'; - - Polymer({ - created: function() { - this.currentSelection_ = undefined; - }, - - get requiresTallView() { - if (this.$.content.children.length === 0) - return false; - if (this.$.content.children[0] instanceof - tr.ui.analysis.ObjectInstanceView) - return this.$.content.children[0].requiresTallView; - }, - - get selection() { - return this.currentSelection_; - }, - - set selection(selection) { - var instance = tr.b.getOnlyElement(selection); - if (!(instance instanceof tr.model.ObjectInstance)) - throw new Error('Only supports object instances'); - - this.$.content.textContent = ''; - this.currentSelection_ = selection; - - var typeInfo = tr.ui.analysis.ObjectInstanceView.getTypeInfo( - instance.category, instance.typeName); - if (typeInfo) { - var customView = new typeInfo.constructor(); - this.$.content.appendChild(customView); - customView.modelEvent = instance; - } else { - this.appendGenericAnalysis_(instance); - } - }, - - appendGenericAnalysis_: function(instance) { - var html = ''; - html += '<div class="title">' + - instance.typeName + ' ' + - instance.id + '</div>\n'; - html += '<table>'; - html += '<tr>'; - html += '<tr><td>creationTs:</td><td>' + - instance.creationTs + '</td></tr>\n'; - if (instance.deletionTs != Number.MAX_VALUE) { - html += '<tr><td>deletionTs:</td><td>' + - instance.deletionTs + '</td></tr>\n'; - } else { - html += '<tr><td>deletionTs:</td><td>not deleted</td></tr>\n'; - } - html += '<tr><td>snapshots:</td><td id="snapshots"></td></tr>\n'; - html += '</table>'; - this.$.content.innerHTML = html; - var snapshotsEl = this.$.content.querySelector('#snapshots'); - instance.snapshots.forEach(function(snapshot) { - var snapshotLink = document.createElement('tr-ui-a-analysis-link'); - snapshotLink.selection = new tr.model.EventSet(snapshot); - snapshotsEl.appendChild(snapshotLink); - }); - } - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_object_instance_sub_view_test.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_object_instance_sub_view_test.html deleted file mode 100644 index 93114f6f98d..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_object_instance_sub_view_test.html +++ /dev/null @@ -1,34 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/ui/analysis/single_object_instance_sub_view.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var ObjectInstance = tr.model.ObjectInstance; - - test('analyzeSelectionWithObjectInstanceUnknownType', function() { - var i10 = new ObjectInstance({}, '0x1000', 'cat', 'someUnhandledName', 10); - var s10 = i10.addSnapshot(10, {foo: 1}); - var s20 = i10.addSnapshot(20, {foo: 2}); - - var selection = new tr.model.EventSet(); - selection.push(i10); - - var view = - document.createElement('tr-ui-a-single-object-instance-sub-view'); - view.selection = selection; - this.addHTMLOutput(view); - }); - -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_object_snapshot_sub_view.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_object_snapshot_sub_view.html deleted file mode 100644 index d156203b904..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_object_snapshot_sub_view.html +++ /dev/null @@ -1,128 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/iteration_helpers.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/ui/analysis/analysis_link.html"> -<link rel="import" href="/tracing/ui/analysis/analysis_sub_view.html"> -<link rel="import" href="/tracing/ui/analysis/generic_object_view.html"> -<link rel="import" href="/tracing/ui/analysis/object_instance_view.html"> -<link rel="import" href="/tracing/ui/analysis/object_snapshot_view.html"> -<link rel="import" href="/tracing/ui/analysis/single_event_sub_view.html"> -<link rel="import" href="/tracing/value/ui/scalar_span.html"> -<link rel="import" href="/tracing/value/unit.html"> - -<polymer-element name="tr-ui-a-single-object-snapshot-sub-view" - extends="tr-ui-a-sub-view"> - <template> - <style> - #args { - white-space: pre; - } - - :host { - overflow: auto; - display: flex; - } - - ::content * { - -webkit-user-select: text; - } - - ::content .title { - border-bottom: 1px solid rgb(128, 128, 128); - font-size: 110%; - font-weight: bold; - } - - ::content td, th { - font-family: monospace; - vertical-align: top; - } - </style> - <content></content> - </template> - <script> - 'use strict'; - - Polymer({ - created: function() { - this.currentSelection_ = undefined; - }, - - get requiresTallView() { - if (this.children.length === 0) - return false; - if (this.children[0] instanceof tr.ui.analysis.ObjectSnapshotView) - return this.children[0].requiresTallView; - }, - - get selection() { - return this.currentSelection_; - }, - - set selection(selection) { - var snapshot = tr.b.getOnlyElement(selection); - if (!(snapshot instanceof tr.model.ObjectSnapshot)) - throw new Error('Only supports object instances'); - - this.textContent = ''; - this.currentSelection_ = selection; - - var typeInfo = tr.ui.analysis.ObjectSnapshotView.getTypeInfo( - snapshot.objectInstance.category, snapshot.objectInstance.typeName); - if (typeInfo) { - var customView = new typeInfo.constructor(); - this.appendChild(customView); - customView.modelEvent = snapshot; - } else { - this.appendGenericAnalysis_(snapshot); - } - }, - - appendGenericAnalysis_: function(snapshot) { - var instance = snapshot.objectInstance; - - this.textContent = ''; - - var titleEl = document.createElement('div'); - titleEl.classList.add('title'); - titleEl.appendChild(document.createTextNode('Snapshot of ')); - this.appendChild(titleEl); - - var instanceLinkEl = document.createElement('tr-ui-a-analysis-link'); - instanceLinkEl.selection = new tr.model.EventSet(instance); - titleEl.appendChild(instanceLinkEl); - - titleEl.appendChild(document.createTextNode(' @ ')); - - titleEl.appendChild(tr.v.ui.createScalarSpan(snapshot.ts, { - unit: tr.v.Unit.byName.timeStampInMs, - ownerDocument: this.ownerDocument - })); - - var tableEl = document.createElement('table'); - this.appendChild(tableEl); - - var rowEl = document.createElement('tr'); - tableEl.appendChild(rowEl); - - var labelEl = document.createElement('td'); - labelEl.textContent = 'args:'; - rowEl.appendChild(labelEl); - - var argsEl = document.createElement('td'); - argsEl.id = 'args'; - rowEl.appendChild(argsEl); - - var objectViewEl = document.createElement('tr-ui-a-generic-object-view'); - objectViewEl.object = snapshot.args; - argsEl.appendChild(objectViewEl); - } - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_object_snapshot_sub_view_test.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_object_snapshot_sub_view_test.html deleted file mode 100644 index d6e73abbc9a..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_object_snapshot_sub_view_test.html +++ /dev/null @@ -1,32 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/ui/analysis/single_object_snapshot_sub_view.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - test('instantiate_snapshotView', function() { - var i10 = new tr.model.ObjectInstance( - {}, '0x1000', 'cat', 'name', 10); - var s10 = i10.addSnapshot(10, {foo: 1}); - i10.updateBounds(); - - var selection = new tr.model.EventSet(); - selection.push(s10); - - var view = - document.createElement('tr-ui-a-single-object-snapshot-sub-view'); - view.selection = selection; - this.addHTMLOutput(view); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_power_sample_sub_view.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_power_sample_sub_view.html deleted file mode 100644 index 96043122244..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_power_sample_sub_view.html +++ /dev/null @@ -1,107 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/ui/analysis/analysis_sub_view.html"> -<link rel="import" href="/tracing/ui/base/table.html"> -<link rel="import" href="/tracing/value/ui/scalar_span.html"> -<link rel="import" href="/tracing/value/unit.html"> - -<polymer-element name="tr-ui-a-power-sample-table"> - <template> - <style> - :host { - display: flex; - } - </style> - <tr-ui-b-table id="table"></tr-ui-b-table> - </template> -</polymer-element> - -<script> -'use strict'; - -Polymer('tr-ui-a-power-sample-table', { - ready: function() { - this.$.table.tableColumns = [ - { - title: 'Time', - width: '100px', - value: function(row) { - return tr.v.ui.createScalarSpan(row.start, { - unit: tr.v.Unit.byName.timeStampInMs - }); - } - }, - { - title: 'Power', - width: '100%', - value: function(row) { - return tr.v.ui.createScalarSpan(row.power, { - unit: tr.v.Unit.byName.powerInWatts - }); - } - } - ]; - this.sample = undefined; - }, - - get sample() { - return this.sample_; - }, - - set sample(sample) { - this.sample_ = sample; - this.updateContents_(); - }, - - updateContents_: function() { - if (this.sample == undefined) - this.$.table.tableRows = []; - else - this.$.table.tableRows = [this.sample]; - this.$.table.rebuild(); - } -}); -</script> - -<polymer-element name="tr-ui-a-single-power-sample-sub-view" - extends="tr-ui-a-sub-view"> - <template> - <style> - :host { display: block; } - </style> - <tr-ui-a-power-sample-table id="samplesTable"> - </tr-ui-a-power-sample-table> - </template> - - <script> - 'use strict'; - - Polymer({ - ready: function() { - this.currentSelection_ = undefined; - - }, - - get selection() { - return this.currentSelection_; - }, - - set selection(selection) { - this.currentSelection_ = selection; - this.updateContents_(); - }, - - updateContents_: function() { - if (this.selection.length != 1) - throw 'Cannot pass multiple samples to sample table.'; - this.$.samplesTable.sample = this.selection[0]; - } - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_power_sample_sub_view_test.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_power_sample_sub_view_test.html deleted file mode 100644 index 2b97e613a93..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_power_sample_sub_view_test.html +++ /dev/null @@ -1,42 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/iteration_helpers.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/model/power_series.html"> -<link rel="import" href="/tracing/ui/analysis/single_power_sample_sub_view.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - test('instantiate', function() { - var model = new tr.Model(); - var series = new tr.model.PowerSeries(model.device); - series.addPowerSample(1, 1); - - var view = document.createElement('tr-ui-a-single-power-sample-sub-view'); - view.selection = new tr.model.EventSet(series.samples); - - this.addHTMLOutput(view); - }); - - test('setSelection', function() { - var model = new tr.Model(); - var series = new tr.model.PowerSeries(model.device); - series.addPowerSample(1, 1); - - var view = document.createElement('tr-ui-a-single-power-sample-sub-view'); - var eventSet = new tr.model.EventSet(series.samples); - view.selection = eventSet; - - assert.deepEqual(view.$.samplesTable.sample, - tr.b.getOnlyElement(series.samples)); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_sample_sub_view.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_sample_sub_view.html deleted file mode 100644 index 29f7b2e064a..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_sample_sub_view.html +++ /dev/null @@ -1,89 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/analysis/analysis_sub_view.html"> -<link rel="import" href="/tracing/ui/analysis/stack_frame.html"> -<link rel="import" href="/tracing/ui/base/table.html"> -<link rel="import" href="/tracing/value/ui/scalar_span.html"> -<link rel="import" href="/tracing/value/unit.html"> - -<polymer-element name="tr-ui-a-single-sample-sub-view" - extends="tr-ui-a-sub-view"> - <template> - <style> - :host { - display: flex; - } - </style> - <tr-ui-b-table id="content"></tr-ui-b-table> - </template> - <script> - 'use strict'; - - Polymer({ - created: function() { - this.currentSelection_ = undefined; - }, - - ready: function() { - this.$.content.tableColumns = [ - { - title: 'FirstColumn', - value: function(row) { return row.title; }, - width: '250px' - }, - { - title: 'SecondColumn', - value: function(row) { return row.value; }, - width: '100%' - } - ]; - this.$.content.showHeader = false; - }, - - get selection() { - return this.currentSelection_; - }, - - set selection(selection) { - this.currentSelection_ = selection; - - if (this.currentSelection_ === undefined) { - this.$.content.tableRows = []; - return; - } - - var sample = this.currentSelection_[0]; - var table = this.$.content; - - var rows = []; - - rows.push({ - title: 'Title', - value: sample.title - }); - - rows.push({ - title: 'Sample time', - value: tr.v.ui.createScalarSpan(sample.start, { - unit: tr.v.Unit.byName.timeStampInMs, - ownerDocument: this.ownerDocument - }) - }); - - var sfEl = document.createElement('tr-ui-a-stack-frame'); - sfEl.stackFrame = sample.leafStackFrame; - rows.push({ - title: 'Stack trace', - value: sfEl - }); - table.tableRows = rows; - table.rebuild(); - } - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_sample_sub_view_test.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_sample_sub_view_test.html deleted file mode 100644 index d31abfaff08..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_sample_sub_view_test.html +++ /dev/null @@ -1,60 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/ui/analysis/single_sample_sub_view.html"> -<link rel="import" href="/tracing/ui/base/deep_utils.html"> -<link rel="import" href="/tracing/value/unit.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var Model = tr.Model; - var EventSet = tr.model.EventSet; - var newSampleNamed = tr.c.TestUtils.newSampleNamed; - - test('instantiate_withSingleSample', function() { - var t53; - var model = tr.c.TestUtils.newModelWithEvents([], { - shiftWorldToZero: false, - pruneContainers: false, - customizeModelCallback: function(model) { - t53 = model.getOrCreateProcess(52).getOrCreateThread(53); - model.samples.push(newSampleNamed(t53, 'X', 'my-category', - ['a', 'b', 'c'], 0.184)); - } - }); - - var t53track = {}; - t53track.thread = t53; - - var selection = new EventSet(); - - assert.equal(selection.length, 0); - selection.push(t53.samples[0]); - assert.equal(selection.length, 1); - - var view = document.createElement('tr-ui-a-single-sample-sub-view'); - view.selection = selection; - this.addHTMLOutput(view); - - var table = tr.b.findDeepElementMatching( - view, 'tr-ui-b-table'); - - var rows = table.tableRows; - assert.equal(rows.length, 3); - - assert.equal(rows[0].value, 'X'); - assert.equal(rows[1].value.value, 0.184); - assert.strictEqual(rows[1].value.unit, tr.v.Unit.byName.timeStampInMs); - assert.equal(rows[2].value.stackFrame, t53.samples[0].leafStackFrame); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_thread_slice_sub_view.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_thread_slice_sub_view.html deleted file mode 100644 index 2eeb8819785..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_thread_slice_sub_view.html +++ /dev/null @@ -1,51 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/analysis/analysis_sub_view.html"> -<link rel="import" href="/tracing/ui/analysis/single_event_sub_view.html"> -<link rel="import" href="/tracing/ui/analysis/related_events.html"> - -<polymer-element name="tr-ui-a-single-thread-slice-sub-view" - extends="tr-ui-a-sub-view"> - <template> - <style> - :host { - display: flex; - flex-direction: row; - } - #events { - display: flex; - flex-direction: column; - } - - </style> - <tr-ui-a-single-event-sub-view id="content"></tr-ui-a-single-event-sub-view> - <div id="events"> - <tr-ui-a-related-events id="relatedEvents"> - </tr-ui-a-related-events> - </div> - </template> - - <script> - 'use strict'; - - Polymer({ - get selection() { - return this.$.content.selection; - }, - - set selection(selection) { - this.$.content.selection = selection; - this.$.relatedEvents.setRelatedEvents(selection); - if (this.$.relatedEvents.hasRelatedEvents()) - this.$.relatedEvents.style.display = ''; - else - this.$.relatedEvents.style.display = 'none'; - } - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_thread_slice_sub_view_test.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_thread_slice_sub_view_test.html deleted file mode 100644 index 7cce4d0d9b8..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_thread_slice_sub_view_test.html +++ /dev/null @@ -1,78 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/model/thread_slice.html"> -<link rel="import" href="/tracing/ui/analysis/single_thread_slice_sub_view.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var newSliceEx = tr.c.TestUtils.newSliceEx; - var newFlowEventEx = tr.c.TestUtils.newFlowEventEx; - - test('instantiate', function() { - var model = new tr.Model(); - var t53 = model.getOrCreateProcess(52).getOrCreateThread(53); - t53.sliceGroup.pushSlice( - newSliceEx({title: 'a', start: 0.0, duration: 0.5})); - t53.sliceGroup.createSubSlices(); - - var selection = new tr.model.EventSet(); - selection.push(t53.sliceGroup.slices[0]); - - var viewEl = document.createElement('tr-ui-a-single-thread-slice-sub-view'); - viewEl.selection = selection; - this.addHTMLOutput(viewEl); - }); - - test('instantiateWithFlowEvent', function() { - var m = tr.c.TestUtils.newModel(function(m) { - m.p1 = m.getOrCreateProcess(1); - - m.t2 = m.p1.getOrCreateThread(2); - m.t3 = m.p1.getOrCreateThread(3); - m.t4 = m.p1.getOrCreateThread(4); - - m.sA = m.t2.sliceGroup.pushSlice( - newSliceEx({title: 'a', start: 0, end: 5, - type: tr.model.ThreadSlice})); - m.sB = m.t3.sliceGroup.pushSlice( - newSliceEx({title: 'b', start: 10, end: 15, - type: tr.model.ThreadSlice})); - m.sC = m.t4.sliceGroup.pushSlice( - newSliceEx({title: 'c', start: 20, end: 20, - type: tr.model.ThreadSlice})); - - m.t2.createSubSlices(); - m.t3.createSubSlices(); - m.t4.createSubSlices(); - - m.f1 = newFlowEventEx({ - 'title': 'flowish', start: 0, end: 10, - startSlice: m.sA, - endSlice: m.sB - }); - m.f2 = newFlowEventEx({ - 'title': 'flowish', start: 15, end: 21, - startSlice: m.sB, - endSlice: m.sC - }); - }); - - var selection = new tr.model.EventSet(); - selection.push(m.sA); - - var viewEl = document.createElement('tr-ui-a-single-thread-slice-sub-view'); - viewEl.selection = selection; - this.addHTMLOutput(viewEl); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_thread_time_slice_sub_view.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_thread_time_slice_sub_view.html deleted file mode 100644 index 8d82ca6ee04..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_thread_time_slice_sub_view.html +++ /dev/null @@ -1,174 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/color_scheme.html"> -<link rel="import" href="/tracing/base/iteration_helpers.html"> -<link rel="import" href="/tracing/base/sorted_array_utils.html"> -<link rel="import" href="/tracing/base/utils.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/ui/analysis/analysis_link.html"> -<link rel="import" href="/tracing/ui/analysis/analysis_sub_view.html"> -<link rel="import" href="/tracing/ui/analysis/generic_object_view.html"> -<link rel="import" href="/tracing/value/ui/scalar_span.html"> -<link rel="import" href="/tracing/value/unit.html"> - -<polymer-element name="tr-ui-a-single-thread-time-slice-sub-view" - extends="tr-ui-a-sub-view"> - <template> - <style> - table { - border-collapse: collapse; - border-width: 0; - margin-bottom: 25px; - width: 100%; - } - - table tr > td:first-child { - padding-left: 2px; - } - - table tr > td { - padding: 2px 4px 2px 4px; - vertical-align: text-top; - width: 150px; - } - - table td td { - padding: 0 0 0 0; - width: auto; - } - tr { - vertical-align: top; - } - - tr:nth-child(2n+0) { - background-color: #e2e2e2; - } - </style> - <table> - <tr> - <td>Running process:</td><td id="process-name"></td> - </tr> - <tr> - <td>Running thread:</td><td id="thread-name"></td> - </tr> - <tr> - <td>State:</td> - <td><b><span id="state"></span></b></td> - </tr> - <tr> - <td>Start:</td> - <td> - <tr-v-ui-scalar-span id="start"> - </tr-v-ui-scalar-span> - </td> - </tr> - <tr> - <td>Duration:</td> - <td> - <tr-v-ui-scalar-span id="duration"> - </tr-v-ui-scalar-span> - </td> - </tr> - - <tr> - <td>On CPU:</td><td id="on-cpu"></td> - </tr> - - <tr> - <td>Running instead:</td><td id="running-instead"></td> - </tr> - - <tr> - <td>Args:</td><td id="args"></td> - </tr> - </table> - </template> - - <script> - 'use strict'; - - Polymer({ - created: function() { - this.currentSelection_ = undefined; - }, - - get selection() { - return this.currentSelection_; - }, - - set selection(selection) { - var timeSlice = tr.b.getOnlyElement(selection); - - if (!(timeSlice instanceof tr.model.ThreadTimeSlice)) - throw new Error('Only supports thread time slices'); - - this.currentSelection_ = selection; - - var thread = timeSlice.thread; - - var shadowRoot = this.shadowRoot; - shadowRoot.querySelector('#state').textContent = timeSlice.title; - var stateColor = tr.b.ColorScheme.colorsAsStrings[timeSlice.colorId]; - shadowRoot.querySelector('#state').style.backgroundColor = stateColor; - - shadowRoot.querySelector('#process-name').textContent = - thread.parent.userFriendlyName; - shadowRoot.querySelector('#thread-name').textContent = - thread.userFriendlyName; - - shadowRoot.querySelector('#start').setValueAndUnit( - timeSlice.start, tr.v.Unit.byName.timeStampInMs); - shadowRoot.querySelector('#duration').setValueAndUnit( - timeSlice.duration, tr.v.Unit.byName.timeDurationInMs); - - var onCpuEl = shadowRoot.querySelector('#on-cpu'); - onCpuEl.textContent = ''; - var runningInsteadEl = shadowRoot.querySelector('#running-instead'); - if (timeSlice.cpuOnWhichThreadWasRunning) { - runningInsteadEl.parentElement.removeChild(runningInsteadEl); - - var cpuLink = document.createElement('tr-ui-a-analysis-link'); - cpuLink.selection = new tr.model.EventSet( - timeSlice.getAssociatedCpuSlice()); - cpuLink.textContent = - timeSlice.cpuOnWhichThreadWasRunning.userFriendlyName; - onCpuEl.appendChild(cpuLink); - } else { - onCpuEl.parentElement.removeChild(onCpuEl); - - var cpuSliceThatTookCpu = timeSlice.getCpuSliceThatTookCpu(); - if (cpuSliceThatTookCpu) { - var cpuLink = document.createElement('tr-ui-a-analysis-link'); - cpuLink.selection = new tr.model.EventSet(cpuSliceThatTookCpu); - if (cpuSliceThatTookCpu.thread) - cpuLink.textContent = cpuSliceThatTookCpu.thread.userFriendlyName; - else - cpuLink.textContent = cpuSliceThatTookCpu.title; - runningInsteadEl.appendChild(cpuLink); - } else { - runningInsteadEl.parentElement.removeChild(runningInsteadEl); - } - } - - var argsEl = shadowRoot.querySelector('#args'); - if (tr.b.dictionaryKeys(timeSlice.args).length > 0) { - var argsView = - document.createElement('tr-ui-a-generic-object-view'); - argsView.object = timeSlice.args; - - argsEl.parentElement.style.display = ''; - argsEl.textContent = ''; - argsEl.appendChild(argsView); - } else { - argsEl.parentElement.style.display = 'none'; - } - } - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_thread_time_slice_sub_view_test.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_thread_time_slice_sub_view_test.html deleted file mode 100644 index 5ab48cbe2cf..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_thread_time_slice_sub_view_test.html +++ /dev/null @@ -1,92 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/extras/importer/linux_perf/ftrace_importer.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/ui/analysis/single_thread_time_slice_sub_view.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - function createBasicModel() { - var lines = [ - 'Android.launcher-584 [001] d..3 12622.506890: sched_switch: prev_comm=Android.launcher prev_pid=584 prev_prio=120 prev_state=R+ ==> next_comm=Binder_1 next_pid=217 next_prio=120', // @suppress longLineCheck - ' Binder_1-217 [001] d..3 12622.506918: sched_switch: prev_comm=Binder_1 prev_pid=217 prev_prio=120 prev_state=D ==> next_comm=Android.launcher next_pid=584 next_prio=120', // @suppress longLineCheck - 'Android.launcher-584 [001] d..4 12622.506936: sched_wakeup: comm=Binder_1 pid=217 prio=120 success=1 target_cpu=001', // @suppress longLineCheck - 'Android.launcher-584 [001] d..3 12622.506950: sched_switch: prev_comm=Android.launcher prev_pid=584 prev_prio=120 prev_state=R+ ==> next_comm=Binder_1 next_pid=217 next_prio=120', // @suppress longLineCheck - ' Binder_1-217 [001] ...1 12622.507057: tracing_mark_write: B|128|queueBuffer', // @suppress longLineCheck - ' Binder_1-217 [001] ...1 12622.507175: tracing_mark_write: E', - ' Binder_1-217 [001] d..3 12622.507253: sched_switch: prev_comm=Binder_1 prev_pid=217 prev_prio=120 prev_state=S ==> next_comm=Android.launcher next_pid=584 next_prio=120' // @suppress longLineCheck - ]; - - return tr.c.TestUtils.newModelWithEvents([lines.join('\n')], { - shiftWorldToZero: false - }); - } - - test('runningSlice', function() { - var m = createBasicModel(); - - var cpu = m.kernel.cpus[1]; - var binderSlice = cpu.slices[0]; - assert.equal(binderSlice.title, 'Binder_1'); - var launcherSlice = cpu.slices[1]; - assert.equal(launcherSlice.title, 'Android.launcher'); - - - var thread = m.findAllThreadsNamed('Binder_1')[0]; - - var view = document.createElement( - 'tr-ui-a-single-thread-time-slice-sub-view'); - var selection = new tr.model.EventSet(); - selection.push(thread.timeSlices[0]); - view.selection = selection; - this.addHTMLOutput(view); - - // Clicking the analysis link should focus the Binder1's timeslice. - var didSelectionChangeHappen = false; - view.addEventListener('requestSelectionChange', function(e) { - assert.isTrue(e.selection.equals(new tr.model.EventSet(binderSlice))); - didSelectionChangeHappen = true; - }); - view.shadowRoot.querySelector('tr-ui-a-analysis-link').click(); - assert.isTrue(didSelectionChangeHappen); - }); - - test('sleepingSlice', function() { - var m = createBasicModel(); - - var cpu = m.kernel.cpus[1]; - var binderSlice = cpu.slices[0]; - assert.equal(binderSlice.title, 'Binder_1'); - var launcherSlice = cpu.slices[1]; - assert.equal(launcherSlice.title, 'Android.launcher'); - - - var thread = m.findAllThreadsNamed('Binder_1')[0]; - - var view = document.createElement( - 'tr-ui-a-single-thread-time-slice-sub-view'); - var selection = new tr.model.EventSet(); - selection.push(thread.timeSlices[1]); - view.selection = selection; - this.addHTMLOutput(view); - - // Clicking the analysis link should focus the Android.launcher slice - var didSelectionChangeHappen = false; - view.addEventListener('requestSelectionChange', function(e) { - assert.isTrue(e.selection.equals(new tr.model.EventSet(launcherSlice))); - didSelectionChangeHappen = true; - }); - view.shadowRoot.querySelector('tr-ui-a-analysis-link').click(); - assert.isTrue(didSelectionChangeHappen); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_user_expectation_sub_view.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_user_expectation_sub_view.html deleted file mode 100644 index 0c2ba50450a..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/single_user_expectation_sub_view.html +++ /dev/null @@ -1,81 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/iteration_helpers.html"> -<link rel="import" href="/tracing/ui/analysis/analysis_sub_view.html"> -<link rel="import" href="/tracing/ui/analysis/single_event_sub_view.html"> -<link rel="import" - href="/tracing/ui/analysis/user_expectation_related_samples_table.html"> -<link rel="import" href="/tracing/value/ui/scalar_span.html"> -<link rel="import" href="/tracing/value/unit.html"> -<link rel="import" href="/tracing/value/value_set.html"> - -<polymer-element name="tr-ui-a-single-user-expectation-sub-view" - extends="tr-ui-a-sub-view"> - <template> - <style> - :host { - display: flex; - flex-direction: row; - } - #events { - display: flex; - flex-direction: column; - } - </style> - <tr-ui-a-single-event-sub-view id="realView"></tr-ui-a-single-event-sub-view> - <div id="events"> - <tr-ui-a-user-expectation-related-samples-table id="relatedSamples"></tr-ui-a-user-expectation-related-samples-table> - </div> - </template> - <script> - 'use strict'; - - Polymer({ - created: function() { - this.currentSelection_ = undefined; - }, - - get selection() { - return this.currentSelection_; - }, - - set selection(selection) { - this.$.realView.addEventListener('customize-rows', - this.onCustomizeRows_.bind(this)); - - this.currentSelection_ = selection; - this.$.realView.setSelectionWithoutErrorChecks(selection); - - this.$.relatedSamples.selection = selection; - if (this.$.relatedSamples.hasRelatedSamples()) - this.$.events.style.display = ''; - else - this.$.events.style.display = 'none'; - }, - - get relatedEventsToHighlight() { - if (!this.currentSelection_) - return undefined; - return tr.b.getOnlyElement(this.currentSelection_).associatedEvents; - }, - - onCustomizeRows_: function(event) { - var ue = tr.b.getOnlyElement(this.selection); - - if (ue.rawCpuMs) { - event.rows.push({ - name: 'Total CPU', - value: tr.v.ui.createScalarSpan(ue.totalCpuMs, { - unit: tr.v.Unit.byName.timeDurationInMs - }) - }); - } - } - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/stack_frame.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/stack_frame.html deleted file mode 100644 index aeca20ee40d..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/stack_frame.html +++ /dev/null @@ -1,78 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> -<link rel="import" href="/tracing/ui/base/table.html"> - -<polymer-element name="tr-ui-a-stack-frame"> - <template> - <style> - :host { - display: flex; - flex-direction: row; - align-items: center; - } - </style> - <tr-ui-b-table id="table"></tr-ui-b-table> - </template> - <script> - 'use strict'; - - Polymer({ - ready: function() { - this.stackFrame_ = undefined; - this.$.table.tableColumns = []; - this.$.table.showHeader = true; - }, - - get stackFrame() { - return this.stackFrame_; - }, - - set stackFrame(stackFrame) { - var table = this.$.table; - - this.stackFrame_ = stackFrame; - if (stackFrame === undefined) { - table.tableColumns = []; - table.tableRows = []; - table.rebuild(); - return; - } - - var hasName = false; - var hasTitle = false; - - table.tableRows = stackFrame.stackTrace; - table.tableRows.forEach(function(row) { - hasName |= row.name !== undefined; - hasTitle |= row.title !== undefined; - }); - - var cols = []; - if (hasName) { - cols.push({ - title: 'Name', - value: function(row) { return row.name; } - }); - } - - if (hasTitle) { - cols.push({ - title: 'Title', - value: function(row) { return row.title; } - }); - } - - table.tableColumns = cols; - table.rebuild(); - }, - - tableForTesting: function() { - return this.$.table; - } - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/stack_frame_test.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/stack_frame_test.html deleted file mode 100644 index 91ee0e3bd57..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/stack_frame_test.html +++ /dev/null @@ -1,34 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> -<link rel="import" href="/tracing/ui/analysis/stack_frame.html"> -<link rel="import" href="/tracing/core/test_utils.html"> -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - test('instantiate', function() { - var model = new tr.Model(); - var fA = tr.c.TestUtils.newStackTrace(model, ['a1', 'a2', 'a3']); - - var stackFrameView = document.createElement('tr-ui-a-stack-frame'); - stackFrameView.stackFrame = fA; - this.addHTMLOutput(stackFrameView); - }); - - test('clearingStackFrame', function() { - var model = new tr.Model(); - var fA = tr.c.TestUtils.newStackTrace(model, ['a1', 'a2', 'a3']); - - var stackFrameView = document.createElement('tr-ui-a-stack-frame'); - stackFrameView.stackFrame = fA; - stackFrameView.stackFrame = undefined; - - assert.isUndefined(stackFrameView.stackFrame); - assert.lengthOf(stackFrameView.$.table.$.body.children, 0); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/stacked_pane.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/stacked_pane.html deleted file mode 100644 index ba5deb30330..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/stacked_pane.html +++ /dev/null @@ -1,89 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/base.html"> - -<!-- -@fileoverview Analysis view stacked pane. See the stacked pane view element -(tr-ui-a-stacked-pane-view) documentation for more details. ---> -<polymer-element name="tr-ui-a-stacked-pane"> - <script> - 'use strict'; - - Polymer({ - rebuild: function() { - /** - * Rebuild the pane if necessary. - * - * This method is not intended to be overriden by subclasses. Please - * override scheduleRebuildPane_() instead. - */ - if (!this.paneDirty_) { - // Avoid rebuilding unnecessarily as it breaks things like table - // selection. - return; - } - - this.paneDirty_ = false; - this.rebuildPane_(); - }, - - /** - * Mark the UI state of the pane as dirty and schedule a rebuild. - * - * This method is intended to be called by subclasses. - */ - scheduleRebuildPane_: function() { - if (this.paneDirty_) - return; - this.paneDirty_ = true; - setTimeout(this.rebuild.bind(this), 0); - }, - - /** - * Called when the pane is dirty and a rebuild is triggered. - * - * This method is intended to be overriden by subclasses (instead of - * directly overriding rebuild()). - */ - rebuildPane_: function() { - }, - - /** - * Request changing the child pane of this pane in the associated stacked - * pane view. If the assigned builder is undefined, request removing the - * current child pane. - * - * Note that setting this property before appended() is called will have no - * effect (as there will be no listener attached to the pane). - * - * This method is intended to be called by subclasses. - */ - set childPaneBuilder(childPaneBuilder) { - this.childPaneBuilder_ = childPaneBuilder; - this.dispatchEvent(new tr.b.Event('request-child-pane-change')); - }, - - get childPaneBuilder() { - return this.childPaneBuilder_; - }, - - /** - * Called right after the pane is appended to a pane view. - * - * This method triggers an immediate rebuild by default (if necessary). - * Subclasses are free to change this behavior (e.g. if a pane has lots of - * data to display, it might decide to defer rebuilding in order not to - * cause jank). - */ - appended: function() { - this.rebuild(); - } - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/stacked_pane_test.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/stacked_pane_test.html deleted file mode 100644 index f76feea8122..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/stacked_pane_test.html +++ /dev/null @@ -1,67 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/analysis/stacked_pane.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - test('rebuild', function() { - var pane = document.createElement('tr-ui-a-stacked-pane'); - var didFireBuildPane; - pane.rebuildPane_ = function() { - didFireBuildPane = true; - }; - - function checkRebuild(expectedDidFireBuildPane) { - didFireBuildPane = false; - pane.rebuild(); - assert.strictEqual(didFireBuildPane, expectedDidFireBuildPane); - } - - // No rebuilds should occur when not scheduled. - checkRebuild(false); - checkRebuild(false); - - // Single rebuild should occur when scheduled once. - pane.scheduleRebuildPane_(); - checkRebuild(true); - checkRebuild(false); - - // Only a single rebuild should occur even when scheduled multiple times. - pane.scheduleRebuildPane_(); - pane.scheduleRebuildPane_(); - checkRebuild(true); - checkRebuild(false); - }); - - test('changeChildPane', function() { - var pane = document.createElement('tr-ui-a-stacked-pane'); - var didFireEvent; - pane.addEventListener('request-child-pane-change', function() { - didFireEvent = true; - }); - - didFireEvent = false; - pane.childPaneBuilder = undefined; - assert.isTrue(didFireEvent); - - didFireEvent = false; - pane.childPaneBuilder = function() { - return undefined; - }; - assert.isTrue(didFireEvent); - - didFireEvent = false; - pane.childPaneBuilder = function() { - return document.createElement('tr-ui-a-stacked-pane'); - }; - assert.isTrue(didFireEvent); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/stacked_pane_view.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/stacked_pane_view.html deleted file mode 100644 index a3c52f780e5..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/stacked_pane_view.html +++ /dev/null @@ -1,189 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/base.html"> - -<!-- -@fileoverview Analysis view container which displays vertically stacked panes. -The panes represent a hierarchy where a child pane contains the details of the -current selection in its parent pane. The container provides simple primitives -for panes to request changing their child pane: - - +=<tr-ui-a-stacked-pane-view>=+ +=<tr-ui-a-stacked-pane-view>=+ - |+.<tr-ui-a-stacked-pane>....+| |+.<tr-ui-a-stacked-pane>....+| - |: Pane 1 +| ===========> |: Pane 1 +| - |+...........................+| Pane 1 |+...........................+| - |+.<tr-ui-a-stacked-pane>....+| requests |+.<tr-ui-a-stacked-pane>....+| - |: Pane 2 (detail of Pane 1) +| child pane |: Pane 4 (detail of Pane 1) +| - |+...........................+| change (e.g. |+...........................+| - |+.<tr-ui-a-stacked-pane>....+| selection +=============================+ - |: Pane 3 (detail of Pane 2) +| changed) - |+...........................+| - +=============================+ - -Note that the actual UI provided by tr-ui-a-stacked-pane-view and -tr-ui-a-stacked-pane is merely a wrapper container with flex box vertical -stacking. No other visual features (such as pane spacing or borders) is -provided by either element. - -The stacked pane element (tr-ui-a-stacked-pane) is defined in a separate file. - -Sample use case: - - Create an empty stacked pane view and add it to the DOM: - - var paneView = document.createElement('tr-ui-a-stacked-pane-view'); - someParentView.appendChild(paneView); - - Define one or more pane subclasses: - - <polymer-element name="some-pane-1" extends="tr-ui-a-stacked-pane"> - ... - </polymer-element> - - Set the top-level pane (by providing a builder function): - - paneView.setPaneBuilder(function() { - var topPane = document.createElement('some-pane-1'); - pane.someProperty = someValue; - return topPane; - }); - - Show a child pane with details upon user interaction (these methods should be - in the definition of the pane subclass Polymer element): - - ready: function() { - this.$.table.addEventListener( - 'selection-changed', this.changeChildPane_.bind(this)); - } - - changeChildPane_: function() { - this.childPaneBuilder = function() { - var selectedRow = this.$.table.selectedTableRow; - var detailsPane = document.createElement('some-pane-2'); - detailsPane.someProperty = selectedRow; - return detailsPane; - }.bind(this); - } ---> -<polymer-element name="tr-ui-a-stacked-pane-view"> - <template> - <style> - :host { - display: flex; - flex-direction: column; - } - - #pane_container > * { - flex: 0 0 auto; - } - </style> - <div id="pane_container"> - </div> - </template> - <script> - 'use strict'; - - Polymer({ - /** - * Add a pane to the stacked pane view. This method performs two operations: - * - * 1. Remove existing descendant panes - * If the optional parent pane is provided, all its current descendant - * panes are removed. Otherwise, all panes are removed from the view. - * - * 2. Build and add new pane - * If a pane builder is provided and returns a pane, the new pane is - * appended to the view (after the provided parent, or at the top). - */ - setPaneBuilder: function(paneBuilder, opt_parentPane) { - var paneContainer = this.$.pane_container; - - // If the parent pane is provided, it must be an HTML element and a child - // of the pane container. - if (opt_parentPane) { - if (!(opt_parentPane instanceof HTMLElement)) - throw new Error('Parent pane must be an HTML element'); - if (opt_parentPane.parentElement !== paneContainer) - throw new Error('Parent pane must be a child of the pane container'); - } - - // Remove all descendants of the parent pane (or all panes if no parent - // pane was specified) in reverse order. - while (paneContainer.lastElementChild !== null && - paneContainer.lastElementChild !== opt_parentPane) { - var removedPane = this.$.pane_container.lastElementChild; - var listener = this.listeners_.get(removedPane); - if (listener === undefined) - throw new Error('No listener associated with pane'); - this.listeners_.delete(removedPane); - removedPane.removeEventListener( - 'request-child-pane-change', listener); - paneContainer.removeChild(removedPane); - } - - if (opt_parentPane && opt_parentPane.parentElement !== paneContainer) - throw new Error('Parent pane was removed from the pane container'); - - // This check is performed here (and not at the beginning of the method) - // because undefined pane builder means that the parent pane requested - // having no child pane (e.g. when selection is cleared). - if (!paneBuilder) - return; - - var pane = paneBuilder(); - if (!pane) - return; - - if (!(pane instanceof HTMLElement)) - throw new Error('Pane must be an HTML element'); - - // Listen for child pane change requests from the newly added pane. - var listener = function(event) { - this.setPaneBuilder(pane.childPaneBuilder, pane); - }.bind(this); - if (!this.listeners_) { - // Instead of initializing the listeners map in a created() callback, - // we do it lazily here so that subclasses could provide their own - // created() callback (Polymer currently doesn't allow calling overriden - // superclass methods in strict mode). - this.listeners_ = new WeakMap(); - } - this.listeners_.set(pane, listener); - pane.addEventListener('request-child-pane-change', listener); - - paneContainer.appendChild(pane); - pane.appended(); - }, - - /** - * Request rebuilding all panes in the view. The panes are rebuilt from the - * top to the bottom (so that parent panes could request changing their - * child panes when they're being rebuilt and the newly constructed child - * panes would be rebuilt as well). - */ - rebuild: function() { - var currentPane = this.$.pane_container.firstElementChild; - while (currentPane) { - currentPane.rebuild(); - currentPane = currentPane.nextElementSibling; - } - }, - - // For testing purposes. - get panesForTesting() { - var panes = []; - var currentChild = this.$.pane_container.firstElementChild; - while (currentChild) { - panes.push(currentChild); - currentChild = currentChild.nextElementSibling; - } - return panes; - } - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/stacked_pane_view_test.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/stacked_pane_view_test.html deleted file mode 100644 index 5afcd1bd1f0..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/stacked_pane_view_test.html +++ /dev/null @@ -1,203 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/analysis/stacked_pane.html"> -<link rel="import" href="/tracing/ui/analysis/stacked_pane_view.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - function createPaneView() { - return document.createElement('tr-ui-a-stacked-pane-view'); - } - - function createPane(paneId, opt_rebuildPaneCallback, opt_appendedCallback) { - var paneEl = document.createElement('tr-ui-a-stacked-pane'); - paneEl.paneId = paneId; - - var divEl = document.createElement('div'); - divEl.textContent = 'Pane ' + paneId; - divEl.style.width = '400px'; - divEl.style.background = '#ccc'; - divEl.style.textAlign = 'center'; - paneEl.appendChild(divEl); - - if (opt_rebuildPaneCallback) - paneEl.rebuildPane_ = opt_rebuildPaneCallback; - - if (opt_appendedCallback) - paneEl.appended = opt_appendedCallback; - - return paneEl; - } - - function createPaneBuilder(paneId, opt_rebuildPaneCallback, - opt_appendedCallback) { - return createPane.bind( - undefined, paneId, opt_rebuildPaneCallback, opt_appendedCallback); - } - - function assertPanes(paneView, expectedPaneIds) { - var actualPaneIds = paneView.panesForTesting.map(function(pane) { - return pane.paneId; - }); - assert.deepEqual(actualPaneIds, expectedPaneIds); - } - - test('instantiate_empty', function() { - var viewEl = createPaneView(); - viewEl.rebuild(); - assertPanes(viewEl, []); - // Don't add the pane to HTML output because it has zero height. - }); - - test('instantiate_singlePane', function() { - var viewEl = createPaneView(); - - viewEl.setPaneBuilder(createPaneBuilder(1)); - viewEl.rebuild(); - - assertPanes(viewEl, [1]); - this.addHTMLOutput(viewEl); - }); - - test('instantiate_multiplePanes', function() { - var viewEl = createPaneView(); - - viewEl.setPaneBuilder(createPaneBuilder(1)); - viewEl.setPaneBuilder(createPaneBuilder(2), viewEl.panesForTesting[0]); - viewEl.setPaneBuilder(createPaneBuilder(3), viewEl.panesForTesting[1]); - - assertPanes(viewEl, [1, 2, 3]); - this.addHTMLOutput(viewEl); - }); - - test('changePanes', function() { - var viewEl = createPaneView(); - - viewEl.setPaneBuilder(createPaneBuilder(1)); - assertPanes(viewEl, [1]); - - viewEl.setPaneBuilder(null); - assertPanes(viewEl, []); - - viewEl.setPaneBuilder(createPaneBuilder(2)); - assertPanes(viewEl, [2]); - - viewEl.setPaneBuilder(createPaneBuilder(3), viewEl.panesForTesting[0]); - assertPanes(viewEl, [2, 3]); - - viewEl.setPaneBuilder(createPaneBuilder(4), viewEl.panesForTesting[0]); - assertPanes(viewEl, [2, 4]); - - viewEl.setPaneBuilder(createPaneBuilder(5), viewEl.panesForTesting[1]); - assertPanes(viewEl, [2, 4, 5]); - - viewEl.setPaneBuilder(createPaneBuilder(6), viewEl.panesForTesting[2]); - assertPanes(viewEl, [2, 4, 5, 6]); - - viewEl.setPaneBuilder(createPaneBuilder(7), viewEl.panesForTesting[1]); - assertPanes(viewEl, [2, 4, 7]); - - this.addHTMLOutput(viewEl); - }); - - test('childPanes', function() { - var viewEl = createPaneView(); - - viewEl.setPaneBuilder(createPaneBuilder(1)); - assertPanes(viewEl, [1]); - - // Pane 1 requests a child pane 2. - var pane1 = viewEl.panesForTesting[0]; - pane1.childPaneBuilder = createPaneBuilder(2); - assertPanes(viewEl, [1, 2]); - - // Pane 2 requests removing its child pane (nothing happens). - var pane2 = viewEl.panesForTesting[1]; - pane2.childPaneBuilder = undefined; - assertPanes(viewEl, [1, 2]); - - // Pane 2 requests a child pane 3. - pane2.childPaneBuilder = createPaneBuilder(3); - assertPanes(viewEl, [1, 2, 3]); - - // Pane 2 requests a child pane 4 (its previous child pane 3 is removed). - pane2.childPaneBuilder = createPaneBuilder(4); - assertPanes(viewEl, [1, 2, 4]); - - // Pane 1 requests removing its child pane (panes 2 and 4 are removed). - pane1.childPaneBuilder = undefined; - assertPanes(viewEl, [1]); - - // Check that removed panes cannot affect the pane view. - pane2.childPaneBuilder = createPaneBuilder(5); - assertPanes(viewEl, [1]); - - // Pane 1 requests a child pane 6 (check that everything still works). - pane1.childPaneBuilder = createPaneBuilder(6); - assertPanes(viewEl, [1, 6]); - - // Change the top pane to pane 7. - viewEl.setPaneBuilder(createPaneBuilder(7)); - assertPanes(viewEl, [7]); - - // Check that removed panes cannot affect the pane view. - pane1.childPaneBuilder = createPaneBuilder(5); - assertPanes(viewEl, [7]); - }); - - test('rebuild', function() { - var viewEl = createPaneView(); - - var rebuiltPaneIds = []; - var rebuildPaneCallback = function() { - rebuiltPaneIds.push(this.paneId); - }; - - viewEl.setPaneBuilder(createPaneBuilder(1, rebuildPaneCallback)); - viewEl.setPaneBuilder(createPaneBuilder(2, rebuildPaneCallback), - viewEl.panesForTesting[0]); - viewEl.setPaneBuilder(createPaneBuilder(3, rebuildPaneCallback), - viewEl.panesForTesting[1]); - - // Rebuild isn't triggered. - assert.deepEqual(rebuiltPaneIds, []); - - // Rebuild is triggered, but it isn't necessary (all panes are clean). - viewEl.rebuild(); - assert.deepEqual(rebuiltPaneIds, []); - - // All panes are now marked as dirty, but rebuild isn't triggered (it was - // only scheduled). - viewEl.panesForTesting.forEach(function(pane) { - pane.scheduleRebuildPane_(); - }); - assert.deepEqual(rebuiltPaneIds, []); - - // Finally, rebuild was triggered and the panes are dirty. - viewEl.rebuild(); - assert.deepEqual(rebuiltPaneIds, [1, 2, 3]); - - // Make sure that panes are clean after the previous rebuild. - viewEl.rebuild(); - assert.deepEqual(rebuiltPaneIds, [1, 2, 3]); - }); - - test('appended', function() { - var viewEl = createPaneView(); - var didFireAppended; - - didFireAppended = false; - viewEl.setPaneBuilder(createPaneBuilder(1, undefined, function() { - didFireAppended = true; - })); - assert.isTrue(didFireAppended); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/stub_analysis_table.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/stub_analysis_table.html deleted file mode 100644 index c08278c9b44..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/stub_analysis_table.html +++ /dev/null @@ -1,48 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/base.html"> -<script> -'use strict'; - -tr.exportTo('tr.ui.analysis', function() { - function StubAnalysisTable() { - this.ownerDocument_ = document; - this.nodes_ = []; - } - - StubAnalysisTable.prototype = { - __proto__: Object.protoype, - - get ownerDocument() { - return this.ownerDocument_; - }, - - appendChild: function(node) { - if (node.tagName == 'TFOOT' || node.tagName == 'THEAD' || - node.tagName == 'TBODY') { - node.__proto__ = StubAnalysisTable.prototype; - node.nodes_ = []; - node.ownerDocument_ = document; - } - this.nodes_.push(node); - }, - - get lastNode() { - return this.nodes_.pop(); - }, - - get nodeCount() { - return this.nodes_.length; - } - }; - - return { - StubAnalysisTable: StubAnalysisTable - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/user_expectation_related_samples_table.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/user_expectation_related_samples_table.html deleted file mode 100644 index fb5b694c17b..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/user_expectation_related_samples_table.html +++ /dev/null @@ -1,85 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2016 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/analysis/analysis_link.html"> -<link rel="import" href="/tracing/ui/base/table.html"> - -<polymer-element name="tr-ui-a-user-expectation-related-samples-table"> - <template> - <style> - #table { - flex: 1 1 auto; - align-self: stretch; - } - </style> - <tr-ui-b-table id="table"></tr-ui-b-table> - </template> - <script> - 'use strict'; - - Polymer({ - ready: function() { - this.samples_ = []; - this.$.table.tableColumns = [ - { - title: 'Event(s)', - value: function(row) { - var typeEl = document.createElement('span'); - typeEl.innerText = row.type; - if (row.tooltip) - typeEl.title = row.tooltip; - return typeEl; - }, - width: '150px' - }, - { - title: 'Link', - width: '100%', - value: function(row) { - var linkEl = document.createElement('tr-ui-a-analysis-link'); - if (row.name) - linkEl.setSelectionAndContent(row.selection, row.name); - else - linkEl.selection = row.selection; - return linkEl; - } - } - ]; - }, - - hasRelatedSamples: function() { - return (this.samples_ && this.samples_.length > 0); - }, - - set selection(eventSet) { - this.samples_ = []; - var samples = new tr.model.EventSet; - eventSet.forEach(function(ue) { - samples.addEventSet(ue.associatedSamples); - }.bind(this)); - - if (samples.length > 0) { - this.samples_.push({ - type: 'Overlapping samples', - tooltip: 'All samples overlapping the selected user expectation(s).', - selection: samples - }); - } - this.updateContents_(); - }, - - updateContents_: function() { - var table = this.$.table; - if (this.samples_ && this.samples_.length > 0) - table.tableRows = this.samples_.slice(); - else - table.tableRows = []; - table.rebuild(); - } - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/user_expectation_related_samples_table_test.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/user_expectation_related_samples_table_test.html deleted file mode 100644 index eab3be89046..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/analysis/user_expectation_related_samples_table_test.html +++ /dev/null @@ -1,64 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2016 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/model/sample.html"> -<link rel="import" href="/tracing/model/thread_slice.html"> -<link rel="import" - href="/tracing/ui/analysis/user_expectation_related_samples_table.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - function createModel() { - var m = tr.c.TestUtils.newModel(function(m) { - m.p1 = m.getOrCreateProcess(1); - m.t2 = m.p1.getOrCreateThread(2); - var s1 = new tr.model.Sample(null, m.t2, 'a_1', 1); - var s2 = new tr.model.Sample(null, m.t2, 'a_2', 2); - var s3 = new tr.model.Sample(null, m.t2, 'a_3', 3); - var s4 = new tr.model.Sample(null, m.t2, 'a_4', 4); - var s5 = new tr.model.Sample(null, m.t2, 'a_5', 5); - var s6 = new tr.model.Sample(null, m.t2, 'a_6', 6); - m.samples.push(s1, s2, s3, s4, s5, s6); - m.ve = new tr.c.TestUtils.newSliceEx( - {title: 'V8.Execute', start: 0, end: 4, type: tr.model.ThreadSlice}); - m.t2.sliceGroup.pushSlice(m.ve); - m.up = new tr.c.TestUtils.newInteractionRecord(m, 0, 4); - m.up.associatedEvents.push(m.ve); - m.userModel.expectations.push(m.up); - }); - return m; - } - - test('overlappingSamples', function() { - var m = createModel(); - - var viewEl = document.createElement( - 'tr-ui-a-user-expectation-related-samples-table'); - viewEl.selection = new tr.model.EventSet([m.up]); - - var overlappingSamples; - viewEl.$.table.tableRows.forEach(function(row) { - if (row.type === 'Overlapping samples') { - assert.isUndefined(overlappingSamples); - overlappingSamples = row.selection; - } - }); - - var samplesTitles = overlappingSamples.map(function(e) { - return e.title; - }); - assert.sameMembers(samplesTitles, - ['a_1', 'a_2', 'a_3', 'a_4']); - }); - -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/annotations/annotation_view.html b/chromium/third_party/catapult/tracing/tracing/ui/annotations/annotation_view.html deleted file mode 100644 index 6edaff2e046..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/annotations/annotation_view.html +++ /dev/null @@ -1,31 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/base.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.annotations', function() { - /** - * A base class for all annotation views. - * @constructor - */ - function AnnotationView(viewport, annotation) { - } - - AnnotationView.prototype = { - draw: function(ctx) { - throw new Error('Not implemented'); - } - }; - - return { - AnnotationView: AnnotationView - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/annotations/annotation_view_test.html b/chromium/third_party/catapult/tracing/tracing/ui/annotations/annotation_view_test.html deleted file mode 100644 index 5ff3f314655..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/annotations/annotation_view_test.html +++ /dev/null @@ -1,70 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/comment_box_annotation.html"> -<link rel="import" href="/tracing/model/location.html"> -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/model/rect_annotation.html"> -<link rel="import" href="/tracing/model/x_marker_annotation.html"> -<link rel="import" href="/tracing/ui/timeline_track_view.html"> -<link rel="import" href="/tracing/ui/timeline_viewport.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - - function createPopulatedTimeline() { - var model = new tr.Model(); - var process = model.getOrCreateProcess(1); - var thread = process.getOrCreateThread(2); - thread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx( - {title: 'a', start: 80, duration: 50})); - - var timeline = document.createElement('tr-ui-timeline-track-view'); - var vp = new tr.ui.TimelineViewport(timeline); - timeline.model = model; - timeline.style.maxHeight = '600px'; - - return timeline; - } - - test('rectAnnotation', function() { - var fakeYComponents1 = [{stableId: '1.2', yPercentOffset: 0.3}]; - var fakeYComponents2 = [{stableId: '1.2', yPercentOffset: 0.9}]; - var start = new tr.model.Location(50, fakeYComponents1); - var end = new tr.model.Location(100, fakeYComponents2); - var rectAnnotation = new tr.model.RectAnnotation(start, end); - - var timeline = createPopulatedTimeline(); - timeline.model.addAnnotation(rectAnnotation); - this.addHTMLOutput(timeline); - }); - - test('xMarkerAnnotation', function() { - var xMarkerAnnotation = new tr.model.XMarkerAnnotation(90); - - var timeline = createPopulatedTimeline(); - var model = timeline.model; - timeline.model.addAnnotation(xMarkerAnnotation); - this.addHTMLOutput(timeline); - }); - - test('commentBoxAnnotation', function() { - var fakeYComponents = [{stableId: '1.2', yPercentOffset: 0.5}]; - var location = new tr.model.Location(120, fakeYComponents); - var text = 'abc'; - var commentBoxAnnotation = - new tr.model.CommentBoxAnnotation(location, text); - - var timeline = createPopulatedTimeline(); - timeline.model.addAnnotation(commentBoxAnnotation); - this.addHTMLOutput(timeline); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/annotations/comment_box_annotation_view.html b/chromium/third_party/catapult/tracing/tracing/ui/annotations/comment_box_annotation_view.html deleted file mode 100644 index 03eba86146b..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/annotations/comment_box_annotation_view.html +++ /dev/null @@ -1,88 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/annotations/annotation_view.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.annotations', function() { - /** - * A view of a comment box consisting of a textarea and a line to the - * actual location. - * @extends {AnnotationView} - * @constructor - */ - function CommentBoxAnnotationView(viewport, annotation) { - this.viewport_ = viewport; - this.annotation_ = annotation; - this.textArea_ = undefined; - - this.styleWidth = 250; - this.styleHeight = 50; - this.fontSize = 10; - this.rightOffset = 50; - this.topOffset = 25; - } - - CommentBoxAnnotationView.prototype = { - __proto__: tr.ui.annotations.AnnotationView.prototype, - - removeTextArea: function() { - this.textArea_.parentNode.removeChild(this.textArea_); - }, - - draw: function(ctx) { - var coords = this.annotation_.location.toViewCoordinates(this.viewport_); - if (coords.viewX < 0) { - if (this.textArea_) - this.textArea_.style.visibility = 'hidden'; - return; - } - - // Set up textarea element. - if (!this.textArea_) { - this.textArea_ = document.createElement('textarea'); - this.textArea_.style.position = 'absolute'; - this.textArea_.readOnly = true; - this.textArea_.value = this.annotation_.text; - // Set the z-index so that this is shown on top of canvas. - this.textArea_.style.zIndex = 1; - ctx.canvas.parentNode.appendChild(this.textArea_); - } - - this.textArea_.style.width = this.styleWidth + 'px'; - this.textArea_.style.height = this.styleHeight + 'px'; - this.textArea_.style.fontSize = this.fontSize + 'px'; - this.textArea_.style.visibility = 'visible'; - - // Update positions to latest coordinate. - this.textArea_.style.left = - coords.viewX + ctx.canvas.getBoundingClientRect().left + - this.rightOffset + 'px'; - this.textArea_.style.top = - coords.viewY - ctx.canvas.getBoundingClientRect().top - - this.topOffset + 'px'; - - // Draw pointer line from offset to actual location. - ctx.strokeStyle = 'rgb(0, 0, 0)'; - ctx.lineWidth = 2; - ctx.beginPath(); - tr.ui.b.drawLine(ctx, coords.viewX, - coords.viewY - ctx.canvas.getBoundingClientRect().top, - coords.viewX + this.rightOffset, - coords.viewY - this.topOffset - - ctx.canvas.getBoundingClientRect().top); - ctx.stroke(); - } - }; - - return { - CommentBoxAnnotationView: CommentBoxAnnotationView - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/annotations/rect_annotation_view.html b/chromium/third_party/catapult/tracing/tracing/ui/annotations/rect_annotation_view.html deleted file mode 100644 index 780f0268b3e..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/annotations/rect_annotation_view.html +++ /dev/null @@ -1,57 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/annotations/annotation_view.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.annotations', function() { - /** - * A view responsible for drawing a single highlight rectangle box on - * the timeline. - * @extends {AnnotationView} - * @constructor - */ - function RectAnnotationView(viewport, annotation) { - this.viewport_ = viewport; - this.annotation_ = annotation; - } - - RectAnnotationView.prototype = { - __proto__: tr.ui.annotations.AnnotationView.prototype, - - draw: function(ctx) { - var dt = this.viewport_.currentDisplayTransform; - var startCoords = - this.annotation_.startLocation.toViewCoordinates(this.viewport_); - var endCoords = - this.annotation_.endLocation.toViewCoordinates(this.viewport_); - - // Prevent drawing into the ruler track by clamping the initial Y - // point and the rect's Y size. - var startY = startCoords.viewY - ctx.canvas.getBoundingClientRect().top; - var sizeY = endCoords.viewY - startCoords.viewY; - if (startY + sizeY < 0) { - // In this case sizeY is negative. If final Y is negative, - // overwrite startY so that the rectangle ends at y=0. - startY = sizeY; - } else if (startY < 0) { - startY = 0; - } - - ctx.fillStyle = this.annotation_.fillStyle; - ctx.fillRect(startCoords.viewX, startY, - endCoords.viewX - startCoords.viewX, sizeY); - } - }; - - return { - RectAnnotationView: RectAnnotationView - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/annotations/x_marker_annotation_view.html b/chromium/third_party/catapult/tracing/tracing/ui/annotations/x_marker_annotation_view.html deleted file mode 100644 index ec6a9e1cc21..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/annotations/x_marker_annotation_view.html +++ /dev/null @@ -1,42 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/annotations/annotation_view.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.annotations', function() { - /** - * A view that draws a vertical line on the timeline at a specific timestamp. - * @extends {AnnotationView} - * @constructor - */ - function XMarkerAnnotationView(viewport, annotation) { - this.viewport_ = viewport; - this.annotation_ = annotation; - } - - XMarkerAnnotationView.prototype = { - __proto__: tr.ui.annotations.AnnotationView.prototype, - - draw: function(ctx) { - var dt = this.viewport_.currentDisplayTransform; - var viewX = dt.xWorldToView(this.annotation_.timestamp); - - ctx.beginPath(); - tr.ui.b.drawLine(ctx, viewX, 0, viewX, ctx.canvas.height); - ctx.strokeStyle = this.annotation_.strokeStyle; - ctx.stroke(); - } - }; - - return { - XMarkerAnnotationView: XMarkerAnnotationView - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/animation.html b/chromium/third_party/catapult/tracing/tracing/ui/base/animation.html deleted file mode 100644 index e0dce339240..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/animation.html +++ /dev/null @@ -1,79 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> -<link rel="import" href="/tracing/base/base.html"> -<script> -'use strict'; - -tr.exportTo('tr.ui.b', function() { - /** - * Represents a procedural animation that can be run by an - * tr.ui.b.AnimationController. - * - * @constructor - */ - function Animation() { - } - - Animation.prototype = { - - /** - * Called when an animation has been queued after a running animation. - * - * @return {boolean} True if the animation can take on the responsibilities - * of the running animation. If true, takeOverFor will be called on the - * animation. - * - * This can be used to build animations that accelerate as pairs of them are - * queued. - */ - canTakeOverFor: function(existingAnimation) { - throw new Error('Not implemented'); - }, - - /** - * Called to take over responsiblities of an existingAnimation. - * - * At this point, the existingAnimation has been ticked one last time, then - * stopped. This animation will be started after this returns and has the - * job of finishing(or transitioning away from) the effect the existing - * animation was trying to accomplish. - */ - takeOverFor: function(existingAnimation, newStartTimestamp, target) { - throw new Error('Not implemented'); - }, - - start: function(timestamp, target) { - throw new Error('Not implemented'); - }, - - /** - * Called when an animation is stopped before it finishes. The animation can - * do what it wants here, usually nothing. - * - * @param {Number} timestamp When the animation was stopped. - * @param {Object} target The object being animated. May be undefined, take - * care. - * @param {boolean} willBeTakenOverByAnotherAnimation Whether this animation - * is going to be handed to another animation's takeOverFor function. - */ - didStopEarly: function(timestamp, target, - willBeTakenOverByAnotherAnimation) { - }, - - /** - * @return {boolean} true if the animation is finished. - */ - tick: function(timestamp, target) { - throw new Error('Not implemented'); - } - }; - - return { - Animation: Animation - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/animation_controller.html b/chromium/third_party/catapult/tracing/tracing/ui/base/animation_controller.html deleted file mode 100644 index 4b94bd456e9..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/animation_controller.html +++ /dev/null @@ -1,140 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> -<link rel="import" href="/tracing/base/event_target.html"> -<link rel="import" href="/tracing/base/raf.html"> -<link rel="import" href="/tracing/ui/base/animation.html"> -<script> -'use strict'; - -tr.exportTo('tr.ui.b', function() { - /** - * Manages execution, queueing and blending of tr.ui.b.Animations against - * a single target. - * - * Targets must have a cloneAnimationState() method that returns all the - * animatable states of that target. - * - * @constructor - * @extends {tr.b.EventTarget} - */ - function AnimationController() { - tr.b.EventTarget.call(this); - - this.target_ = undefined; - - this.activeAnimation_ = undefined; - - this.tickScheduled_ = false; - } - - AnimationController.prototype = { - __proto__: tr.b.EventTarget.prototype, - - get target() { - return this.target_; - }, - - set target(target) { - if (this.activeAnimation_) - throw new Error('Cannot change target while animation is running.'); - if (target.cloneAnimationState === undefined || - typeof target.cloneAnimationState !== 'function') - throw new Error('target must have a cloneAnimationState function'); - - this.target_ = target; - }, - - get activeAnimation() { - return this.activeAnimation_; - }, - - get hasActiveAnimation() { - return !!this.activeAnimation_; - }, - - queueAnimation: function(animation, opt_now) { - if (this.target_ === undefined) - throw new Error('Cannot queue animations without a target'); - - var now; - if (opt_now !== undefined) - now = opt_now; - else - now = window.performance.now(); - - if (this.activeAnimation_) { - // Must tick the animation before stopping it case its about to stop, - // and to update the target with its final sets of edits up to this - // point. - var done = this.activeAnimation_.tick(now, this.target_); - if (done) - this.activeAnimation_ = undefined; - } - - if (this.activeAnimation_) { - if (animation.canTakeOverFor(this.activeAnimation_)) { - this.activeAnimation_.didStopEarly(now, this.target_, true); - animation.takeOverFor(this.activeAnimation_, now, this.target_); - } else { - this.activeAnimation_.didStopEarly(now, this.target_, false); - } - } - this.activeAnimation_ = animation; - this.activeAnimation_.start(now, this.target_); - - if (this.tickScheduled_) - return; - this.tickScheduled_ = true; - tr.b.requestAnimationFrame(this.tickActiveAnimation_, this); - }, - - cancelActiveAnimation: function(opt_now) { - if (!this.activeAnimation_) - return; - var now; - if (opt_now !== undefined) - now = opt_now; - else - now = window.performance.now(); - this.activeAnimation_.didStopEarly(now, this.target_, false); - this.activeAnimation_ = undefined; - }, - - tickActiveAnimation_: function(frameBeginTime) { - this.tickScheduled_ = false; - if (!this.activeAnimation_) - return; - - if (this.target_ === undefined) { - this.activeAnimation_.didStopEarly(frameBeginTime, this.target_, false); - return; - } - - var oldTargetState = this.target_.cloneAnimationState(); - - var done = this.activeAnimation_.tick(frameBeginTime, this.target_); - if (done) - this.activeAnimation_ = undefined; - - if (this.activeAnimation_) { - this.tickScheduled_ = true; - tr.b.requestAnimationFrame(this.tickActiveAnimation_, this); - } - - if (oldTargetState) { - var e = new tr.b.Event('didtick'); - e.oldTargetState = oldTargetState; - this.dispatchEvent(e, false, false); - } - } - }; - - return { - AnimationController: AnimationController - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/animation_controller_test.html b/chromium/third_party/catapult/tracing/tracing/ui/base/animation_controller_test.html deleted file mode 100644 index a830a5902dd..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/animation_controller_test.html +++ /dev/null @@ -1,166 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> -<link rel="import" href="/tracing/base/utils.html"> -<link rel="import" href="/tracing/ui/base/animation_controller.html"> -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - function SimpleAnimation(options) { - this.stopTime = options.stopTime; - - this.startCalled = false; - this.didStopEarlyCalled = false; - this.wasTakenOver = false; - this.tickCount = 0; - } - - SimpleAnimation.prototype = { - __proto__: tr.ui.b.Animation.prototype, - - canTakeOverFor: function(existingAnimation) { - return false; - }, - - takeOverFor: function(existingAnimation, newStartTimestamp, target) { - throw new Error('Not implemented'); - }, - - start: function(timestamp, target) { - this.startCalled = true; - }, - - didStopEarly: function(timestamp, target, willBeTakenOver) { - this.didStopEarlyCalled = true; - this.wasTakenOver = willBeTakenOver; - }, - - /** - * @return {boolean} true if the animation is finished. - */ - tick: function(timestamp, target) { - this.tickCount++; - return timestamp >= this.stopTime; - } - }; - - test('cancel', function() { - var target = { - x: 0, - cloneAnimationState: function() { return {x: this.x}; } - }; - - var controller = new tr.ui.b.AnimationController(); - controller.target = target; - - var animation = new SimpleAnimation({stopTime: 100}); - controller.queueAnimation(animation); - - tr.b.forcePendingRAFTasksToRun(0); - assert.equal(animation.tickCount, 1); - controller.cancelActiveAnimation(); - assert.isFalse(controller.hasActiveAnimation); - assert.isTrue(animation.didStopEarlyCalled); - }); - - test('simple', function() { - var target = { - x: 0, - cloneAnimationState: function() { return {x: this.x}; } - }; - - var controller = new tr.ui.b.AnimationController(); - controller.target = target; - - var animation = new SimpleAnimation({stopTime: 100}); - controller.queueAnimation(animation); - - tr.b.forcePendingRAFTasksToRun(0); - assert.equal(animation.tickCount, 1); - assert.isTrue(controller.hasActiveAnimation); - - tr.b.forcePendingRAFTasksToRun(100); - assert.equal(animation.tickCount, 2); - assert.isFalse(controller.hasActiveAnimation); - }); - - test('queueTwo', function() { - // Clear all pending rafs so if something is lingering it will blow up here. - tr.b.forcePendingRAFTasksToRun(0); - - var target = { - x: 0, - cloneAnimationState: function() { return {x: this.x}; } - }; - - var controller = new tr.ui.b.AnimationController(); - controller.target = target; - - var a1 = new SimpleAnimation({stopTime: 100}); - var a2 = new SimpleAnimation({stopTime: 100}); - controller.queueAnimation(a1, 0); - assert.isTrue(a1.startCalled); - controller.queueAnimation(a2, 50); - assert.isTrue(a1.didStopEarlyCalled); - assert.isTrue(a2.startCalled); - - tr.b.forcePendingRAFTasksToRun(150); - assert.isFalse(controller.hasActiveAnimation); - assert.isAbove(a2.tickCount, 0); - }); - - /** - * @constructor - */ - function AnimationThatCanTakeOverForSimpleAnimation() { - this.takeOverForAnimation = undefined; - } - - AnimationThatCanTakeOverForSimpleAnimation.prototype = { - __proto__: tr.ui.b.Animation.prototype, - - - canTakeOverFor: function(existingAnimation) { - return existingAnimation instanceof SimpleAnimation; - }, - - takeOverFor: function(existingAnimation, newStartTimestamp, target) { - this.takeOverForAnimation = existingAnimation; - }, - - start: function(timestamp, target) { - this.startCalled = true; - } - }; - - test('takeOver', function() { - var target = { - x: 0, - cloneAnimationState: function() { return {x: this.x}; } - }; - - var controller = new tr.ui.b.AnimationController(); - controller.target = target; - - var a1 = new SimpleAnimation({stopTime: 100}); - var a2 = new AnimationThatCanTakeOverForSimpleAnimation(); - controller.queueAnimation(a1, 0); - assert.isTrue(a1.startCalled); - assert.equal(a1.tickCount, 0); - controller.queueAnimation(a2, 10); - assert.isTrue(a1.didStopEarlyCalled); - assert.isTrue(a1.wasTakenOver); - assert.equal(a1.tickCount, 1); - - assert.equal(a1, a2.takeOverForAnimation); - assert.isTrue(a2.startCalled); - - controller.cancelActiveAnimation(); - assert.isFalse(controller.hasActiveAnimation); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/bar_chart.html b/chromium/third_party/catapult/tracing/tracing/ui/base/bar_chart.html deleted file mode 100644 index b2893762db3..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/bar_chart.html +++ /dev/null @@ -1,178 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/base/chart_base_2d_brushable_x.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.b', function() { - var ColorScheme = tr.b.ColorScheme; - var ChartBase2DBrushX = tr.ui.b.ChartBase2DBrushX; - var getColorOfKey = tr.ui.b.getColorOfKey; - - // @constructor - var BarChart = tr.ui.b.define('bar-chart', ChartBase2DBrushX); - - BarChart.prototype = { - __proto__: ChartBase2DBrushX.prototype, - - decorate: function() { - ChartBase2DBrushX.prototype.decorate.call(this); - this.classList.add('bar-chart'); - this.xCushion_ = 0; - this.isStacked_ = false; - }, - - set isStacked(stacked) { - this.isStacked_ = true; - this.updateContents_(); - }, - - get isStacked() { - return this.isStacked_; - }, - - isDatumFieldSeries_: function(fieldName) { - return fieldName != 'x'; - }, - - getXForDatum_: function(datum, index) { - return datum.x; - }, - - updateScales_: function() { - if (this.data_.length === 0) - return; - - var xDifferences = 0; - var currentX = undefined; - var previousX = undefined; - var yRange = new tr.b.Range(); - this.data_.forEach(function(datum, index) { - previousX = currentX; - currentX = this.getXForDatum_(datum, index); - if (previousX !== undefined) { - xDifferences += currentX - previousX; - } - - this.seriesKeys_.forEach(function(key) { - // Allow for sparse data - if (datum[key] !== undefined) - yRange.addValue(datum[key]); - }); - }, this); - - // X. - // Leave a cushion on the right so that the last rect doesn't - // exceed the chart boundaries. The last rect's width is set to the - // average width of the rects, which is chart.width / data.length. - var width = this.chartAreaSize.width; - this.xScale_.range([0, width]); - var domain = d3.extent(this.data_, this.getXForDatum_.bind(this)); - this.xCushion_ = xDifferences / (this.data_.length - 1); - this.xScale_.domain([domain[0], domain[1] + this.xCushion_]); - - // Y. - this.yScale_.range([this.chartAreaSize.height, 0]); - this.yScale_.domain(this.getYScaleDomain_(yRange.min, yRange.max)); - }, - - getYScaleDomain_: function(minValue, maxValue) { - if (!this.isStacked) { - return ChartBase2DBrushX.prototype.getYScaleDomain_.call( - this, minValue, maxValue); - } - - var range = new tr.b.Range(); - range.addValue(0); - this.data_.forEach(function(datum, index) { - var sum = 0; - this.seriesKeys_.forEach(function(key) { - if (datum[key] === undefined) - return; - sum += datum[key]; - }, this); - range.addValue(sum); - }, this); - return [range.min, range.max]; - }, - - getStackedRectsForDatum_: function(datum, index) { - var stacks = []; - var bottom = this.yScale_.range()[0]; - var sum = 0; - this.seriesKeys_.forEach(function(key) { - if (datum[key] === undefined) - return; - sum += datum[key]; - var heightPx = bottom - this.yScale_(sum); - bottom -= heightPx; - stacks.push({ - color: getColorOfKey(key), - heightPx: heightPx, - topPx: bottom - }); - }, this); - return stacks; - }, - - getRectsForDatum_: function(datum, index) { - if (this.isStacked) - return this.getStackedRectsForDatum_(datum, index); - - var stacks = []; - this.seriesKeys_.forEach(function(key) { - if (datum[key] === undefined) - return; - var topPx = this.yScale_(Math.max(datum[key], this.getYScaleMin_())); - stacks.push({ - topPx: topPx, - heightPx: this.yScale_.range()[0] - topPx, - color: getColorOfKey(key) - }); - }, this); - stacks.sort(function(a, b) { - return b.topPx - a.topPx; - }); - return stacks; - }, - - updateDataContents_: function(dataSel) { - dataSel.selectAll('*').remove(); - var rectsSel = dataSel.selectAll('path').data(this.seriesKeys_); - this.data_.forEach(function(datum, index) { - var currentX = this.getXForDatum_(datum, index); - var width = undefined; - if (index < (this.data_.length - 1)) { - var nextX = this.getXForDatum_(this.data_[index + 1], index + 1); - width = nextX - currentX; - } else { - width = this.xCushion_; - } - this.getRectsForDatum_(datum, index).forEach(function(rect) { - var leftPx = this.xScale_(currentX); - var rightPx = this.xScale_(currentX + width); - var widthPx = rightPx - leftPx; - rectsSel.enter() - .append('rect') - .attr('fill', rect.color) - .attr('x', leftPx) - .attr('y', rect.topPx) - .attr('width', widthPx) - .attr('height', rect.heightPx); - }, this); - }, this); - rectsSel.exit().remove(); - } - }; - - return { - BarChart: BarChart - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/bar_chart_test.html b/chromium/third_party/catapult/tracing/tracing/ui/base/bar_chart_test.html deleted file mode 100644 index 7d931d5ff1b..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/bar_chart_test.html +++ /dev/null @@ -1,230 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/base/bar_chart.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - test('instantiation_singleSeries', function() { - var chart = new tr.ui.b.BarChart(); - chart.width = 400; - chart.height = 200; - chart.chartTitle = 'Chart title'; - var data = [ - {x: 10, value: 100}, - {x: 20, value: 110}, - {x: 30, value: 100}, - {x: 40, value: 50} - ]; - chart.data = data; - this.addHTMLOutput(chart); - }); - - test('instantiation_stacked', function() { - var chart = new tr.ui.b.BarChart(); - chart.isStacked = true; - chart.width = 400; - chart.height = 200; - chart.chartTitle = 'title'; - var data = [ - {x: 10, foo: 10, bar: 5, qux: 7}, - {x: 20, foo: 11, bar: 6, qux: 3}, - {x: 30, foo: 10, bar: 4, qux: 8}, - {x: 40, foo: 5, bar: 1, qux: 2} - ]; - chart.data = data; - this.addHTMLOutput(chart); - }); - - test('instantiation_singleSeries_yLogScale', function() { - var chart = new tr.ui.b.BarChart(); - chart.isYLogScale = true; - chart.width = 400; - chart.height = 200; - chart.chartTitle = 'Chart title'; - var data = [ - {x: 10, value: 100}, - {x: 20, value: 10}, - {x: 30, value: 1}, - {x: 40, value: 0.1}, - {x: 50, value: 0.01}, - {x: 60, value: 0.001} - ]; - chart.data = data; - this.addHTMLOutput(chart); - }); - - test('undefined', function() { - var chart = new tr.ui.b.BarChart(); - assert.throws(function() { - chart.data = undefined; - }); - }); - - test('instantiation_twoSeries', function() { - var chart = new tr.ui.b.BarChart(); - - chart.width = 400; - chart.height = 200; - chart.chartTitle = 'Chart title'; - var data = [ - {x: 10, alpha: 100, beta: 50}, - {x: 20, alpha: 110, beta: 75}, - {x: 30, alpha: 100, beta: 125}, - {x: 40, alpha: 50, beta: 125} - ]; - chart.data = data; - - var r = new tr.b.Range(); - r.addValue(20); - r.addValue(40); - chart.brushedRange = r; - - this.addHTMLOutput(chart); - }); - - test('instantiation_twoSeries_yLogScale', function() { - var chart = new tr.ui.b.BarChart(); - chart.isYLogScale = true; - chart.width = 400; - chart.height = 200; - chart.chartTitle = 'Chart title'; - var data = [ - {x: 10, alpha: 100, beta: 50}, - {x: 20, alpha: 110, beta: 75}, - {x: 30, alpha: 100, beta: 125}, - {x: 40, alpha: 50, beta: 125} - ]; - chart.data = data; - - var r = new tr.b.Range(); - r.addValue(20); - r.addValue(40); - chart.brushedRange = r; - - this.addHTMLOutput(chart); - }); - - test('instantiation_twoSparseSeriesWithFirstValueSparse', function() { - var chart = new tr.ui.b.BarChart(); - - chart.width = 400; - chart.height = 200; - chart.chartTitle = 'Chart title'; - var data = [ - {x: 10, alpha: 20, beta: undefined}, - {x: 20, alpha: undefined, beta: 10}, - {x: 30, alpha: 10, beta: undefined}, - {x: 45, alpha: undefined, beta: 20}, - {x: 50, alpha: 25, beta: 30} - ]; - chart.data = data; - - this.addHTMLOutput(chart); - }); - - test('instantiation_twoSparseSeriesWithFirstValueNotSparse', function() { - var chart = new tr.ui.b.BarChart(); - - chart.width = 400; - chart.height = 200; - chart.chartTitle = 'Chart title'; - var data = [ - {x: 10, alpha: 20, beta: 40}, - {x: 20, alpha: undefined, beta: 10}, - {x: 30, alpha: 10, beta: undefined}, - {x: 45, alpha: undefined, beta: 20}, - {x: 50, alpha: 30, beta: undefined} - ]; - chart.data = data; - - this.addHTMLOutput(chart); - }); - - test('brushRangeFromIndices', function() { - var chart = new tr.ui.b.BarChart(); - var data = [ - {x: 10, value: 50}, - {x: 30, value: 60}, - {x: 70, value: 70}, - {x: 80, value: 80}, - {x: 120, value: 90} - ]; - chart.data = data; - var r = new tr.b.Range(); - - // Range min should be 10. - r = chart.computeBrushRangeFromIndices(-2, 1); - assert.equal(r.min, 10); - - // Range max should be 120. - r = chart.computeBrushRangeFromIndices(3, 10); - assert.equal(r.max, 120); - - // Range should be [10, 120] - r = chart.computeBrushRangeFromIndices(-2, 10); - assert.equal(r.min, 10); - assert.equal(r.max, 120); - - // Range should be [20, 100] - r = chart.computeBrushRangeFromIndices(1, 3); - assert.equal(r.min, 20); - assert.equal(r.max, 100); - }); - - test('instantiation_interactiveBrushing', function() { - var chart = new tr.ui.b.BarChart(); - chart.width = 400; - chart.height = 200; - chart.chartTitle = 'Chart title'; - var data = [ - {x: 10, value: 50}, - {x: 20, value: 60}, - {x: 30, value: 80}, - {x: 40, value: 20}, - {x: 50, value: 30}, - {x: 60, value: 20}, - {x: 70, value: 15}, - {x: 80, value: 20} - ]; - chart.data = data; - - var mouseDownX = undefined; - var curMouseX = undefined; - - function updateBrushedRange() { - if (mouseDownX === undefined || (mouseDownX === curMouseX)) { - chart.brushedRange = new tr.b.Range(); - return; - } - var r = new tr.b.Range(); - r.min = Math.min(mouseDownX, curMouseX); - r.max = Math.max(mouseDownX, curMouseX); - chart.brushedRange = r; - } - - chart.addEventListener('item-mousedown', function(e) { - mouseDownX = e.x; - curMouseX = e.x; - updateBrushedRange(); - }); - chart.addEventListener('item-mousemove', function(e) { - if (e.button == undefined) - return; - curMouseX = e.x; - updateBrushedRange(); - }); - chart.addEventListener('item-mouseup', function(e) { - curMouseX = e.x; - updateBrushedRange(); - }); - this.addHTMLOutput(chart); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/camera.html b/chromium/third_party/catapult/tracing/tracing/ui/base/camera.html deleted file mode 100644 index 2cef0b9f394..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/camera.html +++ /dev/null @@ -1,349 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/settings.html"> -<link rel="import" href="/tracing/ui/base/utils.html"> -<link rel="import" href="/tracing/ui/base/ui.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.b', function() { - - var constants = { - DEFAULT_SCALE: 0.5, - DEFAULT_EYE_DISTANCE: 10000, - MINIMUM_DISTANCE: 1000, - MAXIMUM_DISTANCE: 100000, - FOV: 15, - RESCALE_TIMEOUT_MS: 200, - MAXIMUM_TILT: 80, - SETTINGS_NAMESPACE: 'tr.ui_camera' - }; - - - var Camera = tr.ui.b.define('camera'); - - Camera.prototype = { - __proto__: HTMLUnknownElement.prototype, - - decorate: function(eventSource) { - this.eventSource_ = eventSource; - - this.eventSource_.addEventListener('beginpan', - this.onPanBegin_.bind(this)); - this.eventSource_.addEventListener('updatepan', - this.onPanUpdate_.bind(this)); - this.eventSource_.addEventListener('endpan', - this.onPanEnd_.bind(this)); - - this.eventSource_.addEventListener('beginzoom', - this.onZoomBegin_.bind(this)); - this.eventSource_.addEventListener('updatezoom', - this.onZoomUpdate_.bind(this)); - this.eventSource_.addEventListener('endzoom', - this.onZoomEnd_.bind(this)); - - this.eventSource_.addEventListener('beginrotate', - this.onRotateBegin_.bind(this)); - this.eventSource_.addEventListener('updaterotate', - this.onRotateUpdate_.bind(this)); - this.eventSource_.addEventListener('endrotate', - this.onRotateEnd_.bind(this)); - - this.eye_ = [0, 0, constants.DEFAULT_EYE_DISTANCE]; - this.gazeTarget_ = [0, 0, 0]; - this.rotation_ = [0, 0]; - - this.pixelRatio_ = window.devicePixelRatio || 1; - }, - - - get modelViewMatrix() { - var mvMatrix = mat4.create(); - - mat4.lookAt(mvMatrix, this.eye_, this.gazeTarget_, [0, 1, 0]); - return mvMatrix; - }, - - get projectionMatrix() { - var rect = - tr.ui.b.windowRectForElement(this.canvas_). - scaleSize(this.pixelRatio_); - - var aspectRatio = rect.width / rect.height; - var matrix = mat4.create(); - mat4.perspective( - matrix, tr.b.deg2rad(constants.FOV), aspectRatio, 1, 100000); - - return matrix; - }, - - set canvas(c) { - this.canvas_ = c; - }, - - set deviceRect(rect) { - this.deviceRect_ = rect; - }, - - get stackingDistanceDampening() { - var gazeVector = [ - this.gazeTarget_[0] - this.eye_[0], - this.gazeTarget_[1] - this.eye_[1], - this.gazeTarget_[2] - this.eye_[2]]; - vec3.normalize(gazeVector, gazeVector); - return 1 + gazeVector[2]; - }, - - loadCameraFromSettings: function(settings) { - this.eye_ = settings.get( - 'eye', this.eye_, constants.SETTINGS_NAMESPACE); - this.gazeTarget_ = settings.get( - 'gaze_target', this.gazeTarget_, constants.SETTINGS_NAMESPACE); - this.rotation_ = settings.get( - 'rotation', this.rotation_, constants.SETTINGS_NAMESPACE); - - this.dispatchRenderEvent_(); - }, - - saveCameraToSettings: function(settings) { - settings.set( - 'eye', this.eye_, constants.SETTINGS_NAMESPACE); - settings.set( - 'gaze_target', this.gazeTarget_, constants.SETTINGS_NAMESPACE); - settings.set( - 'rotation', this.rotation_, constants.SETTINGS_NAMESPACE); - }, - - resetCamera: function() { - this.eye_ = [0, 0, constants.DEFAULT_EYE_DISTANCE]; - this.gazeTarget_ = [0, 0, 0]; - this.rotation_ = [0, 0]; - - var settings = tr.b.SessionSettings(); - var keys = settings.keys(constants.SETTINGS_NAMESPACE); - if (keys.length !== 0) { - this.loadCameraFromSettings(settings); - return; - } - - if (this.deviceRect_) { - var rect = tr.ui.b.windowRectForElement(this.canvas_). - scaleSize(this.pixelRatio_); - - this.eye_[0] = this.deviceRect_.width / 2; - this.eye_[1] = this.deviceRect_.height / 2; - - this.gazeTarget_[0] = this.deviceRect_.width / 2; - this.gazeTarget_[1] = this.deviceRect_.height / 2; - } - - this.saveCameraToSettings(settings); - this.dispatchRenderEvent_(); - }, - - updatePanByDelta: function(delta) { - var rect = - tr.ui.b.windowRectForElement(this.canvas_). - scaleSize(this.pixelRatio_); - - // Get the eye vector, since we'll be adjusting gazeTarget. - var eyeVector = [ - this.eye_[0] - this.gazeTarget_[0], - this.eye_[1] - this.gazeTarget_[1], - this.eye_[2] - this.gazeTarget_[2]]; - var length = vec3.length(eyeVector); - vec3.normalize(eyeVector, eyeVector); - - var halfFov = constants.FOV / 2; - var multiplier = - 2.0 * length * Math.tan(tr.b.deg2rad(halfFov)) / rect.height; - - // Get the up and right vectors. - var up = [0, 1, 0]; - var rotMatrix = mat4.create(); - mat4.rotate( - rotMatrix, rotMatrix, tr.b.deg2rad(this.rotation_[1]), [0, 1, 0]); - mat4.rotate( - rotMatrix, rotMatrix, tr.b.deg2rad(this.rotation_[0]), [1, 0, 0]); - vec3.transformMat4(up, up, rotMatrix); - - var right = [0, 0, 0]; - vec3.cross(right, eyeVector, up); - vec3.normalize(right, right); - - // Update the gaze target. - for (var i = 0; i < 3; ++i) { - this.gazeTarget_[i] += - delta[0] * multiplier * right[i] - delta[1] * multiplier * up[i]; - - this.eye_[i] = this.gazeTarget_[i] + length * eyeVector[i]; - } - - // If we have some z offset, we need to reposition gazeTarget - // to be on the plane z = 0 with normal [0, 0, 1]. - if (Math.abs(this.gazeTarget_[2]) > 1e-6) { - var gazeVector = [-eyeVector[0], -eyeVector[1], -eyeVector[2]]; - var newLength = tr.b.clamp( - -this.eye_[2] / gazeVector[2], - constants.MINIMUM_DISTANCE, - constants.MAXIMUM_DISTANCE); - - for (var i = 0; i < 3; ++i) - this.gazeTarget_[i] = this.eye_[i] + newLength * gazeVector[i]; - } - - this.saveCameraToSettings(tr.b.SessionSettings()); - this.dispatchRenderEvent_(); - }, - - updateZoomByDelta: function(delta) { - var deltaY = delta[1]; - deltaY = tr.b.clamp(deltaY, -50, 50); - var scale = 1.0 - deltaY / 100.0; - - var eyeVector = [0, 0, 0]; - vec3.subtract(eyeVector, this.eye_, this.gazeTarget_); - - var length = vec3.length(eyeVector); - - // Clamp the length to allowed values by changing the scale. - if (length * scale < constants.MINIMUM_DISTANCE) - scale = constants.MINIMUM_DISTANCE / length; - else if (length * scale > constants.MAXIMUM_DISTANCE) - scale = constants.MAXIMUM_DISTANCE / length; - - vec3.scale(eyeVector, eyeVector, scale); - vec3.add(this.eye_, this.gazeTarget_, eyeVector); - - this.saveCameraToSettings(tr.b.SessionSettings()); - this.dispatchRenderEvent_(); - }, - - updateRotateByDelta: function(delta) { - delta[0] *= 0.5; - delta[1] *= 0.5; - - if (Math.abs(this.rotation_[0] + delta[1]) > constants.MAXIMUM_TILT) - return; - if (Math.abs(this.rotation_[1] - delta[0]) > constants.MAXIMUM_TILT) - return; - - var eyeVector = [0, 0, 0, 0]; - vec3.subtract(eyeVector, this.eye_, this.gazeTarget_); - - // Undo the current rotation. - var rotMatrix = mat4.create(); - mat4.rotate( - rotMatrix, rotMatrix, -tr.b.deg2rad(this.rotation_[0]), [1, 0, 0]); - mat4.rotate( - rotMatrix, rotMatrix, -tr.b.deg2rad(this.rotation_[1]), [0, 1, 0]); - vec4.transformMat4(eyeVector, eyeVector, rotMatrix); - - // Update rotation values. - this.rotation_[0] += delta[1]; - this.rotation_[1] -= delta[0]; - - // Redo the new rotation. - mat4.identity(rotMatrix); - mat4.rotate( - rotMatrix, rotMatrix, tr.b.deg2rad(this.rotation_[1]), [0, 1, 0]); - mat4.rotate( - rotMatrix, rotMatrix, tr.b.deg2rad(this.rotation_[0]), [1, 0, 0]); - vec4.transformMat4(eyeVector, eyeVector, rotMatrix); - - vec3.add(this.eye_, this.gazeTarget_, eyeVector); - - this.saveCameraToSettings(tr.b.SessionSettings()); - this.dispatchRenderEvent_(); - }, - - - // Event callbacks. - onPanBegin_: function(e) { - this.panning_ = true; - this.lastMousePosition_ = this.getMousePosition_(e); - }, - - onPanUpdate_: function(e) { - if (!this.panning_) - return; - - var delta = this.getMouseDelta_(e, this.lastMousePosition_); - this.lastMousePosition_ = this.getMousePosition_(e); - this.updatePanByDelta(delta); - }, - - onPanEnd_: function(e) { - this.panning_ = false; - }, - - onZoomBegin_: function(e) { - this.zooming_ = true; - - var p = this.getMousePosition_(e); - - this.lastMousePosition_ = p; - this.zoomPoint_ = p; - }, - - onZoomUpdate_: function(e) { - if (!this.zooming_) - return; - - var delta = this.getMouseDelta_(e, this.lastMousePosition_); - this.lastMousePosition_ = this.getMousePosition_(e); - this.updateZoomByDelta(delta); - }, - - onZoomEnd_: function(e) { - this.zooming_ = false; - this.zoomPoint_ = undefined; - }, - - onRotateBegin_: function(e) { - this.rotating_ = true; - this.lastMousePosition_ = this.getMousePosition_(e); - }, - - onRotateUpdate_: function(e) { - if (!this.rotating_) - return; - - var delta = this.getMouseDelta_(e, this.lastMousePosition_); - this.lastMousePosition_ = this.getMousePosition_(e); - this.updateRotateByDelta(delta); - }, - - onRotateEnd_: function(e) { - this.rotating_ = false; - }, - - - // Misc helper functions. - getMousePosition_: function(e) { - var rect = tr.ui.b.windowRectForElement(this.canvas_); - return [(e.clientX - rect.x) * this.pixelRatio_, - (e.clientY - rect.y) * this.pixelRatio_]; - }, - - getMouseDelta_: function(e, p) { - var newP = this.getMousePosition_(e); - return [newP[0] - p[0], newP[1] - p[1]]; - }, - - dispatchRenderEvent_: function() { - tr.b.dispatchSimpleEvent(this, 'renderrequired', false, false); - } - }; - - return { - Camera: Camera - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/camera_test.html b/chromium/third_party/catapult/tracing/tracing/ui/base/camera_test.html deleted file mode 100644 index 8a11663eeda..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/camera_test.html +++ /dev/null @@ -1,60 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> -<link rel="import" href="/tracing/base/rect.html"> -<link rel="import" href="/tracing/base/quad.html"> -<link rel="import" href="/tracing/base/bbox2.html"> -<link rel="import" href="/tracing/ui/base/quad_stack_view.html"> -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - - function createQuads() { - var quads = [ - tr.b.Quad.fromXYWH(-500, -500, 30, 30), // 4 corners - tr.b.Quad.fromXYWH(-500, 470, 30, 30), - tr.b.Quad.fromXYWH(470, -500, 30, 30), - tr.b.Quad.fromXYWH(470, 470, 30, 30), - tr.b.Quad.fromXYWH(-250, -250, 250, 250), // crosshairs - tr.b.Quad.fromXYWH(0, -250, 250, 250), // crosshairs - tr.b.Quad.fromXYWH(-250, 0, 250, 250), // crosshairs - tr.b.Quad.fromXYWH(0, 0, 250, 250) // crosshairs - ]; - quads[0].stackingGroupId = 0; - quads[1].stackingGroupId = 0; - quads[2].stackingGroupId = 0; - quads[3].stackingGroupId = 0; - quads[4].stackingGroupId = 1; - quads[5].stackingGroupId = 1; - quads[6].stackingGroupId = 1; - quads[7].stackingGroupId = 1; - return quads; - } - - function createQuadStackView(testFramework) { - var quads = createQuads(); - var view = new tr.ui.b.QuadStackView(); - // simulate the constraints of the layer-tree-view - view.style.height = '400px'; - view.style.width = '800px'; - view.deviceRect = tr.b.Rect.fromXYWH(-250, -250, 500, 500); - view.quads = quads; - - testFramework.addHTMLOutput(view); - return view; - } - - test('initialState', function() { - var view = createQuadStackView(this); - - var viewRect = - view.getBoundingClientRect(); - assert.equal(viewRect.height, 400); - assert.equal(viewRect.width, 800); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/chart_base.html b/chromium/third_party/catapult/tracing/tracing/ui/base/chart_base.html deleted file mode 100644 index 5155376058a..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/chart_base.html +++ /dev/null @@ -1,277 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/color_scheme.html"> -<link rel="import" href="/tracing/ui/base/d3.html"> -<link rel="import" href="/tracing/ui/base/ui.html"> - -<style> - * /deep/ .chart-base #title { - font-size: 16pt; - } - - * /deep/ .chart-base { - font-size: 12pt; - -webkit-user-select: none; - cursor: default; - } - - * /deep/ .chart-base .axis path, - * /deep/ .chart-base .axis line { - fill: none; - shape-rendering: crispEdges; - stroke: #000; - } -</style> - -<template id="chart-base-template"> - <svg> <!-- svg tag is dropped by ChartBase.decorate. --> - <g xmlns="http://www.w3.org/2000/svg" id="chart-area"> - <g class="x axis"></g> - <g class="y axis"></g> - <text id="title"></text> - </g> - </svg> -</template> - -<script> -'use strict'; - -tr.exportTo('tr.ui.b', function() { - var THIS_DOC = document.currentScript.ownerDocument; - - var svgNS = 'http://www.w3.org/2000/svg'; - var ColorScheme = tr.b.ColorScheme; - - function getColorOfKey(key, selected) { - var id = ColorScheme.getColorIdForGeneralPurposeString(key); - if (selected) - id += ColorScheme.properties.brightenedOffsets[0]; - return ColorScheme.colorsAsStrings[id]; - } - - /** - * A virtual base class for basic charts that provides X and Y axes, if - * needed, a title, and legend. - * - * @constructor - */ - var ChartBase = tr.ui.b.define('svg', undefined, svgNS); - - ChartBase.prototype = { - __proto__: HTMLUnknownElement.prototype, - - decorate: function() { - this.classList.add('chart-base'); - this.chartTitle_ = undefined; - this.seriesKeys_ = undefined; - this.width_ = 400; - this.height_ = 300; - - // This should use tr.ui.b.instantiateTemplate. However, creating - // svg-namespaced elements inside a template isn't possible. Thus, this - // hack. - var template = THIS_DOC.querySelector('#chart-base-template'); - var svgEl = template.content.querySelector('svg'); - for (var i = 0; i < svgEl.children.length; i++) - this.appendChild(svgEl.children[i].cloneNode(true)); - - // svg likes to take over width & height properties for some reason. This - // works around it. - Object.defineProperty( - this, 'width', { - get: function() { - return this.width_; - }, - set: function(width) { - this.width_ = width; - this.updateContents_(); - } - }); - Object.defineProperty( - this, 'height', { - get: function() { - return this.height_; - }, - set: function(height) { - this.height_ = height; - this.updateContents_(); - } - }); - }, - - get chartTitle() { - return this.chartTitle_; - }, - - set chartTitle(chartTitle) { - this.chartTitle_ = chartTitle; - this.updateContents_(); - }, - - get chartAreaElement() { - return this.querySelector('#chart-area'); - }, - - setSize: function(size) { - this.width_ = size.width; - this.height_ = size.height; - this.updateContents_(); - }, - - getMargin_: function() { - var margin = {top: 20, right: 20, bottom: 30, left: 50}; - if (this.chartTitle_) - margin.top += 20; - return margin; - }, - - get margin() { - return this.getMargin_(); - }, - - get chartAreaSize() { - var margin = this.margin; - return { - width: this.width_ - margin.left - margin.right, - height: this.height_ - margin.top - margin.bottom - }; - }, - - getLegendKeys_: function() { - throw new Error('Not implemented'); - }, - - updateScales_: function() { - throw new Error('Not implemented'); - }, - - updateContents_: function() { - var margin = this.margin; - - var thisSel = d3.select(this); - thisSel.attr('width', this.width_); - thisSel.attr('height', this.height_); - - var chartAreaSel = d3.select(this.chartAreaElement); - chartAreaSel.attr('transform', - 'translate(' + margin.left + ',' + margin.top + ')'); - - this.updateScales_(); - this.updateTitle_(chartAreaSel); - this.updateLegend_(); - }, - - updateTitle_: function(chartAreaSel) { - var titleSel = chartAreaSel.select('#title'); - if (!this.chartTitle_) { - titleSel.style('display', 'none'); - return; - } - var width = this.chartAreaSize.width; - titleSel.attr('transform', 'translate(' + width * 0.5 + ',-5)') - .style('display', undefined) - .style('text-anchor', 'middle') - .attr('class', 'title') - .attr('width', width) - .text(this.chartTitle_); - }, - - // TODO(charliea): We should change updateLegend_ so that it ellipsizes the - // series names after a certain point. Otherwise, the series names start - // dipping below the x-axis and continue on outside of the viewport. - updateLegend_: function() { - var keys = this.getLegendKeys_(); - if (keys === undefined) - return; - - var chartAreaSel = d3.select(this.chartAreaElement); - var chartAreaSize = this.chartAreaSize; - - var legendEntriesSel = chartAreaSel.selectAll('.legend') - .data(keys.slice().reverse()); - - legendEntriesSel.enter() - .append('g') - .attr('class', 'legend') - .attr('transform', function(d, i) { - return 'translate(0,' + i * 20 + ')'; - }) - .append('text').text(function(key) { - return key; - }); - legendEntriesSel.exit().remove(); - - legendEntriesSel.attr('x', chartAreaSize.width - 18) - .attr('width', 18) - .attr('height', 18) - .style('fill', function(key) { - var selected = this.currentHighlightedLegendKey === key; - return getColorOfKey(key, selected); - }.bind(this)); - - legendEntriesSel.selectAll('text') - .attr('x', chartAreaSize.width - 24) - .attr('y', 9) - .attr('dy', '.35em') - .style('text-anchor', 'end') - .text(function(d) { return d; }); - }, - - get highlightedLegendKey() { - return this.highlightedLegendKey_; - }, - - set highlightedLegendKey(highlightedLegendKey) { - this.highlightedLegendKey_ = highlightedLegendKey; - this.updateHighlight_(); - }, - - get currentHighlightedLegendKey() { - if (this.tempHighlightedLegendKey_) - return this.tempHighlightedLegendKey_; - return this.highlightedLegendKey_; - }, - - pushTempHighlightedLegendKey: function(key) { - if (this.tempHighlightedLegendKey_) - throw new Error('push cannot nest'); - this.tempHighlightedLegendKey_ = key; - this.updateHighlight_(); - }, - - popTempHighlightedLegendKey: function(key) { - if (this.tempHighlightedLegendKey_ != key) - throw new Error('pop cannot happen'); - this.tempHighlightedLegendKey_ = undefined; - this.updateHighlight_(); - }, - - updateHighlight_: function() { - // Update label colors. - var chartAreaSel = d3.select(this.chartAreaElement); - var legendEntriesSel = chartAreaSel.selectAll('.legend'); - - var that = this; - legendEntriesSel.each(function(key) { - var highlighted = key == that.currentHighlightedLegendKey; - var color = getColorOfKey(key, highlighted); - this.style.fill = color; - if (highlighted) - this.style.fontWeight = 'bold'; - else - this.style.fontWeight = ''; - }); - } - }; - - return { - getColorOfKey: getColorOfKey, - ChartBase: ChartBase - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/chart_base_2d.html b/chromium/third_party/catapult/tracing/tracing/ui/base/chart_base_2d.html deleted file mode 100644 index 84cd5019157..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/chart_base_2d.html +++ /dev/null @@ -1,384 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/iteration_helpers.html"> -<link rel="import" href="/tracing/base/range.html"> -<link rel="import" href="/tracing/ui/base/chart_base.html"> -<link rel="import" href="/tracing/ui/base/mouse_tracker.html"> - -<style> - * /deep/ .chart-base-2d.updating-brushing-state #brushes > * { - fill: rgb(103, 199, 165) - } - - * /deep/ .chart-base-2d #brushes { - fill: rgb(213, 236, 229) - } -</style> - -<script> -'use strict'; - -tr.exportTo('tr.ui.b', function() { - var ChartBase = tr.ui.b.ChartBase; - var ChartBase2D = tr.ui.b.define('chart-base-2d', ChartBase); - - ChartBase2D.prototype = { - __proto__: ChartBase.prototype, - - decorate: function() { - ChartBase.prototype.decorate.call(this); - this.classList.add('chart-base-2d'); - this.xScale_ = d3.scale.linear(); - this.yScale_ = d3.scale.linear(); - this.isYLogScale_ = false; - this.yLogScaleMin_ = undefined; - this.dataRange_ = new tr.b.Range(); - - this.data_ = []; - this.seriesKeys_ = []; - this.leftMargin_ = 50; - - d3.select(this.chartAreaElement) - .append('g') - .attr('id', 'brushes'); - d3.select(this.chartAreaElement) - .append('g') - .attr('id', 'series'); - - this.addEventListener('mousedown', this.onMouseDown_.bind(this)); - }, - - get data() { - return this.data_; - }, - - /** - * Sets the data array for the object - * - * @param {Array} data The data. Each element must be an object, with at - * least an x property. All other properties become series names in the - * chart. The data can be sparse (i.e. every x value does not have to - * contain data for every series). - */ - set data(data) { - if (data === undefined) - throw new Error('data must be an Array'); - - this.data_ = data; - this.updateSeriesKeys_(); - this.updateDataRange_(); - this.updateContents_(); - }, - - set isYLogScale(logScale) { - if (logScale) - this.yScale_ = d3.scale.log(10); - else - this.yScale_ = d3.scale.linear(); - this.isYLogScale_ = logScale; - }, - - getYScaleMin_: function() { - return this.isYLogScale_ ? this.yLogScaleMin_ : 0; - }, - - getYScaleDomain_: function(minValue, maxValue) { - if (this.isYLogScale_) - return [this.getYScaleMin_(), maxValue]; - return [Math.min(minValue, this.getYScaleMin_()), maxValue]; - }, - - getSampleWidth_: function(data, index, leftSide) { - var leftIndex, rightIndex; - if (leftSide) { - leftIndex = Math.max(index - 1, 0); - rightIndex = index; - } else { - leftIndex = index; - rightIndex = Math.min(index + 1, data.length - 1); - } - var leftWidth = this.getXForDatum_(data[index], index) - - this.getXForDatum_(data[leftIndex], leftIndex); - var rightWidth = this.getXForDatum_(data[rightIndex], rightIndex) - - this.getXForDatum_(data[index], index); - return leftWidth * 0.5 + rightWidth * 0.5; - }, - - getLegendKeys_: function() { - if (this.seriesKeys_ && - this.seriesKeys_.length > 1) - return this.seriesKeys_.slice(); - return []; - }, - - updateSeriesKeys_: function() { - // Accumulate the keys on each data point. - var keySet = {}; - this.data_.forEach(function(datum) { - Object.keys(datum).forEach(function(key) { - if (this.isDatumFieldSeries_(key)) - keySet[key] = true; - }, this); - }, this); - this.seriesKeys_ = Object.keys(keySet); - }, - - isDatumFieldSeries_: function(fieldName) { - throw new Error('Not implemented'); - }, - - getXForDatum_: function(datum, index) { - throw new Error('Not implemented'); - }, - - updateScales_: function() { - if (this.data_.length === 0) - return; - - var width = this.chartAreaSize.width; - var height = this.chartAreaSize.height; - - // X. - this.xScale_.range([0, width]); - this.xScale_.domain(d3.extent(this.data_, this.getXForDatum_.bind(this))); - - // Y. - var yRange = new tr.b.Range(); - var keySet = new Set(this.seriesKeys_); - for (var i = 0; i < this.data_.length; i++) - for (var key in this.data_[i]) - if (keySet.has(key)) - yRange.addValue(this.data_[i][key]); - - this.yScale_.range([height, 0]); - this.yScale_.domain([yRange.min, yRange.max]); - }, - - updateBrushContents_: function(brushSel) { - brushSel.selectAll('*').remove(); - }, - - updateXAxis_: function(xAxis) { - xAxis.selectAll('*').remove(); - xAxis[0][0].style.opacity = 0; - xAxis.attr('transform', 'translate(0,' + this.chartAreaSize.height + ')') - .call(d3.svg.axis() - .scale(this.xScale_) - .orient('bottom')); - window.requestAnimationFrame(function() { - var previousRight = undefined; - xAxis.selectAll('.tick')[0].forEach(function(tick) { - var currentLeft = tick.transform.baseVal[0].matrix.e; - if ((previousRight === undefined) || - (currentLeft > (previousRight + 3))) { - var currentWidth = tick.getBBox().width; - previousRight = currentLeft + currentWidth; - } else { - tick.style.opacity = 0; - } - }); - xAxis[0][0].style.opacity = 1; - }); - }, - - getMargin_: function() { - var margin = ChartBase.prototype.getMargin_.call(this); - margin.left = this.leftMargin_; - return margin; - }, - - updateDataRange_: function() { - var dataBySeriesKey = this.getDataBySeriesKey_(); - this.dataRange_.reset(); - tr.b.iterItems(dataBySeriesKey, function(series, values) { - for (var i = 0; i < values.length; i++) { - this.dataRange_.addValue(values[i][series]); - } - }, this); - - // Choose the closest power of 10, rounded down, as the smallest tick - // to display. - this.yLogScaleMin_ = undefined; - if (this.dataRange_.min !== undefined) { - var minValue = this.dataRange_.min; - if (minValue == 0) - minValue = 1; - - var onePowerLess = Math.floor( - Math.log(minValue) / Math.log(10)) - 1; - this.yLogScaleMin_ = Math.pow(10, onePowerLess); - } - }, - - updateYAxis_: function(yAxis) { - yAxis.selectAll('*').remove(); - yAxis[0][0].style.opacity = 0; - - var axisModifier = d3.svg.axis() - .scale(this.yScale_) - .orient('left'); - - if (this.isYLogScale_) { - if (this.yLogScaleMin_ === undefined) - return; - var minValue = this.dataRange_.min; - if (minValue == 0) - minValue = 1; - - var largestPower = Math.ceil( - Math.log(this.dataRange_.max) / Math.log(10)) + 1; - var smallestPower = Math.floor( - Math.log(minValue) / Math.log(10)); - var tickValues = []; - for (var i = smallestPower; i < largestPower; i++) { - tickValues.push(Math.pow(10, i)); - } - - axisModifier = axisModifier - .tickValues(tickValues) - .tickFormat(function(d) { - return d; - }); - } - - yAxis.call(axisModifier); - - window.requestAnimationFrame(function() { - var previousTop = undefined; - var leftMargin = 0; - yAxis.selectAll('.tick')[0].forEach(function(tick) { - var bbox = tick.getBBox(); - leftMargin = Math.max(leftMargin, bbox.width); - var currentTop = tick.transform.baseVal[0].matrix.f; - var currentBottom = currentTop + bbox.height; - if ((previousTop === undefined) || - (previousTop > (currentBottom + 3))) { - previousTop = currentTop; - } else { - tick.style.opacity = 0; - } - }); - if (leftMargin > this.leftMargin_) { - this.leftMargin_ = leftMargin; - this.updateContents_(); - } else { - yAxis[0][0].style.opacity = 1; - } - }.bind(this)); - }, - - updateContents_: function() { - ChartBase.prototype.updateContents_.call(this); - var chartAreaSel = d3.select(this.chartAreaElement); - this.updateXAxis_(chartAreaSel.select('.x.axis')); - this.updateYAxis_(chartAreaSel.select('.y.axis')); - this.updateBrushContents_(chartAreaSel.select('#brushes')); - this.updateDataContents_(chartAreaSel.select('#series')); - }, - - updateDataContents_: function(seriesSel) { - throw new Error('Not implemented'); - }, - - /** - * Returns a map of series key to the data for that series. - * - * Example: - * // returns {y: [{x: 1, y: 1}, {x: 3, y: 3}], z: [{x: 2, z: 2}]} - * this.data_ = [{x: 1, y: 1}, {x: 2, z: 2}, {x: 3, y: 3}]; - * this.getDataBySeriesKey_(); - * @return {Object} A map of series data by series key. - */ - getDataBySeriesKey_: function() { - var dataBySeriesKey = {}; - this.seriesKeys_.forEach(function(seriesKey) { - dataBySeriesKey[seriesKey] = []; - }); - - this.data_.forEach(function(multiSeriesDatum, index) { - var x = this.getXForDatum_(multiSeriesDatum, index); - - d3.keys(multiSeriesDatum).forEach(function(seriesKey) { - // Skip 'x' - it's not a series - if (seriesKey === 'x') - return; - - if (multiSeriesDatum[seriesKey] === undefined) - return; - - if (!this.isDatumFieldSeries_(seriesKey)) - return; - - var singleSeriesDatum = {x: x}; - singleSeriesDatum[seriesKey] = multiSeriesDatum[seriesKey]; - dataBySeriesKey[seriesKey].push(singleSeriesDatum); - }, this); - }, this); - - return dataBySeriesKey; - }, - - getDataPointAtClientPoint_: function(clientX, clientY) { - var rect = this.getBoundingClientRect(); - var margin = this.margin; - var x = clientX - rect.left - margin.left; - var y = clientY - rect.top - margin.top; - x = this.xScale_.invert(x); - y = this.yScale_.invert(y); - x = tr.b.clamp(x, this.xScale_.domain()[0], this.xScale_.domain()[1]); - y = tr.b.clamp(y, this.yScale_.domain()[0], this.yScale_.domain()[1]); - return {x: x, y: y}; - }, - - prepareDataEvent_: function(mouseEvent, dataEvent) { - var dataPoint = this.getDataPointAtClientPoint_( - mouseEvent.clientX, mouseEvent.clientY); - dataEvent.x = dataPoint.x; - dataEvent.y = dataPoint.y; - }, - - onMouseDown_: function(mouseEvent) { - tr.ui.b.trackMouseMovesUntilMouseUp( - this.onMouseMove_.bind(this, mouseEvent.button), - this.onMouseUp_.bind(this, mouseEvent.button)); - mouseEvent.preventDefault(); - mouseEvent.stopPropagation(); - var dataEvent = new tr.b.Event('item-mousedown'); - dataEvent.button = mouseEvent.button; - this.classList.add('updating-brushing-state'); - this.prepareDataEvent_(mouseEvent, dataEvent); - this.dispatchEvent(dataEvent); - }, - - onMouseMove_: function(button, mouseEvent) { - if (mouseEvent.buttons !== undefined) { - mouseEvent.preventDefault(); - mouseEvent.stopPropagation(); - } - var dataEvent = new tr.b.Event('item-mousemove'); - dataEvent.button = button; - this.prepareDataEvent_(mouseEvent, dataEvent); - this.dispatchEvent(dataEvent); - }, - - onMouseUp_: function(button, mouseEvent) { - mouseEvent.preventDefault(); - mouseEvent.stopPropagation(); - var dataEvent = new tr.b.Event('item-mouseup'); - dataEvent.button = button; - this.prepareDataEvent_(mouseEvent, dataEvent); - this.dispatchEvent(dataEvent); - this.classList.remove('updating-brushing-state'); - } - }; - - return { - ChartBase2D: ChartBase2D - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/chart_base_2d_brushable_x.html b/chromium/third_party/catapult/tracing/tracing/ui/base/chart_base_2d_brushable_x.html deleted file mode 100644 index 4cde4b58bdd..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/chart_base_2d_brushable_x.html +++ /dev/null @@ -1,84 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/base/chart_base_2d.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.b', function() { - var ChartBase2D = tr.ui.b.ChartBase2D; - var ChartBase2DBrushX = tr.ui.b.define('chart-base-2d-brush-1d', ChartBase2D); - - ChartBase2DBrushX.prototype = { - __proto__: ChartBase2D.prototype, - - decorate: function() { - ChartBase2D.prototype.decorate.call(this); - this.brushedRange_ = new tr.b.Range(); - }, - - // Note: range can only be set, not retrieved. It needs to be immutable - // or else odd data binding effects will result. - set brushedRange(range) { - this.brushedRange_.reset(); - this.brushedRange_.addRange(range); - this.updateContents_(); - }, - - computeBrushRangeFromIndices: function(indexA, indexB) { - indexA = tr.b.clamp(indexA, 0, this.data_.length - 1); - indexB = tr.b.clamp(indexB, 0, this.data_.length - 1); - var leftIndex = Math.min(indexA, indexB); - var rightIndex = Math.max(indexA, indexB); - - var r = new tr.b.Range(); - r.addValue(this.getXForDatum_(this.data_[leftIndex], leftIndex) - - this.getSampleWidth_(this.data_, leftIndex, true)); - r.addValue(this.getXForDatum_(this.data_[rightIndex], rightIndex) + - this.getSampleWidth_(this.data_, rightIndex, false)); - return r; - }, - - getDataIndex_: function(dataX) { - if (!this.data_) - return undefined; - var bisect = d3.bisector(this.getXForDatum_.bind(this)).right; - return bisect(this.data_, dataX) - 1; - }, - - prepareDataEvent_: function(mouseEvent, dataEvent) { - ChartBase2D.prototype.prepareDataEvent_.call( - this, mouseEvent, dataEvent); - dataEvent.index = this.getDataIndex_(dataEvent.x); - if (dataEvent.index !== undefined) - dataEvent.data = this.data_[dataEvent.index]; - }, - - updateBrushContents_: function(brushSel) { - brushSel.selectAll('*').remove(); - var brushes = this.brushedRange_.isEmpty ? [] : [this.brushedRange_]; - var brushRectsSel = brushSel.selectAll('rect').data(brushes); - brushRectsSel.enter().append('rect'); - brushRectsSel.exit().remove(); - brushRectsSel - .attr('x', function(d) { - return this.xScale_(d.min); - }.bind(this)) - .attr('y', 0) - .attr('width', function(d) { - return this.xScale_(d.max) - this.xScale_(d.min); - }.bind(this)) - .attr('height', this.chartAreaSize.height); - } - }; - - return { - ChartBase2DBrushX: ChartBase2DBrushX - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/checkbox.html b/chromium/third_party/catapult/tracing/tracing/ui/base/checkbox.html deleted file mode 100644 index 9de49183853..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/checkbox.html +++ /dev/null @@ -1,107 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2016 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/settings.html"> -<link rel="import" href="/tracing/ui/base/dom_helpers.html"> -<link rel="import" href="/tracing/ui/base/ui.html"> - -<polymer-element name='tr-ui-b-checkbox'> - <template> - <style> - .inline { - display: inline-block; - } - </style> - - <input type="checkbox" id="checkbox" class="inline"/> - <div id="label" class="inline"></div> - </template> - - <script> - 'use strict'; - - Polymer({ - created: function() { - this.needsInit_ = true; - this.defaultCheckedValue_ = undefined; - this.settingsKey_ = undefined; - this.label_ = undefined; - this.checked_ = false; - this.is_ready_ = false; - }, - - ready: function() { - this.is_ready_ = true; - this.$.checkbox.addEventListener('click', function() { - this.checked = this.$.checkbox.checked; - }.bind(this)); - this.maybeUpdateElements_(); - }, - - maybeUpdateElements_: function() { - if (!this.is_ready_) - return; - this.$.label.innerText = this.label_; - this.$.checkbox.checked = this.checked_; - }, - - get defaultCheckedValue() { - return this.defaultCheckedValue_; - }, - - set defaultCheckedValue(defaultCheckedValue) { - if (!this.needsInit_) - throw new Error('Already initialized.'); - this.defaultCheckedValue_ = defaultCheckedValue; - this.maybeInit_(); - }, - - get settingsKey() { - return this.settingsKey_; - }, - - set settingsKey(settingsKey) { - if (!this.needsInit_) - throw new Error('Already initialized.'); - this.settingsKey_ = settingsKey; - this.maybeInit_(); - }, - - maybeInit_: function() { - if (!this.needsInit_) - return; - if (this.settingsKey_ === undefined) - return; - if (this.defaultCheckedValue_ === undefined) - return; - this.needsInit_ = false; - this.checked = tr.b.Settings.get( - this.settingsKey_, this.defaultCheckedValue_); - }, - - get label() { - return this.label_; - }, - - set label(label) { - this.label_ = label; - this.maybeUpdateElements_(); - }, - - get checked() { - return this.checked_; - }, - - set checked(checked) { - this.checked_ = checked; - this.maybeUpdateElements_(); - tr.b.Settings.set(this.settingsKey_, this.checked_); - }, - - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/checkbox_picker.html b/chromium/third_party/catapult/tracing/tracing/ui/base/checkbox_picker.html deleted file mode 100644 index 261b15922bd..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/checkbox_picker.html +++ /dev/null @@ -1,111 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2016 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/base/checkbox.html"> -<link rel="import" href="/tracing/ui/base/ui.html"> - -<polymer-element name='tr-ui-b-checkbox-picker'> - <template> - <style> - #container { - display: flex; - flex-direction: column; - } - </style> - - <div id="container"> - </div> - - </template> - - <script> - 'use strict'; - - Polymer({ - created: function() { - this.needsInit_ = true; - this.settingsKey_ = undefined; - this.is_ready_ = false; - this.checkboxes_ = undefined; - }, - - ready: function() { - this.is_ready_ = true; - this.maybeInit_(); - this.maybeRenderCheckboxes_(); - }, - - get settingsKey() { - return this.settingsKey_; - }, - - set settingsKey(settingsKey) { - if (!this.needsInit_) - throw new Error('Already initialized.'); - this.settingsKey_ = settingsKey; - this.maybeInit_(); - }, - - maybeInit_: function() { - if (!this.needsInit_) - return; - if (this.settingsKey_ === undefined) - return; - if (this.checkboxes_ === undefined) - return; - - this.needsInit_ = false; - - for (var key in this.checkboxes_) { - this.checkboxes_[key].defaultCheckedValue = false; - this.checkboxes_[key].settingsKey = this.settingsKey_ + key; - } - }, - - set items(items) { - this.checkboxes_ = {}; - items.forEach(function(e) { - if (e.key in this.checkboxes_) - throw new Error(e.key + ' already exists'); - var checkboxEl = document.createElement('tr-ui-b-checkbox'); - checkboxEl.label = e.label; - this.checkboxes_[e.key] = checkboxEl; - }.bind(this)); - this.maybeInit_(); - this.maybeRenderCheckboxes_(); - }, - - maybeRenderCheckboxes_: function() { - if (!this.is_ready_) - return; - if (this.checkboxes_ === undefined) - return; - for (var key in this.checkboxes_) - this.$.container.appendChild(this.checkboxes_[key]); - }, - - selectCheckbox: function(key) { - if (!(key in this.checkboxes_)) - throw new Error(key + ' does not exists'); - this.checkboxes_[key].checked = true; - }, - - unselectCheckbox: function(key) { - if (!(key in this.checkboxes_)) - throw new Error(key + ' does not exists'); - this.checkboxes_[key].checked = false; - }, - - get checkedKeys() { - return Object.keys(this.checkboxes_).filter(function(k) { - return this.checkboxes_[k].checked; - }.bind(this)); - }, - - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/checkbox_picker_test.html b/chromium/third_party/catapult/tracing/tracing/ui/base/checkbox_picker_test.html deleted file mode 100644 index 40d83361fb6..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/checkbox_picker_test.html +++ /dev/null @@ -1,139 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2016 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/base/checkbox_picker.html"> -<link rel="import" href="/tracing/ui/base/dom_helpers.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - test('basicAllCheckboxUnchecked', function() { - var cp = document.createElement('tr-ui-b-checkbox-picker'); - cp.items = [ - {key: 'Toyota', label: 'I want to drive Toyota'}, - {key: 'Boeing', label: 'I want to fly'} - ]; - this.addHTMLOutput(cp); - assert.deepEqual(cp.checkedKeys, []); - }); - - test('basicSomeCheckboxChecked', function() { - var cp = document.createElement('tr-ui-b-checkbox-picker'); - cp.items = [ - {key: 'Toyota', label: 'I want to drive Toyota'}, - {key: 'Honda', label: 'I want to drive Honda'}, - {key: 'Tesla', label: 'I want to drive electric car'}, - ]; - - cp.selectCheckbox('Toyota'); - cp.selectCheckbox('Tesla'); - this.addHTMLOutput(cp); - assert.deepEqual(cp.checkedKeys.sort(), ['Tesla', 'Toyota']); - cp.unselectCheckbox('Toyota'); - assert.deepEqual(cp.checkedKeys, ['Tesla']); - }); - - test('duplicateKeys', function() { - var cp = document.createElement('tr-ui-b-checkbox-picker'); - assert.throws(function() { - cp.items = [ - {key: 'Toyota', label: 'I want to drive Toyota'}, - {key: 'Honda', label: 'I want to drive Honda'}, - {key: 'Toyota', label: 'I want to drive electric car'}, - ]; - }); - }); - - test('selectAndUnselectNonExistingKey', function() { - var cp = document.createElement('tr-ui-b-checkbox-picker'); - cp.items = [ - {key: 'Toyota', label: 'I want to drive Toyota'}, - {key: 'Honda', label: 'I want to drive Honda'}, - ]; - assert.throws(function() { - cp.selectCheckbox('Lamborghini'); - }); - assert.throws(function() { - cp.unselectCheckbox('Roll Royce'); - }); - }); - - test('testPersistentStateOneSetSettingsKeyBeforeSettingItems', function() { - var container1 = tr.ui.b.createDiv({textContent: 'Checkbox Picker One'}); - container1.style.border = 'solid'; - var cp = document.createElement('tr-ui-b-checkbox-picker'); - cp.settingsKey = 'checkbox-picker-test-one'; - cp.items = [ - {key: 'Toyota', label: 'I want to drive Toyota'}, - {key: 'Honda', label: 'I want to drive Honda'}, - {key: 'Tesla', label: 'I want to drive electric car'}, - ]; - cp.selectCheckbox('Toyota'); - cp.selectCheckbox('Tesla'); - container1.appendChild(cp); - this.addHTMLOutput(container1); - cp.unselectCheckbox('Tesla'); - assert.deepEqual(cp.checkedKeys, ['Toyota']); - - this.addHTMLOutput(document.createElement('br')); - - var container2 = tr.ui.b.createDiv( - {textContent: - 'Checkbox Picker Two (Same settingsKey as Checkbox Picker One)'}); - container2.style.border = 'solid #0000FF'; - var cp2 = document.createElement('tr-ui-b-checkbox-picker'); - cp2.settingsKey = 'checkbox-picker-test-one'; - cp2.items = [ - {key: 'Toyota', label: 'I want to drive Toyota'}, - {key: 'Honda', label: 'I want to drive Honda'}, - {key: 'Tesla', label: 'I want to drive electric car'}, - ]; - container2.appendChild(cp2); - this.addHTMLOutput(container2); - assert.deepEqual(cp2.checkedKeys, ['Toyota']); - }); - - test('testPersistentStateTwoSetSettingsKeyAfterSettingItems', function() { - var container1 = tr.ui.b.createDiv({textContent: 'Checkbox Picker One'}); - container1.style.border = 'solid'; - var cp = document.createElement('tr-ui-b-checkbox-picker'); - cp.items = [ - {key: 'Toyota', label: 'I want to drive Toyota'}, - {key: 'Honda', label: 'I want to drive Honda'}, - {key: 'Tesla', label: 'I want to drive electric car'}, - ]; - cp.settingsKey = 'checkbox-picker-test-one'; - cp.selectCheckbox('Toyota'); - cp.selectCheckbox('Tesla'); - container1.appendChild(cp); - this.addHTMLOutput(container1); - assert.deepEqual(cp.checkedKeys.sort(), ['Tesla', 'Toyota']); - - this.addHTMLOutput(document.createElement('br')); - - var container2 = tr.ui.b.createDiv( - {textContent: - 'Checkbox Picker Two (Same settingsKey as Checkbox Picker One)'}); - container2.style.border = 'solid #0000FF'; - var cp2 = document.createElement('tr-ui-b-checkbox-picker'); - cp2.items = [ - {key: 'Toyota', label: 'I want to drive Toyota'}, - {key: 'Honda', label: 'I want to drive Honda'}, - {key: 'Tesla', label: 'I want to drive electric car'}, - ]; - container2.appendChild(cp2); - this.addHTMLOutput(container2); - cp2.settingsKey = 'checkbox-picker-test-one'; - assert.deepEqual(cp2.checkedKeys.sort(), ['Tesla', 'Toyota']); - - }); - - - -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/checkbox_test.html b/chromium/third_party/catapult/tracing/tracing/ui/base/checkbox_test.html deleted file mode 100644 index 16f0223110a..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/checkbox_test.html +++ /dev/null @@ -1,69 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2016 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/base/checkbox.html"> -<link rel="import" href="/tracing/ui/base/dom_helpers.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - test('basicUnchecked', function() { - var checkbox = document.createElement('tr-ui-b-checkbox'); - checkbox.label = 'Yo like pizza?'; - this.addHTMLOutput(checkbox); - assert.equal(checkbox.label, 'Yo like pizza?'); - assert.isFalse(checkbox.checked); - }); - - test('basicChecked', function() { - var checkbox = document.createElement('tr-ui-b-checkbox'); - checkbox.label = 'Yo like cookie?'; - checkbox.checked = true; - this.addHTMLOutput(checkbox); - assert.equal(checkbox.label, 'Yo like cookie?'); - assert.isTrue(checkbox.checked); - }); - - test('testPersistentStateOneSetSettingsKeyBeforeAddToDom', function() { - var checkbox = document.createElement('tr-ui-b-checkbox'); - checkbox.settingsKey = 'checkbox-basic-test-one'; - checkbox.label = 'I like sushi'; - checkbox.defaultCheckedValue = false; - this.addHTMLOutput(checkbox); - assert.isFalse(checkbox.checked); - checkbox.checked = true; - - var checkbox2 = document.createElement('tr-ui-b-checkbox'); - checkbox2.label = 'I like sushi'; - checkbox2.defaultCheckedValue = false; - checkbox2.settingsKey = 'checkbox-basic-test-one'; - this.addHTMLOutput(checkbox2); - assert.isTrue(checkbox2.checked); - }); - - test('testPersistentStateTwoSetSettingsKeyAfterAddToDom', function() { - var checkbox = document.createElement('tr-ui-b-checkbox'); - this.addHTMLOutput(checkbox); - checkbox.label = 'I like Ramen'; - checkbox.settingsKey = 'checkbox-basic-test-two'; - checkbox.defaultCheckedValue = false; - assert.isFalse(checkbox.checked); - checkbox.checked = true; - - var checkbox2 = document.createElement('tr-ui-b-checkbox'); - this.addHTMLOutput(checkbox2); - checkbox2.label = 'I like Ramen'; - checkbox2.defaultCheckedValue = false; - checkbox2.settingsKey = 'checkbox-basic-test-two'; - assert.isTrue(checkbox2.checked); - }); - - - -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/color_legend.html b/chromium/third_party/catapult/tracing/tracing/ui/base/color_legend.html deleted file mode 100644 index 3804b4b144c..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/color_legend.html +++ /dev/null @@ -1,79 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/color_scheme.html"> -<link rel="import" href="/tracing/model/compound_event_selection_state.html"> -<link rel="import" href="/tracing/ui/base/dom_helpers.html"> - -<!-- -@fileoverview A component used to display a label and a color square. - -The colored square is typically filled with the color associated with -that label, using the getColorId* methods from base/color_scheme. ---> -<polymer-element name="tr-ui-b-color-legend"> - <template> - <style> - :host { - display: inline-block; - } - - #square { - font-size: 150%; /* Make the square bigger. */ - line-height: 0%; /* Prevent the square from increasing legend height. */ - } - </style> - <span id="square"></span> - <span id="label"></span> - </template> - <script> - 'use strict'; - - Polymer({ - ready: function() { - var blackSquareCharCode = 9632; - this.$.square.innerText = String.fromCharCode(blackSquareCharCode); - this.label_ = undefined; - - this.compoundEventSelectionState_ = - tr.model.CompoundEventSelectionState.NOT_SELECTED; - }, - - set compoundEventSelectionState(compoundEventSelectionState) { - this.compoundEventSelectionState_ = compoundEventSelectionState; - // TODO(nduca): Adjust appearance based on associated state. - }, - - get label() { - return this.label_; - }, - - set label(label) { - if (label === undefined) { - this.setLabelAndColorId(undefined, undefined); - return; - } - - var colorId = tr.b.ColorScheme.getColorIdForGeneralPurposeString( - label); - this.setLabelAndColorId(label, colorId); - }, - - setLabelAndColorId: function(label, colorId) { - this.label_ = label; - - this.$.label.textContent = ''; - this.$.label.appendChild(tr.ui.b.asHTMLOrTextNode(label)); - - if (colorId === undefined) - this.$.square.style.color = 'initial'; - else - this.$.square.style.color = tr.b.ColorScheme.colorsAsStrings[colorId]; - } - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/color_legend_test.html b/chromium/third_party/catapult/tracing/tracing/ui/base/color_legend_test.html deleted file mode 100644 index fbe802d6a8f..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/color_legend_test.html +++ /dev/null @@ -1,122 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/base/color_legend.html"> -<link rel="import" href="/tracing/ui/base/dom_helpers.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var CompoundEventSelectionState = tr.model.CompoundEventSelectionState; - - function checkSquareColor(colorLegend, expectedColor) { - assert.equal(getComputedStyle(colorLegend.$.square).color, expectedColor); - } - - test('noLabelSet', function() { - var colorLegend = document.createElement('tr-ui-b-color-legend'); - this.addHTMLOutput(colorLegend); - checkSquareColor(colorLegend, 'rgb(0, 0, 0)'); - }); - - test('undefinedLabel', function() { - var colorLegend = document.createElement('tr-ui-b-color-legend'); - colorLegend.label = undefined; - this.addHTMLOutput(colorLegend); - checkSquareColor(colorLegend, 'rgb(0, 0, 0)'); - }); - - test('emptyLabel', function() { - var colorLegend = document.createElement('tr-ui-b-color-legend'); - colorLegend.label = ''; - this.addHTMLOutput(colorLegend); - checkSquareColor(colorLegend, 'rgb(122, 98, 135)'); - }); - - test('nonEmptyLabel', function() { - var colorLegend = document.createElement('tr-ui-b-color-legend'); - colorLegend.label = 'Frequency'; - this.addHTMLOutput(colorLegend); - checkSquareColor(colorLegend, 'rgb(83, 150, 97)'); - }); - - test('longLabel', function() { - var colorLegend = document.createElement('tr-ui-b-color-legend'); - colorLegend.label = 'Total memory usage'; - this.addHTMLOutput(colorLegend); - checkSquareColor(colorLegend, 'rgb(96, 128, 137)'); - }); - - test('directlySetColorId', function() { - var colorLegend = document.createElement('tr-ui-b-color-legend'); - colorLegend.setLabelAndColorId('hello_world', 7 /* colorId */); - this.addHTMLOutput(colorLegend); - checkSquareColor(colorLegend, 'rgb(111, 145, 88)'); - }); - - test('directlyProvidedLabelElement', function() { - var colorLegend = document.createElement('tr-ui-b-color-legend'); - colorLegend.setLabelAndColorId( - tr.ui.b.createSpan({textContent: 'hello', - className: 'hello-span'}), - 7 /* colorId */); - this.addHTMLOutput(colorLegend); - checkSquareColor(colorLegend, 'rgb(111, 145, 88)'); - }); - - test('cessObjectSelected', function() { - var colorLegend = document.createElement('tr-ui-b-color-legend'); - colorLegend.label = 'Object selected'; - colorLegend.compoundEventSelectionState = - CompoundEventSelectionState.EVENT_SELECTED; - this.addHTMLOutput(colorLegend); - checkSquareColor(colorLegend, 'rgb(143, 72, 161)'); - }); - - test('cessSomeAssociatedObjectsSelected', function() { - var colorLegend = document.createElement('tr-ui-b-color-legend'); - colorLegend.label = 'Some associated objects selected'; - colorLegend.compoundEventSelectionState = - CompoundEventSelectionState.SOME_ASSOCIATED_EVENTS_SELECTED; - - this.addHTMLOutput(colorLegend); - checkSquareColor(colorLegend, 'rgb(159, 74, 86)'); - }); - - test('cessAllAssociatedObjectsSelected', function() { - var colorLegend = document.createElement('tr-ui-b-color-legend'); - colorLegend.label = 'All associated objects selected'; - colorLegend.compoundEventSelectionState = - CompoundEventSelectionState.ALL_ASSOCIATED_EVENTS_SELECTED; - - this.addHTMLOutput(colorLegend); - checkSquareColor(colorLegend, 'rgb(112, 91, 142)'); - }); - - test('cessObjectAndSomeAssociatedObjectsSelected', function() { - var colorLegend = document.createElement('tr-ui-b-color-legend'); - colorLegend.label = 'Object and some associated objects selected'; - colorLegend.compoundEventSelectionState = - CompoundEventSelectionState.EVENT_AND_SOME_ASSOCIATED_SELECTED; - - this.addHTMLOutput(colorLegend); - checkSquareColor(colorLegend, 'rgb(83, 150, 97)'); - }); - - test('cessObjectAndAllAssociatedObjectsSelected', function() { - var colorLegend = document.createElement('tr-ui-b-color-legend'); - colorLegend.label = 'Object and all associated objects selected'; - colorLegend.compoundEventSelectionState = - CompoundEventSelectionState.EVENT_AND_ALL_ASSOCIATED_SELECTED; - - this.addHTMLOutput(colorLegend); - checkSquareColor(colorLegend, 'rgb(87, 109, 147)'); - }); - -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/constants.html b/chromium/third_party/catapult/tracing/tracing/ui/base/constants.html deleted file mode 100644 index 1a412656369..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/constants.html +++ /dev/null @@ -1,20 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> -<link rel="import" href="/tracing/base/base.html"> -<script> -'use strict'; - -tr.exportTo('tr.ui.b', function() { - var constants = { - HEADING_WIDTH: 250 - }; - - return { - constants: constants - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/container_that_decorates_its_children.html b/chromium/third_party/catapult/tracing/tracing/ui/base/container_that_decorates_its_children.html deleted file mode 100644 index 11ed53a5fda..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/container_that_decorates_its_children.html +++ /dev/null @@ -1,107 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/event.html"> -<link rel="import" href="/tracing/ui/base/ui.html"> - -<script> -'use strict'; - -/** - * @fileoverview Container that decorates its children. - */ -tr.exportTo('tr.ui.b', function() { - /** - * @constructor - */ - var ContainerThatDecoratesItsChildren = tr.ui.b.define('div'); - - ContainerThatDecoratesItsChildren.prototype = { - __proto__: HTMLUnknownElement.prototype, - - decorate: function() { - this.observer_ = new WebKitMutationObserver(this.didMutate_.bind(this)); - this.observer_.observe(this, { childList: true }); - - // textContent is a variable on regular HTMLElements. However, we want to - // hook and prevent writes to it. - Object.defineProperty( - this, 'textContent', - { get: undefined, set: this.onSetTextContent_}); - }, - - appendChild: function(x) { - HTMLUnknownElement.prototype.appendChild.call(this, x); - this.didMutate_(this.observer_.takeRecords()); - }, - - insertBefore: function(x, y) { - HTMLUnknownElement.prototype.insertBefore.call(this, x, y); - this.didMutate_(this.observer_.takeRecords()); - }, - - removeChild: function(x) { - HTMLUnknownElement.prototype.removeChild.call(this, x); - this.didMutate_(this.observer_.takeRecords()); - }, - - replaceChild: function(x, y) { - HTMLUnknownElement.prototype.replaceChild.call(this, x, y); - this.didMutate_(this.observer_.takeRecords()); - }, - - onSetTextContent_: function(textContent) { - if (textContent != '') - throw new Error('textContent can only be set to \'\'.'); - this.clear(); - }, - - clear: function() { - while (this.lastChild) - HTMLUnknownElement.prototype.removeChild.call(this, this.lastChild); - this.didMutate_(this.observer_.takeRecords()); - }, - - didMutate_: function(records) { - this.beginDecorating_(); - for (var i = 0; i < records.length; i++) { - var addedNodes = records[i].addedNodes; - if (addedNodes) { - for (var j = 0; j < addedNodes.length; j++) - this.decorateChild_(addedNodes[j]); - } - var removedNodes = records[i].removedNodes; - if (removedNodes) { - for (var j = 0; j < removedNodes.length; j++) { - this.undecorateChild_(removedNodes[j]); - } - } - } - this.doneDecoratingForNow_(); - }, - - decorateChild_: function(child) { - throw new Error('Not implemented'); - }, - - undecorateChild_: function(child) { - throw new Error('Not implemented'); - }, - - beginDecorating_: function() { - }, - - doneDecoratingForNow_: function() { - } - }; - - return { - ContainerThatDecoratesItsChildren: ContainerThatDecoratesItsChildren - }; - -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/container_that_decorates_its_children_test.html b/chromium/third_party/catapult/tracing/tracing/ui/base/container_that_decorates_its_children_test.html deleted file mode 100644 index 0f7ff710061..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/container_that_decorates_its_children_test.html +++ /dev/null @@ -1,97 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> -<link rel="import" href="/tracing/ui/base/container_that_decorates_its_children.html"> -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - - function createChild() { - var span = document.createElement('span'); - span.decorated = false; - return span; - } - - /** - * @constructor - */ - var SimpleContainer = tr.ui.b.define( - 'simple-container', tr.ui.b.ContainerThatDecoratesItsChildren); - - SimpleContainer.prototype = { - __proto__: tr.ui.b.ContainerThatDecoratesItsChildren.prototype, - - decorateChild_: function(child) { - assert.isFalse(child.decorated); - child.decorated = true; - }, - - undecorateChild_: function(child) { - assert.isTrue(child.decorated); - child.decorated = false; - } - }; - - test('add', function() { - var container = new SimpleContainer(); - container.appendChild(createChild()); - container.appendChild(createChild()); - container.appendChild(createChild()); - assert.isTrue(container.children[0].decorated); - assert.isTrue(container.children[1].decorated); - assert.isTrue(container.children[2].decorated); - }); - - test('clearUsingTextContent', function() { - var c0 = createChild(); - var container = new SimpleContainer(); - container.appendChild(c0); - container.textContent = ''; - assert.isFalse(c0.decorated); - }); - - test('clear', function() { - var c0 = createChild(); - var container = new SimpleContainer(); - container.appendChild(c0); - container.clear(); - assert.isFalse(c0.decorated); - }); - - test('insertNewBefore', function() { - var c0 = createChild(); - var c1 = createChild(); - var container = new SimpleContainer(); - container.appendChild(c1); - container.insertBefore(c0, c1); - assert.isTrue(c0.decorated); - assert.isTrue(c1.decorated); - }); - - test('insertExistingBefore', function() { - var c0 = createChild(); - var c1 = createChild(); - var container = new SimpleContainer(); - container.appendChild(c1); - container.appendChild(c0); - container.insertBefore(c0, c1); - assert.isTrue(c0.decorated); - assert.isTrue(c1.decorated); - }); - - test('testReplace', function() { - var c0 = createChild(); - var c1 = createChild(); - var container = new SimpleContainer(); - container.appendChild(c0); - container.replaceChild(c1, c0); - assert.isFalse(c0.decorated); - assert.isTrue(c1.decorated); - }); - -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/d3.html b/chromium/third_party/catapult/tracing/tracing/ui/base/d3.html deleted file mode 100644 index ed4c962a25e..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/d3.html +++ /dev/null @@ -1,7 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> -<script src="/d3.min.js"></script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/deep_utils.html b/chromium/third_party/catapult/tracing/tracing/ui/base/deep_utils.html deleted file mode 100644 index 6476dee1af1..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/deep_utils.html +++ /dev/null @@ -1,84 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> -<link rel="import" href="/tracing/base/base.html"> -<script> - -'use strict'; - -tr.exportTo('tr.b', function() { - function _iterateElementDeeplyImpl(element, cb, thisArg, includeElement) { - if (includeElement) { - if (cb.call(thisArg, element)) - return true; - } - - if (element.shadowRoot) { - if (_iterateElementDeeplyImpl(element.shadowRoot, cb, thisArg, false)) - return true; - } - for (var i = 0; i < element.children.length; i++) { - if (_iterateElementDeeplyImpl(element.children[i], cb, thisArg, true)) - return true; - } - } - function iterateElementDeeply(element, cb, thisArg) { - _iterateElementDeeplyImpl(element, cb, thisArg, false); - } - - function findDeepElementMatchingPredicate(element, predicate) { - var foundElement = undefined; - function matches(element) { - var match = predicate(element); - if (!match) - return false; - foundElement = element; - return true; - } - iterateElementDeeply(element, matches); - return foundElement; - } - - function findDeepElementsMatchingPredicate(element, predicate) { - var foundElements = []; - function matches(element) { - var match = predicate(element); - if (match) { - foundElements.push(element); - } - return false; - } - iterateElementDeeply(element, matches); - return foundElements; - } - - function findDeepElementMatching(element, selector) { - return findDeepElementMatchingPredicate(element, function(element) { - return element.matches(selector); - }); - } - function findDeepElementsMatching(element, selector) { - return findDeepElementsMatchingPredicate(element, function(element) { - return element.matches(selector); - }); - } - function findDeepElementWithTextContent(element, re) { - return findDeepElementMatchingPredicate(element, function(element) { - if (element.children.length !== 0) - return false; - return re.test(element.textContent); - }); - } - return { - iterateElementDeeply: iterateElementDeeply, - findDeepElementMatching: findDeepElementMatching, - findDeepElementsMatching: findDeepElementsMatching, - findDeepElementMatchingPredicate: findDeepElementMatchingPredicate, - findDeepElementsMatchingPredicate: findDeepElementsMatchingPredicate, - findDeepElementWithTextContent: findDeepElementWithTextContent - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/deep_utils_test.html b/chromium/third_party/catapult/tracing/tracing/ui/base/deep_utils_test.html deleted file mode 100644 index fa0d843e106..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/deep_utils_test.html +++ /dev/null @@ -1,51 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/base/deep_utils.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - function createElement(tagName, opt_class) { - var el = document.createElement(tagName); - if (opt_class) - el.className = opt_class; - return el; - } - - test('testFindDeepElementMatching', function() { - var a = createElement('a'); - var a_ = a.createShadowRoot(); - - var b = createElement('b'); - a_.appendChild(b); - - var b_ = b.createShadowRoot(); - b_.appendChild(createElement('c', 'x')); - - var m = tr.b.findDeepElementMatching(a, 'c.x'); - assert.equal(m, b_.children[0]); - }); - - test('testFindDeepElementsMatching', function() { - var a = createElement('a'); - var a_ = a.createShadowRoot(); - - var b = createElement('b'); - a_.appendChild(b); - - var b_ = b.createShadowRoot(); - b_.appendChild(createElement('c', 'x')); - b_.appendChild(createElement('c', 'x')); - - var m = tr.b.findDeepElementsMatching(a, 'c.x'); - assert.equal(m[0], b_.children[0]); - assert.equal(m[1], b_.children[1]); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/dom_helpers.html b/chromium/third_party/catapult/tracing/tracing/ui/base/dom_helpers.html deleted file mode 100644 index 02af70a52fc..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/dom_helpers.html +++ /dev/null @@ -1,337 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/settings.html"> -<link rel="import" href="/tracing/ui/base/ui.html"> - -<style> -* /deep/ .labeled-checkbox { - display: flex; - white-space: nowrap; -} -</style> - -<script> -'use strict'; - -tr.exportTo('tr.ui.b', function() { - - function createSpan(opt_dictionary) { - var ownerDocument = document; - if (opt_dictionary && opt_dictionary.ownerDocument) - ownerDocument = opt_dictionary.ownerDocument; - var spanEl = ownerDocument.createElement('span'); - if (opt_dictionary) { - if (opt_dictionary.className) - spanEl.className = opt_dictionary.className; - if (opt_dictionary.textContent) - spanEl.textContent = opt_dictionary.textContent; - if (opt_dictionary.tooltip) - spanEl.title = opt_dictionary.tooltip; - if (opt_dictionary.parent) - opt_dictionary.parent.appendChild(spanEl); - if (opt_dictionary.bold) - spanEl.style.fontWeight = 'bold'; - if (opt_dictionary.italic) - spanEl.style.fontStyle = 'italic'; - if (opt_dictionary.marginLeft) - spanEl.style.marginLeft = opt_dictionary.marginLeft; - if (opt_dictionary.marginRight) - spanEl.style.marginRight = opt_dictionary.marginRight; - if (opt_dictionary.backgroundColor) - spanEl.style.backgroundColor = opt_dictionary.backgroundColor; - if (opt_dictionary.color) - spanEl.style.color = opt_dictionary.color; - } - return spanEl; - }; - - function createDiv(opt_dictionary) { - var divEl = document.createElement('div'); - if (opt_dictionary) { - if (opt_dictionary.className) - divEl.className = opt_dictionary.className; - if (opt_dictionary.parent) - opt_dictionary.parent.appendChild(divEl); - if (opt_dictionary.textContent) - divEl.textContent = opt_dictionary.textContent; - if (opt_dictionary.maxWidth) - divEl.style.maxWidth = opt_dictionary.maxWidth; - } - return divEl; - }; - - function createScopedStyle(styleContent) { - var styleEl = document.createElement('style'); - styleEl.scoped = true; - styleEl.innerHTML = styleContent; - return styleEl; - } - - function valuesEqual(a, b) { - if (a instanceof Array && b instanceof Array) - return a.length === b.length && JSON.stringify(a) === JSON.stringify(b); - return a === b; - } - - function createSelector( - targetEl, targetElProperty, - settingsKey, defaultValue, - items, opt_namespace) { - var defaultValueIndex; - for (var i = 0; i < items.length; i++) { - var item = items[i]; - if (valuesEqual(item.value, defaultValue)) { - defaultValueIndex = i; - break; - } - } - if (defaultValueIndex === undefined) - throw new Error('defaultValue must be in the items list'); - - var selectorEl = document.createElement('select'); - selectorEl.addEventListener('change', onChange); - for (var i = 0; i < items.length; i++) { - var item = items[i]; - var optionEl = document.createElement('option'); - optionEl.textContent = item.label; - optionEl.targetPropertyValue = item.value; - optionEl.item = item; - selectorEl.appendChild(optionEl); - } - function onChange(e) { - var value = selectorEl.selectedOptions[0].targetPropertyValue; - tr.b.Settings.set(settingsKey, value, opt_namespace); - targetEl[targetElProperty] = value; - } - var oldSetter = targetEl.__lookupSetter__('selectedIndex'); - selectorEl.__defineGetter__('selectedValue', function(v) { - return selectorEl.children[selectorEl.selectedIndex].targetPropertyValue; - }); - selectorEl.__defineGetter__('selectedItem', function(v) { - return selectorEl.children[selectorEl.selectedIndex].item; - }); - selectorEl.__defineSetter__('selectedValue', function(v) { - for (var i = 0; i < selectorEl.children.length; i++) { - var value = selectorEl.children[i].targetPropertyValue; - if (valuesEqual(value, v)) { - var changed = selectorEl.selectedIndex != i; - if (changed) { - selectorEl.selectedIndex = i; - onChange(); - } - return; - } - } - throw new Error('Not a valid value'); - }); - - var initialValue = tr.b.Settings.get( - settingsKey, defaultValue, opt_namespace); - var didSet = false; - for (var i = 0; i < selectorEl.children.length; i++) { - if (valuesEqual(selectorEl.children[i].targetPropertyValue, - initialValue)) { - didSet = true; - targetEl[targetElProperty] = initialValue; - selectorEl.selectedIndex = i; - break; - } - } - if (!didSet) { - selectorEl.selectedIndex = defaultValueIndex; - targetEl[targetElProperty] = defaultValue; - } - - return selectorEl; - } - - function createEditCategorySpan(optionGroupEl, targetEl) { - var spanEl = createSpan({className: 'edit-categories'}); - spanEl.textContent = 'Edit categories'; - spanEl.classList.add('labeled-option'); - - spanEl.addEventListener('click', function() { - targetEl.onClickEditCategories(); - }); - return spanEl; - } - - function createOptionGroup(targetEl, targetElProperty, - settingsKey, defaultValue, - items) { - function onChange() { - var value = []; - if (this.value.length) - value = this.value.split(','); - tr.b.Settings.set(settingsKey, value); - targetEl[targetElProperty] = value; - } - - var optionGroupEl = createSpan({className: 'labeled-option-group'}); - var initialValue = tr.b.Settings.get(settingsKey, defaultValue); - for (var i = 0; i < items.length; ++i) { - var item = items[i]; - var id = 'category-preset-' + item.label.replace(/ /g, '-'); - - var radioEl = document.createElement('input'); - radioEl.type = 'radio'; - radioEl.setAttribute('id', id); - radioEl.setAttribute('name', 'category-presets-group'); - radioEl.setAttribute('value', item.value); - radioEl.addEventListener('change', onChange.bind(radioEl, targetEl, - targetElProperty, - settingsKey)); - if (valuesEqual(initialValue, item.value)) - radioEl.checked = true; - - var labelEl = document.createElement('label'); - labelEl.textContent = item.label; - labelEl.setAttribute('for', id); - - var spanEl = createSpan({className: 'labeled-option'}); - spanEl.appendChild(radioEl); - spanEl.appendChild(labelEl); - - spanEl.__defineSetter__('checked', function(opt_bool) { - var changed = radioEl.checked !== (!!opt_bool); - if (!changed) - return; - - radioEl.checked = !!opt_bool; - onChange(); - }); - spanEl.__defineGetter__('checked', function() { - return radioEl.checked; - }); - - optionGroupEl.appendChild(spanEl); - } - optionGroupEl.appendChild(createEditCategorySpan(optionGroupEl, targetEl)); - // Since this option group element is not yet added to the tree, - // querySelector will fail during updateEditCategoriesStatus_ call. - // Hence, creating the element with the 'expanded' classlist category - // added, if last selected value was 'Manual' selection. - if (!initialValue.length) - optionGroupEl.classList.add('categories-expanded'); - targetEl[targetElProperty] = initialValue; - - return optionGroupEl; - } - - var nextCheckboxId = 1; - function createCheckBox(targetEl, targetElProperty, - settingsKey, defaultValue, - label, opt_changeCb) { - var buttonEl = document.createElement('input'); - buttonEl.type = 'checkbox'; - - var initialValue = tr.b.Settings.get(settingsKey, defaultValue); - buttonEl.checked = !!initialValue; - if (targetEl) - targetEl[targetElProperty] = initialValue; - - function onChange() { - tr.b.Settings.set(settingsKey, buttonEl.checked); - if (targetEl) - targetEl[targetElProperty] = buttonEl.checked; - if (opt_changeCb) - opt_changeCb.call(); - } - - buttonEl.addEventListener('change', onChange); - - var id = '#checkbox-' + nextCheckboxId++; - - var spanEl = createSpan({className: 'labeled-checkbox'}); - buttonEl.setAttribute('id', id); - - var labelEl = document.createElement('label'); - labelEl.textContent = label; - labelEl.setAttribute('for', id); - spanEl.appendChild(buttonEl); - spanEl.appendChild(labelEl); - - spanEl.__defineSetter__('checked', function(opt_bool) { - var changed = buttonEl.checked !== (!!opt_bool); - if (!changed) - return; - - buttonEl.checked = !!opt_bool; - onChange(); - }); - spanEl.__defineGetter__('checked', function() { - return buttonEl.checked; - }); - - return spanEl; - } - - /** - * @param {!string} label - * @param {function()=} opt_callback - * @param {*=} opt_this - */ - function createButton(label, opt_callback, opt_this) { - var buttonEl = document.createElement('input'); - buttonEl.type = 'button'; - buttonEl.value = label; - - function onClick() { - opt_callback.call(opt_this || buttonEl); - } - - if (opt_callback) - buttonEl.addEventListener('click', onClick); - - return buttonEl; - } - - function createTextInput( - targetEl, targetElProperty, settingsKey, defaultValue) { - var initialValue = tr.b.Settings.get(settingsKey, defaultValue); - var el = document.createElement('input'); - el.type = 'text'; - function onChange(e) { - tr.b.Settings.set(settingsKey, el.value); - targetEl[targetElProperty] = el.value; - } - el.addEventListener('input', onChange); - el.value = initialValue; - targetEl[targetElProperty] = initialValue; - - return el; - } - - function isElementAttachedToDocument(el) { - var cur = el; - while (cur.parentNode) - cur = cur.parentNode; - return (cur === el.ownerDocument || cur.nodeName === '#document-fragment'); - } - - function asHTMLOrTextNode(value, opt_ownerDocument) { - if (value instanceof Node) - return value; - var ownerDocument = opt_ownerDocument || document; - return ownerDocument.createTextNode(value); - } - - return { - createSpan: createSpan, - createDiv: createDiv, - createScopedStyle: createScopedStyle, - createSelector: createSelector, - createOptionGroup: createOptionGroup, - createCheckBox: createCheckBox, - createButton: createButton, - createTextInput: createTextInput, - isElementAttachedToDocument: isElementAttachedToDocument, - asHTMLOrTextNode: asHTMLOrTextNode - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/dom_helpers_test.html b/chromium/third_party/catapult/tracing/tracing/ui/base/dom_helpers_test.html deleted file mode 100644 index 64ba68ba36f..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/dom_helpers_test.html +++ /dev/null @@ -1,151 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> -<link rel="import" href="/tracing/ui/base/dom_helpers.html"> -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var THIS_DOC = document._currentScript.ownerDocument; - - test('simpleSpanAndDiv', function() { - var divEl = tr.ui.b.createDiv({ - className: 'a-div-class', parent: document.body - }); - var testText = 'some span text'; - var spanEl = tr.ui.b.createSpan({ - className: 'a-span-class', - textContent: testText, - parent: divEl - }); - var eltInDocument = document.querySelector('.a-div-class>.a-span-class'); - assert.equal(eltInDocument.textContent, testText); - eltInDocument.parentElement.removeChild(eltInDocument); - }); - - test('createSpan_ownerDocument', function() { - var spanEl = tr.ui.b.createSpan({ - className: 'a-span-class', - bold: true, - ownerDocument: THIS_DOC - }); - assert.strictEqual(spanEl.ownerDocument, THIS_DOC); - }); - - test('checkboxFromDefaults', function() { - var target = {foo: undefined}; - var cb = tr.ui.b.createCheckBox(target, 'foo', 'myCheckBox', false, 'Foo'); - assert.isFalse(target.foo); - }); - - test('checkboxFromSettings', function() { - tr.b.Settings.set('myCheckBox', true); - var target = {foo: undefined}; - var cb = tr.ui.b.createCheckBox(target, 'foo', 'myCheckBox', false, 'Foo'); - assert.isTrue(target.foo); - }); - - test('checkboxChanged', function() { - var target = {foo: undefined}; - var cb = tr.ui.b.createCheckBox(target, 'foo', 'myCheckBox', false, 'Foo'); - cb.checked = true; - - assert.isTrue(tr.b.Settings.get('myCheckBox', undefined)); - assert.isTrue(target.foo); - }); - - test('selectorSettingsAlreaySet', function() { - tr.b.Settings.set('myScale', 0.25); - - var target = { - scale: 314 - }; - var sel = tr.ui.b.createSelector( - target, 'scale', - 'myScale', 0.375, - [{label: '6.25%', value: 0.0625}, - {label: '12.5%', value: 0.125}, - {label: '25%', value: 0.25}, - {label: '37.5%', value: 0.375}, - {label: '50%', value: 0.5}, - {label: '75%', value: 0.75}, - {label: '100%', value: 1}, - {label: '200%', value: 2} - ]); - assert.equal(target.scale, 0.25); - assert.equal(sel.selectedIndex, 2); - }); - - test('selectorSettingsDefault', function() { - var target = { - scale: 314 - }; - var sel = tr.ui.b.createSelector( - target, 'scale', - 'myScale', 0.375, - [{label: '6.25%', value: 0.0625}, - {label: '12.5%', value: 0.125}, - {label: '25%', value: 0.25}, - {label: '37.5%', value: 0.375}, - {label: '50%', value: 0.5}, - {label: '75%', value: 0.75}, - {label: '100%', value: 1}, - {label: '200%', value: 2} - ]); - assert.equal(target.scale, 0.375); - assert.equal(sel.selectedIndex, 3); - }); - - test('selectorSettingsChanged', function() { - var target = { - scale: 314 - }; - var sel = tr.ui.b.createSelector( - target, 'scale', - 'myScale', 0.375, - [{label: '6.25%', value: 0.0625}, - {label: '12.5%', value: 0.125}, - {label: '25%', value: 0.25}, - {label: '37.5%', value: 0.375}, - {label: '50%', value: 0.5}, - {label: '75%', value: 0.75}, - {label: '100%', value: 1}, - {label: '200%', value: 2} - ]); - assert.equal(sel.selectedValue, 0.375); - sel.selectedValue = 0.75; - assert.equal(target.scale, 0.75); - assert.equal(sel.selectedValue, 0.75); - assert.equal(undefined), 0.75, tr.b.Settings.get('myScale'); - }); - - test('asHTMLOrTextNode_string', function() { - // Default owner document. - var node = tr.ui.b.asHTMLOrTextNode('Hello, World!'); - assert.instanceOf(node, Node); - assert.equal(node.textContent, 'Hello, World!'); - assert.strictEqual(node.ownerDocument, document); - - // Custom owner document. - var node = tr.ui.b.asHTMLOrTextNode('Bye, World!', THIS_DOC); - assert.instanceOf(node, Node); - assert.equal(node.textContent, 'Bye, World!'); - assert.strictEqual(node.ownerDocument, THIS_DOC); - }); - - test('asHTMLOrTextNode_node', function() { - // Node object. Owner document should NOT be modified. - var node = document.createTextNode('Hi', THIS_DOC); - assert.strictEqual(tr.ui.b.asHTMLOrTextNode(node), node); - assert.strictEqual(node.ownerDocument, document); - - // HTMLElement object. Owner document should NOT be modified. - var node = THIS_DOC.createElement('div'); - assert.strictEqual(tr.ui.b.asHTMLOrTextNode(node), node); - assert.strictEqual(node.ownerDocument, THIS_DOC); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/drag_handle.html b/chromium/third_party/catapult/tracing/tracing/ui/base/drag_handle.html deleted file mode 100644 index d919bbbad93..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/drag_handle.html +++ /dev/null @@ -1,184 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/base/ui.html"> - -<polymer-element name="tr-ui-b-drag-handle"> - <template> - <style> - :host { - -webkit-user-select: none; - box-sizing: border-box; - display: block; - } - - :host(.horizontal-drag-handle) { - background-image: -webkit-gradient(linear, - 0 0, 0 100%, - from(#E5E5E5), - to(#D1D1D1)); - border-bottom: 1px solid #8e8e8e; - border-top: 1px solid white; - cursor: ns-resize; - flex: 0 0 auto; - height: 7px; - position: relative; - } - - :host(.vertical-drag-handle) { - background-image: -webkit-gradient(linear, - 0 0, 100% 0, - from(#E5E5E5), - to(#D1D1D1)); - border-left: 1px solid white; - border-right: 1px solid #8e8e8e; - cursor: ew-resize; - flex: 0 0 auto; - position: relative; - width: 7px; - } - </style> - </template> - <script> - 'use strict'; - - Polymer({ - __proto__: HTMLDivElement.prototype, - - created: function() { - this.lastMousePos_ = 0; - this.onMouseMove_ = this.onMouseMove_.bind(this); - this.onMouseUp_ = this.onMouseUp_.bind(this); - this.addEventListener('mousedown', this.onMouseDown_); - this.target_ = undefined; - this.horizontal = true; - this.observer_ = new WebKitMutationObserver( - this.didTargetMutate_.bind(this)); - this.targetSizesByModeKey_ = {}; - }, - - get modeKey_() { - return this.target_.className == '' ? '.' : this.target_.className; - }, - - get target() { - return this.target_; - }, - - set target(target) { - this.observer_.disconnect(); - this.target_ = target; - if (!this.target_) - return; - this.observer_.observe(this.target_, { - attributes: true, - attributeFilter: ['class'] - }); - }, - - get horizontal() { - return this.horizontal_; - }, - - set horizontal(h) { - this.horizontal_ = h; - if (this.horizontal_) - this.className = 'horizontal-drag-handle'; - else - this.className = 'vertical-drag-handle'; - }, - - get vertical() { - return !this.horizontal_; - }, - - set vertical(v) { - this.horizontal = !v; - }, - - forceMutationObserverFlush_: function() { - var records = this.observer_.takeRecords(); - if (records.length) - this.didTargetMutate_(records); - }, - - didTargetMutate_: function(e) { - var modeSize = this.targetSizesByModeKey_[this.modeKey_]; - if (modeSize !== undefined) { - this.setTargetSize_(modeSize); - return; - } - - // If we hadn't previously sized the target, then just remove any manual - // sizing that we applied. - this.target_.style[this.targetStyleKey_] = ''; - }, - - get targetStyleKey_() { - return this.horizontal_ ? 'height' : 'width'; - }, - - getTargetSize_: function() { - // If style is not set, start off with computed height. - var targetStyleKey = this.targetStyleKey_; - if (!this.target_.style[targetStyleKey]) { - this.target_.style[targetStyleKey] = - window.getComputedStyle(this.target_)[targetStyleKey]; - } - var size = parseInt(this.target_.style[targetStyleKey]); - this.targetSizesByModeKey_[this.modeKey_] = size; - return size; - }, - - setTargetSize_: function(s) { - this.target_.style[this.targetStyleKey_] = s + 'px'; - this.targetSizesByModeKey_[this.modeKey_] = s; - }, - - applyDelta_: function(delta) { - // Apply new size to the container. - var curSize = this.getTargetSize_(); - var newSize; - if (this.target_ === this.nextElementSibling) { - newSize = curSize + delta; - } else { - newSize = curSize - delta; - } - this.setTargetSize_(newSize); - }, - - onMouseMove_: function(e) { - // Compute the difference in height position. - var curMousePos = this.horizontal_ ? e.clientY : e.clientX; - var delta = this.lastMousePos_ - curMousePos; - - this.applyDelta_(delta); - - this.lastMousePos_ = curMousePos; - e.preventDefault(); - return true; - }, - - onMouseDown_: function(e) { - if (!this.target_) - return; - this.forceMutationObserverFlush_(); - this.lastMousePos_ = this.horizontal_ ? e.clientY : e.clientX; - document.addEventListener('mousemove', this.onMouseMove_); - document.addEventListener('mouseup', this.onMouseUp_); - e.preventDefault(); - return true; - }, - - onMouseUp_: function(e) { - document.removeEventListener('mousemove', this.onMouseMove_); - document.removeEventListener('mouseup', this.onMouseUp_); - e.preventDefault(); - } - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/drag_handle_test.html b/chromium/third_party/catapult/tracing/tracing/ui/base/drag_handle_test.html deleted file mode 100644 index bd52880503d..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/drag_handle_test.html +++ /dev/null @@ -1,94 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> -<link rel="import" href="/tracing/ui/base/drag_handle.html"> -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var createDragHandle = function() { - var el = document.createElement('div'); - el.style.border = '1px solid black'; - el.style.width = '200px'; - el.style.height = '200px'; - el.style.display = 'flex'; - el.style.flexDirection = 'column'; - - var upperEl = document.createElement('div'); - upperEl.style.flex = '1 1 auto'; - upperEl.style.minHeight = '0'; - - var lowerEl = document.createElement('div'); - lowerEl.style.height = '100px'; - - var dragHandle = document.createElement('tr-ui-b-drag-handle'); - dragHandle.target = lowerEl; - - el.appendChild(upperEl); - el.appendChild(dragHandle); - el.appendChild(lowerEl); - el.upperEl = upperEl; - el.dragHandle = dragHandle; - el.lowerEl = lowerEl; - - el.getLowerElHeight = function() { - return parseInt(getComputedStyle(this.lowerEl).height); - }; - return el; - }; - - test('instantiate', function() { - this.addHTMLOutput(createDragHandle()); - }); - - test('applyDelta', function() { - var el = createDragHandle(); - this.addHTMLOutput(el); - - var dragHandle = el.dragHandle; - var oldHeight = el.getLowerElHeight(); - dragHandle.applyDelta_(10); - assert.equal(el.getLowerElHeight(), oldHeight + 10); - }); - - test('classNameMutation', function() { - var el = createDragHandle(); - - var styleEl = document.createElement('style'); - styleEl.textContent = - '.mode-a { height: 100px; } .mode-b { height: 50px; }'; - document.head.appendChild(styleEl); - - this.addHTMLOutput(el); - - try { - var dragHandle = el.dragHandle; - el.lowerEl.className = 'mode-a'; - assert.equal(el.getLowerElHeight(), 100); - - dragHandle.applyDelta_(10); - assert.equal(el.getLowerElHeight(), 110); - - // Change the class, which should restore the layout - // to the default sizing for mode-b - el.lowerEl.className = 'mode-b'; - dragHandle.forceMutationObserverFlush_(); - assert.equal(el.getLowerElHeight(), 50); - - dragHandle.applyDelta_(10); - assert.equal(el.getLowerElHeight(), 60); - - // Restore the class-a, which should restore the layout - // to sizing when we were changed. - el.lowerEl.className = 'mode-a'; - dragHandle.forceMutationObserverFlush_(); - assert.equal(el.getLowerElHeight(), 110); - } finally { - document.head.removeChild(styleEl); - } - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/draw_helpers.html b/chromium/third_party/catapult/tracing/tracing/ui/base/draw_helpers.html deleted file mode 100644 index 981f16da3e6..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/draw_helpers.html +++ /dev/null @@ -1,419 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/base/event_presenter.html"> -<link rel="import" href="/tracing/base/sorted_array_utils.html"> -<link rel="import" href="/tracing/ui/base/elided_cache.html"> - -<script> -'use strict'; - -/** - * @fileoverview Provides various helper methods for drawing to a provided - * canvas. - */ -tr.exportTo('tr.ui.b', function() { - var elidedTitleCache = new tr.ui.b.ElidedTitleCache(); - var ColorScheme = tr.b.ColorScheme; - var colorsAsStrings = ColorScheme.colorsAsStrings; - - var EventPresenter = tr.ui.b.EventPresenter; - var blackColorId = ColorScheme.getColorIdForReservedName('black'); - - /** - * This value is used to allow for consistent style UI elements. - * Thread time visualisation uses a smaller rectangle that has this height. - * @const - */ - var THIN_SLICE_HEIGHT = 4; - - /** - * This value is used to for performance considerations when drawing large - * zoomed out traces that feature cpu time in the slices. If the waiting - * width is less than the threshold, we only draw the rectangle as a solid. - * @const - */ - var SLICE_WAITING_WIDTH_DRAW_THRESHOLD = 3; - - /** - * If the slice has mostly been waiting to be scheduled on the cpu, the - * wall clock will be far greater than the cpu clock. Draw the slice - * only as an idle slice, if the active width is not thicker than the - * threshold. - * @const - */ - var SLICE_ACTIVE_WIDTH_DRAW_THRESHOLD = 1; - - /** - * Should we elide text on trace labels? - * Without eliding, text that is too wide isn't drawn at all. - * Disable if you feel this causes a performance problem. - * This is a default value that can be overridden in tracks for testing. - * @const - */ - var SHOULD_ELIDE_TEXT = true; - - /** - * Draw the define line into |ctx|. - * - * @param {Context} ctx The context to draw into. - * @param {float} x1 The start x position of the line. - * @param {float} y1 The start y position of the line. - * @param {float} x2 The end x position of the line. - * @param {float} y2 The end y position of the line. - */ - function drawLine(ctx, x1, y1, x2, y2) { - ctx.moveTo(x1, y1); - ctx.lineTo(x2, y2); - } - - /** - * Draw the defined triangle into |ctx|. - * - * @param {Context} ctx The context to draw into. - * @param {float} x1 The first corner x. - * @param {float} y1 The first corner y. - * @param {float} x2 The second corner x. - * @param {float} y2 The second corner y. - * @param {float} x3 The third corner x. - * @param {float} y3 The third corner y. - */ - function drawTriangle(ctx, x1, y1, x2, y2, x3, y3) { - ctx.beginPath(); - ctx.moveTo(x1, y1); - ctx.lineTo(x2, y2); - ctx.lineTo(x3, y3); - ctx.closePath(); - } - - /** - * Draw an arrow into |ctx|. - * - * @param {Context} ctx The context to draw into. - * @param {float} x1 The shaft x. - * @param {float} y1 The shaft y. - * @param {float} x2 The head x. - * @param {float} y2 The head y. - * @param {float} arrowLength The length of the head. - * @param {float} arrowWidth The width of the head. - */ - function drawArrow(ctx, x1, y1, x2, y2, arrowLength, arrowWidth) { - var dx = x2 - x1; - var dy = y2 - y1; - var len = Math.sqrt(dx * dx + dy * dy); - var perc = (len - arrowLength) / len; - var bx = x1 + perc * dx; - var by = y1 + perc * dy; - var ux = dx / len; - var uy = dy / len; - var ax = uy * arrowWidth; - var ay = -ux * arrowWidth; - - ctx.beginPath(); - drawLine(ctx, x1, y1, x2, y2); - ctx.stroke(); - - drawTriangle(ctx, - bx + ax, by + ay, - x2, y2, - bx - ax, by - ay); - ctx.fill(); - } - - /** - * Draw the provided slices to the screen. - * - * Each of the elements in |slices| must provide the follow methods: - * * start - * * duration - * * colorId - * * selected - * - * @param {Context} ctx The canvas context. - * @param {TimelineDrawTransform} dt The draw transform. - * @param {float} viewLWorld The left most point of the world viewport. - * @param {float} viewRWorld The right most point of the world viewport. - * @param {float} viewHeight The height of the viewport. - * @param {Array} slices The slices to draw. - * @param {bool} async Whether the slices are drawn with async style. - */ - function drawSlices(ctx, dt, viewLWorld, viewRWorld, viewHeight, slices, - async) { - var pixelRatio = window.devicePixelRatio || 1; - var pixWidth = dt.xViewVectorToWorld(1); - var height = viewHeight * pixelRatio; - - var darkRectHeight = THIN_SLICE_HEIGHT * pixelRatio; - - // Not enough space for both colors, use light color only. - if (height < darkRectHeight) - darkRectHeight = 0; - - var lightRectHeight = height - darkRectHeight; - - // Begin rendering in world space. - ctx.save(); - dt.applyTransformToCanvas(ctx); - - var rect = new tr.ui.b.FastRectRenderer( - ctx, 2 * pixWidth, 2 * pixWidth, colorsAsStrings); - rect.setYandH(0, height); - - var lowSlice = tr.b.findLowIndexInSortedArray( - slices, - function(slice) { return slice.start + slice.duration; }, - viewLWorld); - - var hadTopLevel = false; - - for (var i = lowSlice; i < slices.length; ++i) { - var slice = slices[i]; - var x = slice.start; - if (x > viewRWorld) - break; - - var w = pixWidth; - if (slice.duration > 0) { - w = Math.max(slice.duration, 0.000001); - if (w < pixWidth) - w = pixWidth; - } - - var colorId = EventPresenter.getSliceColorId(slice); - var alpha = EventPresenter.getSliceAlpha(slice, async); - var lightAlpha = alpha * 0.70; - - if (async && slice.isTopLevel) { - rect.setYandH(3, height - 3); - hadTopLevel = true; - } else { - rect.setYandH(0, height); - } - - // If cpuDuration is available, draw rectangles proportional to the - // amount of cpu time taken. - if (!slice.cpuDuration) { - // No cpuDuration available, draw using only one alpha. - rect.fillRect(x, w, colorId, alpha); - continue; - } - - var activeWidth = w * (slice.cpuDuration / slice.duration); - var waitingWidth = w - activeWidth; - - // Check if we have enough screen space to draw the whole slice, with - // both color tones. - // - // Truncate the activeWidth to 0 if it is less than 'threshold' pixels. - if (activeWidth < SLICE_ACTIVE_WIDTH_DRAW_THRESHOLD * pixWidth) { - activeWidth = 0; - waitingWidth = w; - } - - // Truncate the waitingWidth to 0 if it is less than 'threshold' pixels. - if (waitingWidth < SLICE_WAITING_WIDTH_DRAW_THRESHOLD * pixWidth) { - activeWidth = w; - waitingWidth = 0; - } - - // We now draw the two rectangles making up the event slice. - // NOTE: The if statements are necessary for performance considerations. - // We do not want to force draws, if the width of the rectangle is 0. - // - // First draw the solid color, representing the 'active' part. - if (activeWidth > 0) { - rect.fillRect(x, activeWidth, colorId, alpha); - } - - // Next draw the two toned 'idle' part. - // NOTE: Substracting pixWidth and drawing one extra pixel is done to - // prevent drawing artifacts. Without it, the two parts of the slice, - // ('active' and 'idle') may appear split apart. - if (waitingWidth > 0) { - // First draw the light toned top part. - rect.setYandH(0, lightRectHeight); - rect.fillRect(x + activeWidth - pixWidth, - waitingWidth + pixWidth, colorId, lightAlpha); - // Then the solid bottom half. - rect.setYandH(lightRectHeight, darkRectHeight); - rect.fillRect(x + activeWidth - pixWidth, - waitingWidth + pixWidth, colorId, alpha); - // Reset for the next slice. - rect.setYandH(0, height); - } - } - rect.flush(); - - if (async && hadTopLevel) { - // Draw a top border over async slices in order to visually separate - // them from events above it. - // See https://github.com/google/trace-viewer/issues/725. - rect.setYandH(2, 1); - for (var i = lowSlice; i < slices.length; ++i) { - var slice = slices[i]; - var x = slice.start; - if (x > viewRWorld) - break; - - if (!slice.isTopLevel) - continue; - - var w = pixWidth; - if (slice.duration > 0) { - w = Math.max(slice.duration, 0.000001); - if (w < pixWidth) - w = pixWidth; - } - - rect.fillRect(x, w, blackColorId, 0.7); - } - rect.flush(); - } - - ctx.restore(); - } - - /** - * Draw the provided instant slices as lines to the screen. - * - * Each of the elements in |slices| must provide the follow methods: - * * start - * * duration with value of 0. - * * colorId - * * selected - * - * @param {Context} ctx The canvas context. - * @param {TimelineDrawTransform} dt The draw transform. - * @param {float} viewLWorld The left most point of the world viewport. - * @param {float} viewRWorld The right most point of the world viewport. - * @param {float} viewHeight The height of the viewport. - * @param {Array} slices The slices to draw. - * @param {Numer} lineWidthInPixels The width of the lines. - */ - function drawInstantSlicesAsLines( - ctx, dt, viewLWorld, viewRWorld, viewHeight, slices, lineWidthInPixels) { - var pixelRatio = window.devicePixelRatio || 1; - var height = viewHeight * pixelRatio; - - var pixWidth = dt.xViewVectorToWorld(1); - - // Begin rendering in world space. - ctx.save(); - ctx.lineWidth = pixWidth * lineWidthInPixels * pixelRatio; - dt.applyTransformToCanvas(ctx); - ctx.beginPath(); - - var lowSlice = tr.b.findLowIndexInSortedArray( - slices, - function(slice) { return slice.start; }, - viewLWorld); - - for (var i = lowSlice; i < slices.length; ++i) { - var slice = slices[i]; - var x = slice.start; - if (x > viewRWorld) - break; - - ctx.strokeStyle = EventPresenter.getInstantSliceColor(slice); - - ctx.beginPath(); - ctx.moveTo(x, 0); - ctx.lineTo(x, height); - ctx.stroke(); - } - ctx.restore(); - } - - /** - * Draws the labels for the given slices. - * - * The |slices| array must contain objects with the following API: - * * start - * * duration - * * title - * * didNotFinish (optional) - * - * @param {Context} ctx The graphics context. - * @param {TimelineDrawTransform} dt The draw transform. - * @param {float} viewLWorld The left most point of the world viewport. - * @param {float} viewRWorld The right most point of the world viewport. - * @param {Array} slices The slices to label. - * @param {bool} async Whether the slice labels are drawn with async style. - * @param {float} fontSize The font size. - * @param {float} yOffset The font offset. - */ - function drawLabels(ctx, dt, viewLWorld, viewRWorld, slices, async, - fontSize, yOffset) { - var pixelRatio = window.devicePixelRatio || 1; - var pixWidth = dt.xViewVectorToWorld(1); - - ctx.save(); - - ctx.textAlign = 'center'; - ctx.textBaseline = 'top'; - ctx.font = (fontSize * pixelRatio) + 'px sans-serif'; - - if (async) - ctx.font = 'italic ' + ctx.font; - - var cY = yOffset * pixelRatio; - - var lowSlice = tr.b.findLowIndexInSortedArray( - slices, - function(slice) { return slice.start + slice.duration; }, - viewLWorld); - - // Don't render text until until it is 20px wide - var quickDiscardThresshold = pixWidth * 20; - for (var i = lowSlice; i < slices.length; ++i) { - var slice = slices[i]; - if (slice.start > viewRWorld) - break; - - if (slice.duration <= quickDiscardThresshold) - continue; - - var title = slice.title + - (slice.didNotFinish ? ' (Did Not Finish)' : ''); - - var drawnTitle = title; - var drawnWidth = elidedTitleCache.labelWidth(ctx, drawnTitle); - var fullLabelWidth = elidedTitleCache.labelWidthWorld( - ctx, drawnTitle, pixWidth); - if (SHOULD_ELIDE_TEXT && fullLabelWidth > slice.duration) { - var elidedValues = elidedTitleCache.get( - ctx, pixWidth, - drawnTitle, drawnWidth, - slice.duration); - drawnTitle = elidedValues.string; - drawnWidth = elidedValues.width; - } - - if (drawnWidth * pixWidth < slice.duration) { - ctx.fillStyle = EventPresenter.getTextColor(slice); - var cX = dt.xWorldToView(slice.start + 0.5 * slice.duration); - ctx.fillText(drawnTitle, cX, cY, drawnWidth); - } - } - ctx.restore(); - } - - return { - drawSlices: drawSlices, - drawInstantSlicesAsLines: drawInstantSlicesAsLines, - drawLabels: drawLabels, - - drawLine: drawLine, - drawTriangle: drawTriangle, - drawArrow: drawArrow, - - elidedTitleCache_: elidedTitleCache, - - THIN_SLICE_HEIGHT: THIN_SLICE_HEIGHT - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/dropdown.html b/chromium/third_party/catapult/tracing/tracing/ui/base/dropdown.html deleted file mode 100644 index 2d0fe220eef..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/dropdown.html +++ /dev/null @@ -1,158 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/base.html"> - -<polymer-element name="tr-ui-b-dropdown"> - <template> - <style> - :host { - position: relative; - display: flex; - } - #outer { - display: flex; - flex: 0 0 auto; - padding: 1px 4px 1px 4px; - -webkit-user-select: none; - cursor: default; - } - - #state { - display: flex; - flex: 0 0 auto; - margin-left: 2px; - margin-right: 0px; - flex: 0 0 auto; - } - - #icon { - display: flex; - flex: 0 0 auto; - flex: 0 0 auto; - } - dialog { - position: absolute; - padding: 0; - border: 0; - margin: 0; - } - dialog::backdrop { - background: rgba(0,0,0,.05); - } - - #dialog-frame { - background-color: #fff; - display: flex; - flex-direction: column; - flex: 1 1 auto; - padding: 6px; - border: 1px solid black; - -webkit-user-select: none; - cursor: default; - } - </style> - <tr-ui-b-toolbar-button id="outer" - on-keydown="{{ onOuterKeyDown_ }}" - on-click="{{ onOuterClick_ }}"> - <div id="icon">⚙</div> - <div id="state">▾</div> - </tr-ui-b-toolbar-button> - <dialog id="dialog" - on-click="{{ onDialogClick_ }}" - on-cancel="{{ onDialogCancel_ }}"> - <div id="dialog-frame"> - <content></content> - </div> - </dialog> - </template> - <script> - 'use strict'; - - Polymer({ - ready: function() { - this.$.outer.tabIndex = 0; - }, - - get iconElement() { - return this.$.icon; - }, - - onOuterKeyDown_: function(e) { - if (e.keyCode === ' '.charCodeAt(0)) { - this.toggle_(); - e.preventDefault(); - e.stopPropagation(); - } - }, - - onOuterClick_: function(e) { - var or = this.$.outer.getBoundingClientRect(); - var inside = true; - inside &= e.clientX >= or.left; - inside &= e.clientX < or.right; - inside &= e.clientY >= or.top; - inside &= e.clientY < or.bottom; - if (!inside) - return; - - e.preventDefault(); - this.toggle_(); - }, - - toggle_: function() { - if (!this.isOpen) - this.show(); - else - this.close(); - }, - - show: function() { - if (this.isOpen) - return; - - this.$.outer.classList.add('open'); - - var ddr = this.$.outer.getBoundingClientRect(); - var rW = Math.max(ddr.width, 150); - this.$.dialog.style.minWidth = rW + 'px'; - this.$.dialog.showModal(); - - var ddw = this.$.outer.getBoundingClientRect().width; - var w = this.$.dialog.getBoundingClientRect().width; - this.$.dialog.style.top = ddr.bottom - 1 + 'px'; - this.$.dialog.style.left = ddr.left + 'px'; - }, - - onDialogClick_: function(e) { - if (!this.isOpen) - return; - if (e.srcElement !== this.$.dialog) - return; - e.preventDefault(); - this.close(); - }, - - onDialogCancel_: function(e) { - e.preventDefault(); - this.close(); - }, - - close: function() { - if (!this.isOpen) - return; - this.$.dialog.close(); - this.$.outer.classList.remove('open'); - this.$.outer.focus(); - }, - - get isOpen() { - return this.$.dialog.hasAttribute('open'); - } - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/dropdown_test.html b/chromium/third_party/catapult/tracing/tracing/ui/base/dropdown_test.html deleted file mode 100644 index 8801a927a1f..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/dropdown_test.html +++ /dev/null @@ -1,38 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/base/dropdown.html"> -<link rel="import" href="/tracing/ui/base/dom_helpers.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - test('basic', function() { - var dd = document.createElement('tr-ui-b-dropdown'); - dd.style.marginLeft = '50px'; - dd.style.width = '50px'; - dd.iconElement.textContent = 'Settings ' + String.fromCharCode(0x2699); - - dd.appendChild(tr.ui.b.createDiv({textContent: 'item 1'})); - dd.appendChild(tr.ui.b.createDiv({textContent: 'item 2 longer'})); - dd.appendChild(tr.ui.b.createDiv({textContent: 'item 3'})); - - var container = tr.ui.b.createDiv(); - container.style.height = '100px'; - container.appendChild(dd); - container.appendChild(tr.ui.b.createDiv({textContent: 'some text'})); - container.appendChild(tr.ui.b.createDiv({textContent: 'some more text'})); - container.appendChild(tr.ui.b.createDiv({textContent: 'more text'})); - this.addHTMLOutput(container); - - dd.show(); - dd.close(); - }); - -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/elided_cache.html b/chromium/third_party/catapult/tracing/tracing/ui/base/elided_cache.html deleted file mode 100644 index 7019f9807da..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/elided_cache.html +++ /dev/null @@ -1,113 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> -<link rel="import" href="/tracing/base/base.html"> -<script> -'use strict'; - -/** - * @fileoverview Provides a caching layer for elided text values. - */ -tr.exportTo('tr.ui.b', function() { - /** - * Cache for elided strings. - * Moved from the ElidedTitleCache protoype to a "global" for speed - * (variable reference is 100x faster). - * key: String we wish to elide. - * value: Another dict whose key is width - * and value is an ElidedStringWidthPair. - */ - var elidedTitleCacheDict = {}; - var elidedTitleCache = new ElidedTitleCache(); - - /** - * A cache for elided strings. - * @constructor - */ - function ElidedTitleCache() { - // TODO(jrg): possibly obsoleted with the elided string cache. - // Consider removing. - this.textWidthMap = {}; - } - - ElidedTitleCache.prototype = { - /** - * Return elided text. - * - * @param {ctx} Context The graphics context. - * @param {pixWidth} Pixel width. - * @param {title} Original title text. - * @param {width} Drawn width in world coords. - * @param {sliceDuration} Where the title must fit (in world coords). - * @return {ElidedStringWidthPair} Elided string and width. - */ - get: function(ctx, pixWidth, title, width, sliceDuration) { - var elidedDict = elidedTitleCacheDict[title]; - if (!elidedDict) { - elidedDict = {}; - elidedTitleCacheDict[title] = elidedDict; - } - - var elidedDictForPixWidth = elidedDict[pixWidth]; - if (!elidedDictForPixWidth) { - elidedDict[pixWidth] = {}; - elidedDictForPixWidth = elidedDict[pixWidth]; - } - - var stringWidthPair = elidedDictForPixWidth[sliceDuration]; - if (stringWidthPair === undefined) { - var newtitle = title; - var elided = false; - while (this.labelWidthWorld(ctx, newtitle, pixWidth) > sliceDuration) { - if (newtitle.length * 0.75 < 1) - break; - newtitle = newtitle.substring(0, newtitle.length * 0.75); - elided = true; - } - - if (elided && newtitle.length > 3) - newtitle = newtitle.substring(0, newtitle.length - 3) + '...'; - - stringWidthPair = new ElidedStringWidthPair( - newtitle, this.labelWidth(ctx, newtitle)); - elidedDictForPixWidth[sliceDuration] = stringWidthPair; - } - return stringWidthPair; - }, - - quickMeasureText_: function(ctx, text) { - var w = this.textWidthMap[text]; - if (!w) { - w = ctx.measureText(text).width; - this.textWidthMap[text] = w; - } - return w; - }, - - labelWidth: function(ctx, title) { - return this.quickMeasureText_(ctx, title) + 2; - }, - - labelWidthWorld: function(ctx, title, pixWidth) { - return this.labelWidth(ctx, title) * pixWidth; - } - }; - - /** - * A pair representing an elided string and world-coordinate width - * to draw it. - * @constructor - */ - function ElidedStringWidthPair(string, width) { - this.string = string; - this.width = width; - } - - return { - ElidedTitleCache: ElidedTitleCache - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/event_presenter.html b/chromium/third_party/catapult/tracing/tracing/ui/base/event_presenter.html deleted file mode 100644 index 68497381687..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/event_presenter.html +++ /dev/null @@ -1,93 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2012 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/color_scheme.html"> -<link rel="import" href="/tracing/model/selection_state.html"> - -<script> -'use strict'; - -/** - * @fileoverview Provides color scheme related functions. - */ -tr.exportTo('tr.ui.b', function() { - var ColorScheme = tr.b.ColorScheme; - - var colors = ColorScheme.colors; - var colorsAsStrings = ColorScheme.colorsAsStrings; - var numColorsPerVariant = ColorScheme.properties.numColorsPerVariant; - - var SelectionState = tr.model.SelectionState; - - /** - * Provides methods to get view values for events. - */ - var EventPresenter = { - getSelectableItemColorAsString: function(item) { - var colorId = item.colorId + this.getColorIdOffset_(item); - return colorsAsStrings[colorId]; - }, - - getColorIdOffset_: function(event) { - return event.selectionState; - }, - - getTextColor: function(event) { - if (event.selectionState === SelectionState.DIMMED) - return 'rgb(60,60,60)'; - return 'rgb(0,0,0)'; - }, - - getSliceColorId: function(slice) { - return slice.colorId + this.getColorIdOffset_(slice); - }, - - getSliceAlpha: function(slice, async) { - var alpha = 1; - if (async) - alpha *= 0.3; - return alpha; - }, - - getInstantSliceColor: function(instant) { - var colorId = instant.colorId + this.getColorIdOffset_(instant); - return colors[colorId].toStringWithAlphaOverride(1.0); - }, - - getObjectInstanceColor: function(instance) { - var colorId = instance.colorId + this.getColorIdOffset_(instance); - return colors[colorId].toStringWithAlphaOverride(0.25); - }, - - getObjectSnapshotColor: function(snapshot) { - var colorId = - snapshot.objectInstance.colorId + this.getColorIdOffset_(snapshot); - return colors[colorId]; - }, - - getCounterSeriesColor: function(colorId, selectionState, - opt_alphaMultiplier) { - var event = {selectionState: selectionState}; - var c = colors[colorId + this.getColorIdOffset_(event)]; - return c.toStringWithAlphaOverride( - opt_alphaMultiplier !== undefined ? opt_alphaMultiplier : 1.0); - }, - - getBarSnapshotColor: function(snapshot, offset) { - var colorId = - (snapshot.objectInstance.colorId + offset) % - numColorsPerVariant; - colorId += this.getColorIdOffset_(snapshot); - return colors[colorId].toStringWithAlphaOverride(1.0); - } - }; - - return { - EventPresenter: EventPresenter - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/fast_rect_renderer.html b/chromium/third_party/catapult/tracing/tracing/ui/base/fast_rect_renderer.html deleted file mode 100644 index 1729596fc95..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/fast_rect_renderer.html +++ /dev/null @@ -1,134 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2012 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> -<link rel="import" href="/tracing/base/base.html"> -<script> -'use strict'; - -/** - * @fileoverview Provides a mechanism for drawing massive numbers of - * colored rectangles into a canvas in an efficient manner, provided - * they are drawn left to right with fixed y and height throughout. - * - * The basic idea used here is to fuse subpixel rectangles together so that - * we never issue a canvas fillRect for them. It turns out Javascript can - * do this quite efficiently, compared to asking Canvas2D to do the same. - * - * A few extra things are done by this class in the name of speed: - * - Viewport culling: off-viewport rectangles are discarded. - * - * - The actual discarding operation is done in world space, - * e.g. pre-transform. - * - * - Rather than expending compute cycles trying to figure out an average - * color for fused rectangles from css strings, you instead draw using - * palletized colors. The fused rect color is choosen from the rectangle with - * the higher alpha value, if equal the max pallete index encountered. - * - * Make sure to flush the trackRenderer before finishing drawing in order - * to commit any queued drawing operations. - */ -tr.exportTo('tr.ui.b', function() { - - /** - * Creates a fast rect renderer with a specific set of culling rules - * and color pallette. - * @param {GraphicsContext2D} ctx Canvas2D drawing context. - * @param {number} minRectSize Only rectangles with width < minRectSize are - * considered for merging. - * @param {number} maxMergeDist Controls how many successive small rectangles - * can be merged together before issuing a rectangle. - * @param {Array} pallette The color pallete for drawing. Pallette slots - * should map to valid Canvas fillStyle strings. - * - * @constructor - */ - function FastRectRenderer(ctx, minRectSize, maxMergeDist, pallette) { - this.ctx_ = ctx; - this.minRectSize_ = minRectSize; - this.maxMergeDist_ = maxMergeDist; - this.pallette_ = pallette; - } - - FastRectRenderer.prototype = { - y_: 0, - h_: 0, - merging_: false, - mergeStartX_: 0, - mergeCurRight_: 0, - mergedColorId_: 0, - mergedAlpha_: 0, - - /** - * Changes the y position and height for subsequent fillRect - * calls. x and width are specifieid on the fillRect calls. - */ - setYandH: function(y, h) { - if (this.y_ === y && - this.h_ === h) - return; - this.flush(); - this.y_ = y; - this.h_ = h; - }, - - /** - * Fills rectangle at the specified location, if visible. If the - * rectangle is subpixel, it will be merged with adjacent rectangles. - * The drawing operation may not take effect until flush is called. - * @param {number} colorId The color of this rectangle, as an index - * in the renderer's color pallete. - * @param {number} alpha The opacity of the rectangle as 0.0-1.0 number. - */ - fillRect: function(x, w, colorId, alpha) { - var r = x + w; - if (w < this.minRectSize_) { - if (r - this.mergeStartX_ > this.maxMergeDist_) - this.flush(); - if (!this.merging_) { - this.merging_ = true; - this.mergeStartX_ = x; - this.mergeCurRight_ = r; - this.mergedColorId_ = colorId; - this.mergedAlpha_ = alpha; - } else { - this.mergeCurRight_ = r; - - if (this.mergedAlpha_ < alpha || - (this.mergedAlpha_ === alpha && this.mergedColorId_ < colorId)) { - this.mergedAlpha_ = alpha; - this.mergedColorId_ = colorId; - } - } - } else { - if (this.merging_) - this.flush(); - this.ctx_.fillStyle = this.pallette_[colorId]; - this.ctx_.globalAlpha = alpha; - this.ctx_.fillRect(x, this.y_, w, this.h_); - } - }, - - /** - * Commits any pending fillRect operations to the underlying graphics - * context. - */ - flush: function() { - if (this.merging_) { - this.ctx_.fillStyle = this.pallette_[this.mergedColorId_]; - this.ctx_.globalAlpha = this.mergedAlpha_; - this.ctx_.fillRect(this.mergeStartX_, this.y_, - this.mergeCurRight_ - this.mergeStartX_, this.h_); - this.merging_ = false; - } - } - }; - - return { - FastRectRenderer: FastRectRenderer - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/favicons.html b/chromium/third_party/catapult/tracing/tracing/ui/base/favicons.html deleted file mode 100644 index 66e74de6f65..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/favicons.html +++ /dev/null @@ -1,27 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2012 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/base.html"> - -<script> -'use strict'; -tr.exportTo('tr.ui.b', function() { - var FaviconsByHue = { - blue: 'data:image/vndmicrosofticon;base64,AAABAAIAEBAAAAEAIABoBAAAJgAAACAgAAABACAAqBAAAI4EAAAoAAAAEAAAACAAAAABACAAAAAAAAAEAAASCwAAEgsAAAAAAAAAAAAAAAAAAAAAAAAAAAAAjj8xAGArIgqOPzE8nUY3dqJJOJeiSTiXnUY3do4/MTxhKyIKjkAxAAAAAAAAAAAAAAAAAAAAAABQJBwAAAAAAZJBMzSoSzqlsU8+6bRQP/21UT//tVE//7RQP/2wTz3ppko6pY9AMjQAAAABTyMbAAAAAAB7e3sAAP//AKFSRE+wTz3dtVE//7VRP/+1UT//tVE//7VRP/+zUD7/sE89/7BOPf+qTDvdl0M0TwAAAABWJx4A+fn5ANjd3TnIiX7ftVA9/7VRP/+1UT//tVE//7VRP/+xTz3/rE08/6xMO/+sTDv/rE08/6dKOt+SQTM5q0w7ALO0tA3v8fGu05uR/7NMOf+0Tzz/tE88/7RPPv+uTT3/p0o7/6ZJOv+mSTr/pkk6/6ZJOv+mSjr/n0Y4rnIwKg3h4eFK9/j48N2zrP/FeGr/xnps/8Z6bP/AaUv/tlw1/7RbNf+1WzX/tFs1/7RbNf+0WzX/tFs1/7NbNPCqWy1K7e3tjPn5+f/49vX/9vLy//by8v/28vH/8bZv/+6RH//ukyP/7pMj/+6SI//ukiP/7pMj/+2SIv/qjyL/34kfjPHx8bL5+fn/+fn5//n5+f/5+fr/+fn5//W7cP/zlB3/85Yh//OWIf/zliH/85Yh//GVIf/rkR//6ZAf/+KLHrLz8/O2+fn5//n5+f/5+fn/+fn5//n5+f/1unD/85Qd//OWIf/zliH/85Yh//CUIP/mjh//44we/+OMHv/diR628vLymfn5+f/5+fn/+fn5//n5+f/5+fn/9bx0//OXI//zmCb/85gm/++VIv/hjB//3Yoe/92KHv/dih7/2IYdmfHx8Vz4+Pj3+fn5//n5+f/5+fn/+fn5//jo0//33bv/9929//bbtf/euDX/06oJ/9OrC//Tqwv/06oM98yfD1zr6+sY9/f3xvn5+f/5+fn/+fn5//n5+f/5+vv/+fv8//n7/f/3+PH/3Ms6/9O8AP/UvQD/1L0A/9K8AMbItAAY////APT09Fb4+Pjy+fn5//n5+f/5+fn/+fn5//n5+f/5+fr/9/bu/9zKOf/TuwD/1LwA/9S8APLQuABW3cQAAOzs7ADm5uYF9vb2ePn5+fT5+fn/+fn5//n5+f/5+fn/+fn6//f27v/cyTn/07sA/9S8APTRugB4w60ABcmyAAAAAAAA8PDwAOzs7Ab29vZd+Pj40vn5+fz5+fn/+fn5//n5+f/49/H/5Ndu/NjEIdLSugBdybIABsy1AAAAAAAAAAAAAAAAAADn5+cAqKioAPT09CH39/dy+Pj4tvj4+NX4+PjV+Pj4tvX063Lt6MMhOQAAAM+/RAAAAAAAAAAAAPAPAADAAwAAwAMAAIABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIABAACAAQAAwAMAAPAPAAAoAAAAIAAAAEAAAAABACAAAAAAAAAQAAASCwAAEgsAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABCwUEDDgZExxWJx4tYiwiN2IsIjdWJx4tOBkTHAsFBAwAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP///wAbDAkKZS0jMYs+MWydRjeipko6x6tMO9utTTzjrU0846tMO9umSjrHnUY3oos+MWxlLSMxGwwJCv///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgZFAAPBwUHcjMoPJtFNpqsTTzhs1A+/LVRP/+2UT//tVE//7VRP/+1UT//tVE//7ZRP/+1UT//s1A+/KxNPOGbRTaacTInPA8HBQc4GRMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/yp4AUCQcGZVDNICtTjzktVE//7VRP/+1UT//tVE//7VRP/+1UT//tVE//7VRP/+1UT//tVE//7VRP/+0UT//s1A+/7JQPv+rTDvkkkEzgE8jGxn/xZoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAA////AGswJSqiSTivs1A++7VRP/+1UT//tVE//7VRP/+1UT//tVE//7VRP/+1UT//tVE//7VRP/+1UT//tFA+/7FPPf+xTz3/sU89/7FPPf+vTj37nkc3r2guJCr///8AAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwMDAP/DogB/VEwsqE09v7VRP/+1UT//tVE//7VRP/+1UT//tVE//7VRP/+1UT//tVE//7VRP/+1UT//tVE//7NQPv+vTj3/r049/69OPf+vTj3/r049/69OPf+uTjz/oUg4v20xJiz/nnsAAgEBAAAAAAAAAAAAAAAAAAAAAAD19fUAkp2fHdK2sbW5W0r/tVA+/7VRP/+1UT//tVE//7VRP/+1UT//tVE//7VRP/+1UT//tVE//7VRP/+yUD7/rU08/6xNPP+tTTz/rU08/61NPP+tTTz/rU08/61NPP+sTTz/nkY3tWAqIR2pSzsAAAAAAAAAAAAAAAAAeXl5ADY2Ngnd39+O6tbT/blbSv+1UD7/tVE//7VRP/+1UT//tVE//7VRP/+1UT//tVE//7VRP/+1UT//slA+/6xNPP+rTDv/q0w7/6tMO/+rTDv/q0w7/6tMO/+rTDv/q0w7/6tMO/+qTDv9lkM0jiUQDQlSJR0AAAAAAAAAAAD///8AxMTES/X29u3s2NX/uVtK/7VQPv+1UT//tVE//7VRP/+1UT//tVE//7VRP/+1UT//tVE//7FPPv+qTDv/qEs6/6hLOv+oSzr/qEs6/6hLOv+oSzr/qEs6/6hLOv+oSzr/qEs6/6lLOv+lSTnthDsuS/+TcgAAAAAAm5ubAHBwcA/o6Oix+vv8/+zY1P+5W0r/tVA+/7VRP/+1UT//tVE//7VRP/+1UT//tVE//7VRP/+xTz3/qEs6/6ZKOv+mSjr/pko6/6ZKOv+mSjr/pko6/6ZKOv+mSjr/pko6/6ZKOv+mSjr/pko6/6ZKOv+bRTaxSiEaD2cuJAD///8AycnJRfX19fD6+/z/69fU/7hYR/+0Tjv/tE48/7ROPP+0Tjz/tE48/7ROPP+0Tz3/r04+/6VJOv+jSDn/o0g5/6NIOf+jSDn/o0g5/6NIOf+jSDn/o0g5/6NIOf+jSDr/o0g5/6NIOf+jSDn/o0g6/6BHOfCCOS9F0FxKAAAAAALk5OSN+fn5//n6+v/y5+X/05uS/9CTiP/QlIn/0JSJ/9CUif/QlIn/0JSK/8yGb//AaDb/vWc0/71nNf+9ZzT/vWc0/71nNP+9ZjT/vWY0/71mNP+9ZjT/vGY0/7xmNP+8ZjT/vGY0/7xmNP+8ZjT/u2U0/7FiLY0AAAACk5OTFu/v78X5+fn/+fn5//n5+f/5+vr/+fn5//n5+f/5+fn/+fn5//n5+f/5+/3/99iy//KWI//ylSH/8ZUh//GVIf/xlSH/8ZUh//GVIf/xlSH/8ZUh//GVIf/xlSH/8ZUh//GVIf/xlSH/8ZUh//CUIf/vkyD/5Y0fxY1XExbDw8Mz9PT05fn5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n7/f/32LL/85cj//OWIf/zliH/85Yh//OWIf/zliH/85Yh//OWIf/zliH/85Yh//OWIf/zliH/85Yh//OWIf/wlCD/7pIg/+6SIP/pjx/lunIZM9XV1VD39/f0+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fv9//fYsv/zlyP/85Yh//OWIf/zliH/85Yh//OWIf/zliH/85Yh//OWIf/zliH/85Yh//OWIf/zliH/75Mg/+uRH//qkB//6pAf/+iPH/TIfBtQ3d3dYfj4+Pn5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+/3/99iy//OXI//zliH/85Yh//OWIf/zliH/85Yh//OWIf/zliH/85Yh//OWIf/zliH/85Yh/+6TIP/ojx//548f/+ePH//njx//5o4f+c1/HGHh4eFl+Pj4+vn5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n7/f/32LL/85cj//OWIf/zliH/85Yh//OWIf/zliH/85Yh//OWIf/zliH/85Yh//OWIf/tkiD/5Y0f/+SNH//ljR//5Y0f/+WNH//kjB/6zn8cZeDg4Fr4+Pj3+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fv9//fYsv/zlyP/85Yh//OWIf/zliH/85Yh//OWIf/zliH/85Yh//OWIf/zliH/65Eg/+KMHv/iix7/4ose/+KLHv/iix7/4ose/+CLHvfLfRta3NzcQvf39+/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+/3/99iy//OXI//zliH/85Yh//OWIf/zliH/85Yh//OWIf/zliH/85Yh/+qRIP/gih7/34oe/9+KHv/fih7/34oe/9+KHv/fih7/3Yge78V6GkLS0tIj9fX12fn5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n7/f/32LH/85Yg//OVHv/zlR7/85Ue//OVHv/zlR7/85Ue//OVIf/pjyH/3ogf/92HH//dhx//3Ycf/92HH//dhx//3Ycf/92HH//ahh7ZunMZI56engjy8vKu+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fr7//jr2f/2ypL/9smP//bJkP/2yZD/9smQ//bJkP/2yZD/5rNI/9OeFP/SnhX/0p4V/9KeFf/SnhX/0Z0V/9GdFf/RnRX/0Z0V/8yWFq6KVBcI////AO3t7Wr5+fn++fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn6//n6/P/5+vz/+fr8//n6/P/5+vz/+fr8//n6/P/h013/0rsA/9O8AP/TvAD/07wA/9O8AP/TvAD/07wA/9O8AP/SvAD+yLMAav/mAADr6+sA4eHhJPb29tv5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5/+LSW//TuwD/1LwA/9S8AP/UvAD/1LwA/9S8AP/UvAD/1LwA/9K6ANu/qgAkyLEAALu7uwAAAAAA8vLygfn5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/4tJb/9O7AP/UvAD/1LwA/9S8AP/UvAD/1LwA/9S8AP/UvAD/zrYAgQAAAACfjQAAAAAAAOzs7ADk5OQe9vb2zPn5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/i0lv/07sA/9S8AP/UvAD/1LwA/9S8AP/UvAD/1LwA/9K6AMzCrAAeybIAAAAAAAAAAAAAsLCwAP///wDv7+9O+Pj47Pn5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5/+LSW//TuwD/1LwA/9S8AP/UvAD/1LwA/9S8AP/TuwDsy7QATu7UAACXhQAAAAAAAAAAAAAAAAAA1tbWALS0tAPy8vJv+Pj49Pn5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/4tJb/9O7AP/UvAD/1LwA/9S8AP/UvAD/07wA9M63AG6ZiQADtqIAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4uLiANfX1wbz8/Nz+Pj48Pn5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/i0lv/07sA/9S8AP/UvAD/1LwA/9O8APDPuABzuKMABsGrAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4+PjANjY2ATy8vJZ+Pj42vn5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5/+HSW//TugD/1LsA/9S8AP/TuwDazrcAWbejAATBqwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA1NTUAB8fHwDw8PAr9vb2nPj4+O35+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/7uas/+bZdv/j1mvt2cYznMu0ACsUFAAAtaEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOvr6wDj4+MG8vLyOvb29pD4+PjS+fn58vn5+f35+fn/+fn5//n5+f/5+fn/+fn5/fn5+fL4+frS9/j8kPT1/Trs8v8G8PP/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADh4eEA1tbWAu/v7xv09PRJ9vb2dvb29pf39/eo9/f3qPb29pf29vZ29PT0Se/v7xvW1tYC4eHhAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP/gB///gAH//gAAf/wAAD/4AAAf8AAAD+AAAAfAAAADwAAAA4AAAAGAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAGAAAABwAAAA8AAAAPgAAAH4AAAB/AAAA/4AAAf/gAAf/8AAP//wAP/', // @suppress longLineCheck - - green: 'data:image/vndmicrosofticon;base64,AAABAAIAEBAAAAEAIABoBAAAJgAAACAgAAABACAAqBAAAI4EAAAoAAAAEAAAACAAAAABACAAAAAAAAAEAAASCwAAEgsAAAAAAAAAAAAAAAAAAAAAAAAAAAAAbWJLAEpCMwptYks8eWxTdn1wVpd9cFaXeWxTdm1iSzxKQzMKbWJLAAAAAAAAAAAAAAAAAAAAAAA+OCsAAAAAAXBlTTSBdFmliHpe6Yp8X/2LfWD/i31g/4p8X/2HeV3pf3NYpW5jTDQAAAABPTcqAAAAAAB7e3sAlv//AIB1Xk+HeV3di31g/4t9YP+LfWD/i31g/4t9YP+Je1//h3pd/4d5Xf+DdVrddGhQTwAAAABDPC4A+fn5ANrb3DmupZPfinxf/4t9YP+LfWD/i31g/4t9YP+Iel7/hHdb/4R2W/+Edlv/hHdb/4BzWN9wZU05g3ZaALS0tA3w8PGuu7Sj/4h5W/+Je17/iXte/4t8X/+HeFz/gnNY/4FyWP+Bclj/gXJY/4FyWP+Bclj/fG1Url9NPA3h4eFK9/j48MvFuf+kmoP/ppuF/6abhf+JkHL/c4Rj/3OEY/9zhGP/coNj/3KDY/9yg2P/coNj/3CDYvBgf19K7e3tjPn5+f/39vb/9fTz//X08//09PP/itKw/0m+h/9Mv4n/TL+J/0y/if9Mv4n/TL+J/0y+iP9Lu4b/RrJ/jPHx8bL5+fn/+fn5//n5+f/5+fn/+fn5/4rXtP9Hwon/SsOL/0rDi/9Kw4v/SsOL/0nCiv9HvYb/RruF/0S1gbLz8/O2+fn5//n5+f/5+fn/+fn5//n5+f+K17P/R8KJ/0rDi/9Kw4v/SsOL/0nBif9GuYT/RbaC/0W2gv9Dsn+28vLymfn5+f/5+fn/+fn5//n5+f/5+fn/jdi1/0vDjP9OxI7/TsSO/0rAiv9FtoP/RLKA/0SygP9EsoD/Qq59mfHx8Vz4+Pj3+fn5//n5+f/5+fn/+fn5/9rw5v/H6tn/yOra/8Lp2f9e1b7/O8yz/z3MtP89zLT/Pcuy9zzApVzr6+sY9/f3xvn5+f/5+fn/+fn5//n5+f/7+vr//Pr7//z6+//z+fn/ZuPY/zbczv853c7/Od3O/zjbzcY10sYY////APT09Fb4+Pjy+fn5//n5+f/5+fn/+fn5//n5+f/6+fn/8Pj3/2Xj1/823Mz/OdzN/znczfI42MlWO+XWAOzs7ADm5uYF9vb2ePn5+fT5+fn/+fn5//n5+f/5+fn/+vn5//D49/9j4tf/NdvM/znczfQ42ct4Ncu9BTbRwgAAAAAA8PDwAOzs7Ab29vZd+Pj40vn5+fz5+fn/+fn5//n5+f/z+Pj/jung/FLf0tI42ctdNdHCBjfUxgAAAAAAAAAAAAAAAADn5+cAqKioAPT09CH39/dy+Pj4tvj4+NX4+PjV+Pj4tu329XLO7+whAFQmAGrUygAAAAAAAAAAAPAPAADAAwAAwAMAAIABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIABAACAAQAAwAMAAPAPAAAoAAAAIAAAAEAAAAABACAAAAAAAAAQAAASCwAAEgsAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABCQgGDCsmHRxCOy4tS0M0N0tDNDdCOy4tKyYdHAkIBgwAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP///wAVEg4KTUU1MWtgSmx5bVOigHNYx4N2W9uFd1zjhXdc44N2W9uAc1jHeW1TomtgSmxNRjUxFRMOCv///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACsnHgALCggHWE88PHdrUpqEd1vhiXxf/It9YP+LfWD/i31g/4t9YP+LfWD/i31g/4t9YP+LfWD/iXxf/IR3W+F3a1KaV048PAsKCAcrJx4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///AAPjcqGXJnT4CFeFzki31g/4t9YP+LfWD/i31g/4t9YP+LfWD/i31g/4t9YP+LfWD/i31g/4t9YP+KfWD/iXxf/4l7Xv+DdlrkcGVNgDw2Khn//+sAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////AFJKOSp9cFavinxf+4t9YP+LfWD/i31g/4t9YP+LfWD/i31g/4t9YP+LfWD/i31g/4t9YP+LfWD/inxf/4h6Xv+Iel3/iHpd/4h6Xv+GeV37eW1Ur1BINyr///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwMDAP//3gBsZ1osgnVbv4t9YP+LfWD/i31g/4t9YP+LfWD/i31g/4t9YP+LfWD/i31g/4t9YP+LfWD/i31g/4l8X/+HeV3/hnlc/4Z5XP+GeVz/hnlc/4Z5XP+GeFz/fG9Vv1RLOiz/9LoAAgIBAAAAAAAAAAAAAAAAAAAAAAD19fUAl5ibHcbCurWShGn/i31g/4t9YP+LfWD/i31g/4t9YP+LfWD/i31g/4t9YP+LfWD/i31g/4t9YP+Je1//hXhc/4R3W/+Fd1v/hXdb/4V3W/+Fd1v/hXdb/4V3W/+Ed1v/eW1TtUlCMh2CdVkAAAAAAAAAAAAAAAAAeXl5ADY2Ngne3t+O4t/Z/ZKFaf+LfV//i31g/4t9YP+LfWD/i31g/4t9YP+LfWD/i31g/4t9YP+LfWD/iXte/4R3W/+Ddlr/g3Za/4N2Wv+Ddlr/g3Za/4N2Wv+Ddlr/g3Za/4N2Wv+CdVr9c2dPjhwZEwk/OSsAAAAAAAAAAAD///8AxMTES/X19u3k4dv/koRp/4t9X/+LfWD/i31g/4t9YP+LfWD/i31g/4t9YP+LfWD/i31g/4h6Xv+CdVr/gXRZ/4F0Wf+BdFn/gXRZ/4F0Wf+BdFn/gXRZ/4F0Wf+BdFn/gXRZ/4F0Wf9+clftZVtGS/3jrgAAAAAAm5ubAHBwcA/o6Oix+/v7/+Pg2/+ShGn/i31f/4t9YP+LfWD/i31g/4t9YP+LfWD/i31g/4t9YP+Iel7/gXRZ/4BzWP+Ac1j/gHNY/4BzWP+Ac1j/gHNY/4BzWP+Ac1j/gHNY/4BzWP+Ac1j/gHNY/4BzWP93a1KxOTMnD1BHNwD///8AycnJRfX19fD7+/v/4+Da/5CCZ/+Jel3/iXtd/4l7Xf+Je13/iXtd/4l7Xf+Ke17/iHhd/4BxV/9/cFb/f3BW/39wVv9/cFb/f3BW/39wVv9/cFb/f3BW/39wVv9/cFb/f3BW/39wVv9/cFb/f3BW/31uVPBnWURFo45tAAAAAALk5OSN+fn5//r6+v/t7Oj/vLSk/7aunP+3rp3/t66d/7eunf+3rp3/uK+e/6Gmjv9vkG3/bI5r/2yOa/9sjmv/bI5r/2yOa/9sjmv/bI5r/2yOa/9sjmr/bI1q/2yNav9sjWr/bI1q/2uNav9rjWr/a41q/16GZI0AAAACk5OTFu/v78X5+fn/+fn5//n5+f/5+fr/+fn5//n5+f/5+fn/+fn5//n5+f/8+vv/wOfV/0vCi/9Kwor/SsKK/0rCiv9Kwor/SsKK/0rCiv9Kwor/SsKK/0rCiv9Kwor/SsKK/0rCiv9Kwor/SsKK/0nAif9Jv4j/RreCxStxUBbDw8Mz9PT05fn5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//z6+/+/59X/TMSM/0rDi/9Kw4v/SsOL/0rDi/9Kw4v/SsOL/0rDi/9Kw4v/SsOL/0rDi/9Kw4v/SsOL/0rDi/9JwYn/SL6I/0i+iP9GuoXlOJVqM9XV1VD39/f0+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn//Pr7/7/n1f9Mw4z/SsOL/0rDi/9Kw4v/SsOL/0rDi/9Kw4v/SsOL/0rDi/9Kw4v/SsOL/0rDi/9Kw4v/ScCJ/0e8hv9HvIb/R7yG/0a6hfQ9oXJQ3d3dYfj4+Pn5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/8+vv/v+fV/0zDjP9Kw4v/SsOL/0rDi/9Kw4v/SsOL/0rDi/9Kw4v/SsOL/0rDi/9Kw4v/SsOL/0i/iP9GuoX/RrqE/0a6hP9GuoT/RrmD+T6ldWHh4eFl+Pj4+vn5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//z6+/+/59X/TMOM/0rDi/9Kw4v/SsOL/0rDi/9Kw4v/SsOL/0rDi/9Kw4v/SsOL/0rDi/9Ivof/RbiD/0W3gv9FuIP/RbiD/0W4g/9Ft4L6PqZ2ZeDg4Fr4+Pj3+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn//Pr7/7/n1f9Mw4z/SsOL/0rDi/9Kw4v/SsOL/0rDi/9Kw4v/SsOL/0rDi/9Kw4v/SL2H/0W2gv9FtYH/RbWB/0W1gf9FtYH/RbWB/0S0gPc+o3Ra3NzcQvf39+/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/8+vv/v+fV/0zDjP9Kw4v/SsOL/0rDi/9Kw4v/SsOL/0rDi/9Kw4v/SsOL/0e8hv9EtID/RLOA/0SzgP9Es4D/RLOA/0SzgP9Es4D/Q7F/7zyecULS0tIj9fX12fn5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//z6+/+/59X/SsOL/0jCiv9Iwor/SMKK/0jCiv9Iwor/SMKK/0rCiv9HuoT/RLF+/0Owff9EsH3/RLB9/0Swff9EsH3/RLB9/0Swff9CrnzZOJZrI56engjy8vKu+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+vn6/9/x6f+l38X/o9/D/6Tfw/+k38P/pN/D/6Tfw/+k38T/a9Kz/0DBof9BwKH/QcCh/0HAof9BwKD/QcCg/0G/oP9Bv6D/Qb+g/0C4mK4tbU4I////AO3t7Wr5+fn++fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+vn6//v6+//7+vv/+/r7//v6+//7+vv//Pr7//v6+/+B597/NdvN/znczf853M3/OdzN/znczf853M3/OdzN/znczf85283+NtHDakb/+gDr6+sA4eHhJPb29tv5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5/3/n3f823Mz/OdzN/znczf853M3/OdzN/znczf853M3/OdzN/zjay9s0x7kkNs/BALu7uwAAAAAA8vLygfn5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/f+fd/zbbzP853M3/OdzN/znczf853M3/OdzN/znczf853M3/N9XHgQAAAAAspZoAAAAAAOzs7ADk5OQe9vb2zPn5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f9/593/NtvM/znczf853M3/OdzN/znczf853M3/OdzN/zjay8w0yrweNtDCAAAAAAAAAAAAsLCwAP///wDv7+9O+Pj47Pn5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5/3/n3f8228z/OdzN/znczf853M3/OdzN/znczf8528zsN9PETkD45gAonJEAAAAAAAAAAAAAAAAA1tbWALS0tAPy8vJv+Pj49Pn5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/f+fd/zbbzP853M3/OdzN/znczf853M3/OdvM9DjWx24qoJUDMb2wAAAAAAAAAAAAAAAAAAAAAAAAAAAA4uLiANfX1wbz8/Nz+Pj48Pn5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f9/593/NtvM/znczf853M3/OdzN/znbzPA418hzMr6xBjTIugAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4+PjANjY2ATy8vJZ+Pj42vn5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5/37m3f8z28z/N9zN/znczf8528zaONbIWTK/sgQ0yLsAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA1NTUAB8fHwDw8PAr9vb2nPj4+O35+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/vfDr/5Tq4v+L6ODtYODUnDTTxSsAGBsAMrywAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOvr6wDj4+MG8vLyOvb29pD4+PjS+fn58vn5+f35+fn/+fn5//n5+f/5+fn/+fn5/fn5+fL6+PjS+vf3kPv09Tr/6u4G/+/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADh4eEA1tbWAu/v7xv09PRJ9vb2dvb29pf39/eo9/f3qPb29pf29vZ29PT0Se/v7xvW1tYC4eHhAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP/gB///gAH//gAAf/wAAD/4AAAf8AAAD+AAAAfAAAADwAAAA4AAAAGAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAGAAAABwAAAA8AAAAPgAAAH4AAAB/AAAA/4AAAf/gAAf/8AAP//wAP/', // @suppress longLineCheck - - red: 'data:image/vndmicrosofticon;base64,AAABAAIAEBAAAAEAIABoBAAAJgAAACAgAAABACAAqBAAAI4EAAAoAAAAEAAAACAAAAABACAAAAAAAAAEAAASCwAAEgsAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQxmbAC0RagpDGZs8ShysdkwdspdMHbKXShysdkMZmzwuEWoKQxmcAAAAAAAAAAAAAAAAAAAAAAAmDlgAAAAAAUQanzRPHrilUx/B6VQgxf1VIMb/VSDG/1Qgxf1TH8DpTh22pUMZnDQAAAABJQ5XAAAAAAB7ensA//8AAFUrr09SH8DdVSDG/1Ugxv9VIMb/VSDG/1Ugxv9UH8P/Ux/B/1IfwP9QHrrdRxqlTwAAAAAoD14A+fn5ANzf1zmMatPfVB7G/1Ugxv9VIMb/VSDG/1Ugxv9TH8L/UR68/1AevP9QHrz/UR68/04dt99EGaA5UB67ALS0sw3x8u+unYDd/1AZxP9THcX/Ux3F/1Qexf9THr//Tx23/08ctv9PHbb/Tx22/08dtv9PHbb/SxuurjkSfg3h4eFK+Pj38LWf5P97UtL/fVXS/31V0/9fOcz/SSfC/0knwP9JJ8D/SSfA/0knwP9JJ8D/SSfA/0gnv/A/KLNK7e3tjPn5+f/29fj/8vD3//Px9//y8Pf/fILz/zQ/8P83QvD/N0Lw/zdC8P83QvD/N0Lw/zdB7/82QOz/Mz3gjPHx8bL5+fn/+fn5//n6+f/5+vn/+fn5/36G9v8yQPT/NkP0/zZD9P82Q/T/NkP0/zVC8v80QOz/M0Dq/zI+47Lz8/O2+fn5//n5+f/5+fn/+fn5//n5+f99hvb/MkD0/zZD9P82Q/T/NkP0/zVC8f8zP+f/Mj7k/zI+5P8xPd628vLymfn5+f/5+fn/+fn5//n5+f/5+fn/gYn2/zdE9P87R/T/O0f0/zZF8P8yQOP/MT/e/zE/3v8xP97/Lz3ZmfHx8Vz4+Pj3+fn5//n5+f/5+fn/+fn5/9fZ+P/Bxfj/wsb4/7vD+P87j/X/Dnzx/xF98f8RffH/EXzw9xZv5Vzr6+sY9/f3xvn5+f/5+fn/+fn5//n5+f/7+/n//Pz5//38+f/x+Pn/OrD+/wCY//8Amf//AJn//wCZ/cYAlPMY////APT09Fb4+Pjy+fn5//n5+f/5+fn/+fn5//n5+f/6+fn/7vX5/zmu/v8Al///AJj//wCY/vIAlfpWAJ//AOzs7ADm5uYF9vb2ePn5+fT5+fn/+fn5//n5+f/5+fn/+vn5/+71+f85rf7/AJb//wCY//QAlvx4AIzrBQCQ8gAAAAAA8PDwAOzs7Ab29vZd+Pj40vn5+fz5+fn/+fn5//n5+f/x9vn/bsP8/CGk/tIAlvxdAJDyBgCT9QAAAAAAAAAAAAAAAADn5+cAqKioAPT09CH39/dy+Pj4tvj4+NX4+PjV+Pj4tuvy93LD4fUhAAC7AESo6wAAAAAAAAAAAPAPAADAAwAAwAMAAIABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIABAACAAQAAwAMAAPAPAAAoAAAAIAAAAEAAAAABACAAAAAAAAAQAAASCwAAEgsAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBgIMDBoKPRwoD14tLhFrNy4RazcoD14tGgo9HAYCDAwAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP+3/wANBR0KLxJuMUEYmGxKHKyiTh22x1Aeu9tRHr3jUR6941Aeu9tOHbbHShysokEYmGwvEm4xDQUeCv+6/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABoKPgAHAxAHNhR9PEkbqppRHr3hVCDE/FUgxv9VIMf/VSDH/1Ugxv9VIMb/VSDH/1Ugx/9VIMb/VCDE/FEevOFIG6maNRR8PAcDEAcaCj0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADVUP8AJg5YGUYao4BRH77kVSDG/1Ugxv9VIMb/VSDG/1Ugxv9VIMb/VSDG/1Ugxv9VIMb/VSDG/1Ugxv9VIMX/VB/E/1Qfw/9QHrvkRRmggCUOVhnQTv8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEA////ADITdSpMHbKvVCDE+1Ugxv9VIMb/VSDG/1Ugxv9VIMb/VSDG/1Ugxv9VIMb/VSDG/1Ugxv9VIMb/VCDE/1Mfwv9TH8H/Ux/B/1Mfwv9SH7/7ShytrzEScSr///8AAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwMDAMto/wBVPoYsUSC3v1Ugxv9VIMb/VSDG/1Ugxv9VIMb/VSDG/1Ugxv9VIMb/VSDG/1Ugxv9VIMb/VSDG/1QfxP9SHsD/Uh6//1Iev/9SHr//Uh6//1Iev/9SHr//SxywvzMTdyymPf8AAQACAAAAAAAAAAAAAAAAAAAAAAD19fUAnaKQHbep1rVfLcn/VB/G/1Ugxv9VIMb/VSDG/1Ugxv9VIMb/VSDG/1Ugxv9VIMb/VSDG/1Ugxv9UH8P/UR6+/1Eevf9RHr3/UR69/1Eevf9RHr3/UR69/1Eevf9RHr3/ShuttS0RaB1PHrkAAAAAAAAAAAAAAAAAeXl5ADY2Ngnf4NyO18zu/V8tyf9UH8b/VSDG/1Ugxv9VIMb/VSDG/1Ugxv9VIMb/VSDG/1Ugxv9VIMb/VB/D/1EevP9QHrr/UB67/1Aeu/9QHrv/UB67/1Aeu/9QHrv/UB67/1Aeu/9QHrr9RhqkjhEGKAknDloAAAAAAAAAAAD///8AxMTES/b39O3Zzu//Xy3J/1Qfxv9VIMb/VSDG/1Ugxv9VIMb/VSDG/1Ugxv9VIMb/VSDG/1Mfwv9QHbr/Tx24/08duP9PHbj/Tx24/08duP9PHbj/Tx24/08duP9PHbj/Tx24/08duf9NHLTtPheRS5s5/wAAAAAAm5ubAHBwcA/o6Oix+/z6/9jO7/9fLcn/VB/G/1Ugxv9VIMb/VSDG/1Ugxv9VIMb/VSDG/1Ugxv9TH8H/Tx24/04dtv9OHbb/Th22/04dtv9OHbb/Th22/04dtv9OHbb/Th22/04dtv9OHbb/Th22/04dtv9JG6mxIw1RDzAScQD///8AycnJRfX19fD7/Pr/2M3v/1wqyP9SHMX/UhzF/1Icxf9SHMX/UhzF/1Icxf9THcX/Ux7A/04ctf9NHLL/Thyz/04cs/9NHLP/TRyz/00cs/9OHLP/Thyz/04cs/9OHLP/Thyz/04cs/9NHLP/Thyz/0wcsPA/Fo9FYyTkAAAAAALk5OSN+fn5//r6+f/n4vT/noDd/5Z22v+Wdtr/lnba/5Z22v+Wdtr/mHfb/35g1/9KMMr/SC/H/0gvx/9IL8f/SC/H/0gvx/9IL8b/SC/G/0gvxv9HL8b/Ry/G/0cvxv9HL8b/Ry/G/0cvxv9HL8X/Ry7F/z8tuI0AAAACk5OTFu/v78X5+fn/+fn5//n5+f/6+vn/+fr5//n6+f/5+vn/+fr5//n6+f/9/fn/ub73/zhF8v82Q/L/NkPy/zZD8v82Q/L/NkPy/zZD8v82Q/L/NkPy/zZD8v82Q/L/NkPy/zZD8v82Q/L/NkPy/zVC8f81QvD/Mz/mxR8njhbDw8Mz9PT05fn5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//z8+f+5vff/OEX0/zZD9P82Q/T/NkP0/zZD9P82Q/T/NkP0/zZD9P82Q/T/NkP0/zZD9P82Q/T/NkP0/zZD9P81QvH/NEHv/zRB7/8zQOrlKTO6M9XV1VD39/f0+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn//Pz5/7m99/84RfT/NkP0/zZD9P82Q/T/NkP0/zZD9P82Q/T/NkP0/zZD9P82Q/T/NkP0/zZD9P82Q/T/NULw/zRA7P80QOv/NEDr/zNA6fQsN8lQ3d3dYfj4+Pn5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/8/Pn/ub33/zhF9P82Q/T/NkP0/zZD9P82Q/T/NkP0/zZD9P82Q/T/NkP0/zZD9P82Q/T/NkP0/zVB7/8zQOn/Mz/o/zM/6P8zQOj/Mz/n+S04zmHh4eFl+Pj4+vn5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//z8+f+5vff/OEX0/zZD9P82Q/T/NkP0/zZD9P82Q/T/NkP0/zZD9P82Q/T/NkP0/zZD9P80Qe7/Mz/m/zM/5f8zP+b/Mz/m/zM/5v8yP+X6LjnPZeDg4Fr4+Pj3+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn//Pz5/7m99/84RfT/NkP0/zZD9P82Q/T/NkP0/zZD9P82Q/T/NkP0/zZD9P82Q/T/NEHs/zI+4/8yPuP/Mj7j/zI+4/8yPuP/Mj7j/zI+4fctOMxa3NzcQvf39+/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/8/Pn/ub33/zhF9P82Q/T/NkP0/zZD9P82Q/T/NkP0/zZD9P82Q/T/NkP0/zRA6/8xPeH/MT3g/zE94P8xPeD/MT3g/zE94P8xPeD/MT3e7ys2xkLS0tIj9fX12fn5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//z8+f+4vff/NkP0/zNB9P80QfT/NEH0/zRB9P80QfT/NEH0/zZC8/81P+n/Mjze/zI73f8yO93/Mjvd/zI73f8yO93/Mjvd/zI73f8xO9rZKTO7I56engjy8vKu+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+/r5/9ze+P+covf/mqD3/5qg9/+aoPf/mqD3/5qg9/+aoPf/UoLz/x1p5/8eaeb/Hmnm/x5p5v8eaeX/Hmnl/x5p5f8eaOX/Hmjl/yBh3a4jJokI////AO3t7Wr5+fn++fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+vr5//z8+f/8/Pn//Pz5//z8+f/8/Pn//Pz5//z8+f9dvfz/AJf+/wCZ/v8Amf7/AJn+/wCZ/v8Amf7/AJn+/wCZ/v8AmP7+AJLxagC4/wDr6+sA4eHhJPb29tv5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5/1u8/f8Alv//AJj//wCY//8AmP//AJj//wCY//8AmP//AJj//wCW/NsAieckAI/xALu7uwAAAAAA8vLygfn5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/W7z9/wCW//8AmP//AJj//wCY//8AmP//AJj//wCY//8AmP//AJP3gQAAAAAAcr8AAAAAAOzs7ADk5OQe9vb2zPn5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f9bvP3/AJb//wCY//8AmP//AJj//wCY//8AmP//AJj//wCW/MwAi+oeAJDxAAAAAAAAAAAAsLCwAP///wDv7+9O+Pj47Pn5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5/1u8/f8Alv//AJj//wCY//8AmP//AJj//wCY//8Al/7sAJL0TgCr/wAAa7QAAAAAAAAAAAAAAAAA1tbWALS0tAPy8vJv+Pj49Pn5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/W7z9/wCW//8AmP//AJj//wCY//8AmP//AJj+9ACU+G4AbrgDAIPaAAAAAAAAAAAAAAAAAAAAAAAAAAAA4uLiANfX1wbz8/Nz+Pj48Pn5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f9bvP3/AJb//wCY//8AmP//AJj//wCY/vAAlflzAITcBgCK5wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4+PjANjY2ATy8vJZ+Pj42vn5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5/1u7/f8Alf//AJf//wCY//8Al/7aAJT4WQCE3AQAiucAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA1NTUAB8fHwDw8PAr9vb2nPj4+O35+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/rNv7/3bG/P9rwfztM6r7nACR9SsAER0AAIPZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOvr6wDj4+MG8vLyOvb29pD4+PjS+fn58vn5+f35+fn/+fn5//n5+f/5+fn/+fn5/fn5+fL6+fjS/Pj2kP338jr/+eIG//fqAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADh4eEA1tbWAu/v7xv09PRJ9vb2dvb29pf39/eo9/f3qPb29pf29vZ29PT0Se/v7xvW1tYC4eHhAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP/gB///gAH//gAAf/wAAD/4AAAf8AAAD+AAAAfAAAADwAAAA4AAAAGAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAGAAAABwAAAA8AAAAPgAAAH4AAAB/AAAA/4AAAf/gAAf/8AAP//wAP/', // @suppress longLineCheck - - yellow: 'data:image/vndmicrosofticon;base64,AAABAAIAICAAAAEAIACoEAAAJgAAABAQAAABACAAaAQAAM4QAAAoAAAAIAAAAEAAAAABACAAAAAAAAAQAAASCwAAEgsAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAZKhQAOWAiAEV0KgBFdCoAOWAiABkqFAAAAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8ZAAAChAHAEp8JwBvu10AgNeSAInluACN7c4Aj/DXAI/w1wCN7c4AieW4AIDXkgBvu10ASnwnAAoQBwA8ZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAbLgAAAAAFAFmWMwB/1YwAj/DXAJX7+QCY//8AmP//AJj//wCY//8AmP//AJj//wCY//8AmP//AJX7+QCP79cAftWMAFmVMwAAAAUAGy4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA7v8AAD1mFQB6zXYAkPLdAJf+/gCY//8AmP//AJj//wCY//8AmP//AJj//wCY//8AmP//AJj//wCY//8AmP7/AJf+/wCV/P4AjvDdAHjKdgA8ZBUA6f8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP//AABWkCYAh+KoAJb8+QCY//8AmP//AJj//wCY//8AmP//AJj//wCY//8AmP//AJj//wCY//8AmP//AJf+/wCV+v8AlPr/AJT6/wCV+v8Akvf5AIPdqABTjCYA//8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgICABb//wAka5wqAozquwCY/v8AmP//AJj//wCY//8AmP//AJj//wCY//8AmP//AJj//wCY//8AmP//AJj//wCX/f8Ak/j/AJP3/wCT9/8Ak/f/AJP3/wCT9/8Akvb/AIbiuwBZlyoA//8AAAECAAAAAAAAAAAAAAAAAAAAAADz8/MAqJaJHZDD5rQLnP7/AJj//wCY//8AmP//AJj//wCY//8AmP//AJj//wCY//8AmP//AJj//wCY//8Alvz/AJL2/wCR9P8AkfT/AJH0/wCR9P8AkfT/AJH0/wCR9P8AkfT/AITftABQhh0AjO0AAAAAAAAAAAAAAAAAfX19ADw8PAni3tuPuuD5/Quc//8AmP//AJj//wCY//8AmP//AJj//wCY//8AmP//AJj//wCY//8AmP//AJb8/wCQ8/8Aj/H/AI/x/wCP8f8Aj/H/AI/x/wCP8f8Aj/H/AI/x/wCP8f8AjvD9AH7UjwAiOQkASHkAAAAAAAgICAD///8AxcXFT/j19O+94vv/Cpz//wCY//8AmP//AJj//wCY//8AmP//AJj//wCY//8AmP//AJj//wCV+/8Aj/H/AI3u/wCN7v8Aje7/AI3u/wCN7v8Aje7/AI3u/wCN7v8Aje7/AI3u/wCO7v8AiunvAHC8TwD//wAABQgAqKioAHp6ehHp6em3/fv5/7zh+v8KnP//AJj//wCY//8AmP//AJj//wCY//8AmP//AJj//wCY//8Alfr/AI7u/wCM6/8AjOv/AIzr/wCM6/8AjOv/AIzr/wCM6/8AjOv/AIzr/wCM6/8AjOv/AIzr/wCM6/8Ag9y3AERyEQBenQD///8AzMzMTfb29vP9+/n/vOH6/wqb//8Alv//AJb//wCW//8Alv//AJb//wCW//8Al///AJT5/wCL6/8Aiej/AIno/wCJ6P8Aiej/AIno/wCJ6P8Aiej/AIno/wCJ6P8Aiej/AIno/wCJ6P8Aiej/AIno/wCH5fMAb75NAMP/AAAAAAXl5eWX+fn5//v6+f/T6vr/Wbv9/0+3/f9Qt/3/ULf9/1C3/f9Qt/3/Ubj9/zew+/8InO//B5nr/weZ6/8Hmev/B5nq/weZ6v8Hmer/B5nq/weZ6v8Hmer/B5jq/weY6v8HmOn/B5jp/weY6f8HmOn/Bpjp/weP15cBAAAFpKSkHfDw8M/5+fn/+fn5//n5+f/1+Pn/9Pf5//T3+f/09/n/9Pf5//T3+f/4+Pn/o+T6/wq//f8Hv/3/CL/9/wi//f8Iv/3/CL/9/wi//f8Iv/3/CL/8/wi+/P8Ivvz/CL78/wi+/P8Ivvz/CL78/we9+/8HvPr/BrbxzwR9pR3Ly8tA9fX17Pn5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//36+f+l5vv/CcL//wfB//8Hwf//B8H//wfB//8Hwf//B8H//wfB//8Hwf//B8H//wfB//8Hwf//B8H//wfB//8Hv/3/Br36/wa9+v8GuvbsBZnLQNra2mD39/f4+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn//fr5/6Xm+/8Jwf//B8H//wfB//8Hwf//B8H//wfB//8Hwf//B8H//wfB//8Hwf//B8H//wfB//8Hwf//B778/wa79/8Guvf/Brr3/wa59fgFo9hg4uLidPj4+P35+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/9+vn/peb7/wnB//8Hwf//B8H//wfB//8Hwf//B8H//wfB//8Hwf//B8H//wfB//8Hwf//B8H//we++/8GufX/Brj0/wa49P8GuPT/Brfz/QWm3XTk5OR6+Pj4/fn5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//36+f+l5vv/CcH//wfB//8Hwf//B8H//wfB//8Hwf//B8H//wfB//8Hwf//B8H//wfB//8Hvfr/Brfy/wa28f8GtvH/Brbx/wa28f8GtfD9BafdeuXl5W/4+Pj8+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn//fr5/6Xm+/8Jwf//B8H//wfB//8Hwf//B8H//wfB//8Hwf//B8H//wfB//8Hwf//B7z5/wa17/8GtO7/BrTu/wa07v8GtO7/BrTu/waz7fwFpdtv4eHhVvj4+Pb5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/9+vn/peb7/wnB//8Hwf//B8H//wfB//8Hwf//B8H//wfB//8Hwf//B8H//we7+P8Gsu3/BrHr/wax6/8Gsev/BrHr/wax6/8Gsev/BrDq9gWh1Vba2toz9vb25vn5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//36+f+k5fv/BsH//wPA//8DwP//A8D//wPA//8DwP//A8D//wXA//8Guvb/BrDq/wau6P8Gruj/Bq7o/wau6P8Gruj/Bq7o/wau6P8GreXmBZnLM7+/vxH09PTC+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+/r5/83v+v9x2vz/btn9/2/Z/f9v2f3/b9n9/2/Z/f9v2f3/RdL5/yXG7v8mxOz/JsTs/ybE6/8mxOv/JsTr/yXE6/8lw+v/JcPr/yK95cIQirAR////APDw8IH5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+vn5//r5+f/6+fn/+vn5//r5+f/6+fn/+vn5//r5+f+H8Pz/Oer+/zzq/v886v7/POr+/zzq/v886v7/POr+/zzq/v886v3/OuDzgWz//wD09PQA5+fnNPf39+n5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5/4Xw/f846///O+v//zvr//876///O+v//zvr//876///O+v//zvp/ek32+00Ouf6AMrKygCzs7MF8/Pzmvn5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/hfD9/zjr//876///O+v//zvr//876///O+v//zvr//876///OuX5miqptwUwv88AAAAAAPPz8wDp6eku9/f33fn5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f+F8P3/OOv//zvr//876///O+v//zvr//876///O+v//zvp/d033O8uOuX5AAAAAAAAAAAAvr6+AP///wDx8fFl+Pj49fn5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5/4Xw/f846///O+v//zvr//876///O+v//zvr//876v71OeP2ZY7//wAus8IAAAAAAAAAAAAAAAAA4ODgANPT0wj09PSI+fn5+vn5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/hfD9/zjr//876///O+v//zvr//876///O+v/+jrm+Ygyx9gINdPlAAAAAAAAAAAAAAAAAAAAAAAAAAAA6enpAOHh4Q309PSM+fn5+Pn5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f+F8P3/OOv//zvr//876///O+v//zvr//g65/qMNtXnDTjd7wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA6enpAOLi4gr09PRw+Pj45/n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5/4Pw/f816///Oev//zvr//876v7nOub5cDbW5wo33O4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ODgANHR0QLx8fE89/f3sfn5+fX5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+f/5+fn/t/T7/4Xx/f+A8P31Xez8sTnk9zwuxdUCNtTkAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAREREAP///wDo6OgM9PT0Tff396T4+Pjf+fn5+Pn5+f/5+fn/+fn5//n5+f/5+fn/+fn5//n5+fj5+Pjf9vf3pPL09E3m6OgM7/3/APtbOwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACMjIwD19fUA4uLiBvHx8Sn19fVd9vb2jff396739/e99/f3vff396729vaN9fX1XfHx8Snl4uIG9PX1AFEnIgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP/wD///gAH//gAAf/wAAD/4AAAf8AAAD+AAAAfAAAADwAAAA4AAAAGAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAGAAAABgAAAAcAAAAPgAAAH4AAAB/AAAA/4AAAf/AAAP/8AAP//wAP/KAAAABAAAAAgAAAAAQAgAAAAAAAABAAAEgsAABILAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABorgAAS34IAHTDNQCC22wAh+OMAIfjjACC22wAdMQ1AEx/CABorwAAAAAAAAAAAAAAAAAAAAAAAEBrAAAAAAAAecswAIzsngCU+OUAl/37AJj+/wCY/v8Al/37AJP35QCL6Z4Ad8gwAAAAAAA+aQAAAAAAcXd6AP8AAAAOiNtNAJP32gCY//8AmP//AJj//wCY//8AmP//AJb8/wCU+f8Ak/j/AI7w2gB+1E0AAAAAAEd4APn7/ADc2NU5T7P33gCX//8AmP//AJj//wCY//8AmP//AJX6/wCR8/8AkPL/AJDz/wCQ8/8AjOzeAHrOOQCR9AC3t7cO8e/vsGnA/f8Alf//AJf//wCX//8Al///AJP4/wCN7v8AjOz/AIzs/wCM7P8AjOz/AIzt/wCG4rAAY6oO4uLiT/j39/GIzfz/Mav+/zSs/v80rP7/FaH5/wOV7f8DlOv/A5Tr/wOU6/8DlOv/A5Tr/wOU6/8Dk+jxBIvVT+3t7ZT5+fn/8fb5/+vz+f/r9Pn/6vP5/1nR+/8EvPz/B738/we9/P8Hvfz/B738/we9/P8HvPv/B7r4/wax7ZTy8vK7+fn5//n5+f/6+fn/+vn5//n5+f9e1f3/A8D//wfB//8Hwf//B8H//wfB//8HwP3/Brv3/wa59f8GtO678/Pzwfn5+f/5+fn/+fn5//n5+f/4+fn/XtX9/wPA//8Hwf//B8H//wfB//8Hv/z/Brfz/wa17/8Gte//BrHqwfPz86X5+fn/+fn5//n5+f/5+fn/+Pn5/2DW/f8Gwf//CsL//wrC//8Jv/v/CLXu/wix6f8Isen/CLHp/wet5KXy8vJo+fn5+vn5+f/5+fn/+fn5//n5+f/I7vr/quf7/6zn+/+m5/v/Tdz5/yzV9P8u1fT/LtX0/y7U8/ooyOpo7OzsH/f399D5+fn/+fn5//n5+f/5+fn//Pr5//36+f/++vn/9fn5/2rv/v857P//POz//zzs//886/3QOuLzH////wD09PRh+fn59vn5+f/5+fn/+fn5//n5+f/5+fn/+fn5//H4+f9o7v7/OOv//zvr//876//2Ouf6YUH//wDu7u4A6enpB/b29oT5+fn3+fn5//n5+f/5+fn/+fn5//n5+f/x+Pn/Zu7+/zfr//876//3Ouj8hDfc7wc44PMAAAAAAPHx8QDu7u4I9vb2aPj4+Nn5+fn9+fn5//n5+f/5+fn/8/n5/4zx/P1S7P7ZO+n8aDfh9Ag55PcAAAAAAAAAAAAAAAAA6+vrAN/f3wH19fUo9/f3fvj4+MH4+Pje+Pj43vj4+MHq9vh+w/H2KADM5wFk4e8AAAAAAAAAAADwDwAA4AcAAMADAACAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAQAAgAEAAMADAADgBwAA' // @suppress longLineCheck - }; - - return { - FaviconsByHue: FaviconsByHue - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/file.html b/chromium/third_party/catapult/tracing/tracing/ui/base/file.html deleted file mode 100644 index c599c5e3ef8..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/file.html +++ /dev/null @@ -1,35 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright 2016 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> -<link rel="import" href="/tracing/base/base.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.b', function() { - function readFile(fileBlob) { - return new Promise(function(resolve, reject) { - var reader = new FileReader(); - var filename = fileBlob.name; - reader.onload = function(data) { - resolve(data.target.result); - }; - reader.onerror = function(err) { - reject(err); - }; - - var is_binary = filename.endsWith('.gz') || filename.endsWith('.zip'); - if (is_binary) - reader.readAsArrayBuffer(fileBlob); - else - reader.readAsText(fileBlob); - }); - } - return { - readFile: readFile - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/grouping_table.html b/chromium/third_party/catapult/tracing/tracing/ui/base/grouping_table.html deleted file mode 100644 index 341574145c6..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/grouping_table.html +++ /dev/null @@ -1,227 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2016 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/base/table.html"> - -<polymer-element name="tr-ui-b-grouping-table"> - <template> - <style> - :host { - display: flex; - } - #table { - flex: 1 1 auto; - } - </style> - <tr-ui-b-table id="table"></tr-ui-b-table> - </template> -</polymer-element> -<script> -'use strict'; - -tr.exportTo('tr.ui.b', function() { - - function Row(title, data, groupingKeyFuncs, rowStatsConstructor) { - this.title = title; - this.data_ = data; - if (groupingKeyFuncs === undefined) - groupingKeyFuncs = []; - this.groupingKeyFuncs_ = groupingKeyFuncs; - this.rowStatsConstructor_ = rowStatsConstructor; - - this.subRowsBuilt_ = false; - this.subRows_ = undefined; - - this.rowStats_ = undefined; - } - - Row.prototype = { - getCurrentGroupingKeyFunc_: function() { - if (this.groupingKeyFuncs_.length === 0) - return undefined; - return this.groupingKeyFuncs_[0]; - }, - - get data() { - return this.data_; - }, - - get rowStats() { - if (this.rowStats_ === undefined) { - this.rowStats_ = new this.rowStatsConstructor_(this); - } - return this.rowStats_; - }, - - rebuildSubRowsIfNeeded_: function() { - if (this.subRowsBuilt_) - return; - this.subRowsBuilt_ = true; - - var groupingKeyFunc = this.getCurrentGroupingKeyFunc_(); - if (groupingKeyFunc === undefined) { - this.subRows_ = undefined; - return; - } - - var dataByKey = {}; - var hasValues = false; - this.data_.forEach(function(datum) { - var key = groupingKeyFunc(datum); - hasValues = hasValues || (key !== undefined); - if (dataByKey[key] === undefined) - dataByKey[key] = []; - dataByKey[key].push(datum); - }); - if (!hasValues) { - this.subRows_ = undefined; - return; - } - - this.subRows_ = []; - for (var key in dataByKey) { - var row = new Row(key, - dataByKey[key], - this.groupingKeyFuncs_.slice(1), - this.rowStatsConstructor_); - this.subRows_.push(row); - } - }, - - get isExpanded() { - return (this.subRows && - (this.subRows.length > 0) && - (this.subRows.length < 5)); - }, - - get subRows() { - this.rebuildSubRowsIfNeeded_(); - return this.subRows_; - } - }; - - Polymer('tr-ui-b-grouping-table', { - created: function() { - this.dataToGroup_ = undefined; - this.groupBy_ = undefined; - this.rowStatsConstructor_ = undefined; - }, - - get tableColumns() { - return this.$.table.tableColumns; - }, - - set tableColumns(tableColumns) { - this.$.table.tableColumns = tableColumns; - }, - - get tableRows() { - return this.$.table.tableRows; - }, - - get sortColumnIndex() { - return this.$.table.sortColumnIndex; - }, - - set sortColumnIndex(sortColumnIndex) { - this.$.table.sortColumnIndex = sortColumnIndex; - }, - - get sortDescending() { - return this.$.table.sortDescending; - }, - - set sortDescending(sortDescending) { - this.$.table.sortDescending = sortDescending; - }, - - get selectionMode() { - return this.$.table.selectionMode; - }, - - set selectionMode(selectionMode) { - this.$.table.selectionMode = selectionMode; - }, - - get rowHighlightStyle() { - return this.$.table.rowHighlightStyle; - }, - - set rowHighlightStyle(rowHighlightStyle) { - this.$.table.rowHighlightStyle = rowHighlightStyle; - }, - - get cellHighlightStyle() { - return this.$.table.cellHighlightStyle; - }, - - set cellHighlightStyle(cellHighlightStyle) { - this.$.table.cellHighlightStyle = cellHighlightStyle; - }, - - get selectedColumnIndex() { - return this.$.table.selectedColumnIndex; - }, - - set selectedColumnIndex(selectedColumnIndex) { - this.$.table.selectedColumnIndex = selectedColumnIndex; - }, - - get selectedTableRow() { - return this.$.table.selectedTableRow; - }, - - set selectedTableRow(selectedTableRow) { - this.$.table.selectedTableRow = selectedTableRow; - }, - - get groupBy() { - return this.groupBy_; - }, - - set groupBy(groupBy) { - this.groupBy_ = groupBy; - this.updateContents_(); - }, - - get dataToGroup() { - return this.dataToGroup_; - }, - - set dataToGroup(dataToGroup) { - this.dataToGroup_ = dataToGroup; - this.updateContents_(); - }, - - get rowStatsConstructor() { - return this.rowStatsConstructor_; - }, - - set rowStatsConstructor(rowStatsConstructor) { - this.rowStatsConstructor_ = rowStatsConstructor; - this.updateContents_(); - }, - - rebuild: function() { - this.$.table.rebuild(); - }, - - updateContents_: function() { - var groupBy = this.groupBy_ || []; - var dataToGroup = this.dataToGroup_ || []; - var rowStatsConstructor = this.rowStatsConstructor_ || function() {}; - - var superRow = new Row('', dataToGroup, groupBy, - rowStatsConstructor); - this.$.table.tableRows = superRow.subRows || []; - } - }); - - return { - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/grouping_table_groupby_picker.html b/chromium/third_party/catapult/tracing/tracing/ui/base/grouping_table_groupby_picker.html deleted file mode 100644 index ef12f0450d6..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/grouping_table_groupby_picker.html +++ /dev/null @@ -1,313 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2016 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> -<link rel="import" href="/tracing/base/iteration_helpers.html"> -<link rel="import" href="/tracing/base/settings.html"> -<link rel="import" href="/tracing/ui/base/dropdown.html"> - -<polymer-element name="tr-ui-b-grouping-table-groupby-picker"> - <template> - <style> - :host { - display: flex; - flex-direction: row; - align-items: center; - } - groups { - -webkit-user-select: none; - display: flex; - flex-direction: row; - padding-left: 10px; - } - - group, possible-group { - display: span; - padding-right: 10px; - padding-left: 10px; - } - - group { - border-left: 1px solid rgba(0,0,0,0); - cursor: move; - } - - group.dragging { - opacity: 0.2; - } - - group.drop-targeted { - border-left: 1px solid black; - } - - - #remove { - cursor: default; - } - - #remove:not([hovered]) { - visibility: hidden; - } - </style> - <groups> - </groups> - <tr-ui-b-dropdown id="add-group"></tr-ui-b-dropdown> - </template> -</polymer-element> - -<template id="tr-ui-b-grouping-table-groupby-picker-group-template"> - <span id="key"></span> - <span id="remove">×</span> -</template> - -<script> -'use strict'; - -tr.exportTo('tr.ui.b', function() { - var THIS_DOC = document._currentScript.ownerDocument; - - Polymer('tr-ui-b-grouping-table-groupby-picker', { - created: function() { - this.needsInit_ = true; - this.defaultGroupKeys_ = undefined; - this.possibleGroups_ = []; - this.settingsKey_ = []; - - this.currentGroupKeys_ = undefined; - - this.dragging_ = false; - }, - - get defaultGroupKeys() { - return this.defaultGroupKeys_; - }, - - set defaultGroupKeys(defaultGroupKeys) { - if (!this.needsInit_) - throw new Error('Already initialized.'); - this.defaultGroupKeys_ = defaultGroupKeys; - this.maybeInit_(); - }, - - get possibleGroups() { - return this.possibleGroups_; - }, - - set possibleGroups(possibleGroups) { - if (!this.needsInit_) - throw new Error('Already initialized.'); - this.possibleGroups_ = possibleGroups; - this.maybeInit_(); - }, - - get settingsKey() { - return this.settingsKey_; - }, - - set settingsKey(settingsKey) { - if (!this.needsInit_) - throw new Error('Already initialized.'); - this.settingsKey_ = settingsKey; - this.maybeInit_(); - }, - - maybeInit_: function() { - if (!this.needsInit_) - return; - - if (this.settingsKey_ === undefined) - return; - if (this.defaultGroupKeys_ === undefined) - return; - if (this.possibleGroups_ === undefined) - return; - - this.needsInit_ = false; - - var addGroupEl = this.shadowRoot.querySelector('#add-group'); - addGroupEl.iconElement.textContent = 'Add another...'; - - this.currentGroupKeys = tr.b.Settings.get( - this.settingsKey_, this.defaultGroupKeys_); - }, - - get currentGroupKeys() { - return this.currentGroupKeys_; - }, - - get currentGroups() { - var groupsByKey = {}; - this.possibleGroups_.forEach(function(group) { - groupsByKey[group.key] = group; - }); - return this.currentGroupKeys_.map(function(groupKey) { - return groupsByKey[groupKey]; - }); - }, - - set currentGroupKeys(currentGroupKeys) { - if (this.currentGroupKeys_ === currentGroupKeys) - return; - - if (!(currentGroupKeys instanceof Array)) - throw new Error('Must be array'); - - this.currentGroupKeys_ = currentGroupKeys; - this.updateGroups_(); - - tr.b.Settings.set( - this.settingsKey_, this.currentGroupKeys_); - - var e = new tr.b.Event('current-groups-changed'); - this.dispatchEvent(e); - }, - - updateGroups_: function() { - var groupsEl = this.shadowRoot.querySelector('groups'); - var addGroupEl = this.shadowRoot.querySelector('#add-group'); - - groupsEl.textContent = ''; - addGroupEl.textContent = ''; - - var unusedGroups = {}; - var groupsByKey = {}; - this.possibleGroups_.forEach(function(group) { - unusedGroups[group.key] = group; - groupsByKey[group.key] = group; - }); - - this.currentGroupKeys_.forEach(function(key) { - delete unusedGroups[key]; - }); - - // Create groups. - var groupTemplateEl = THIS_DOC.querySelector( - '#tr-ui-b-grouping-table-groupby-picker-group-template'); - this.currentGroupKeys_.forEach(function(key, index) { - var group = groupsByKey[key]; - var groupEl = document.createElement('group'); - groupEl.groupKey = key; - groupEl.appendChild(document.importNode(groupTemplateEl.content, true)); - groupEl.querySelector('#key').textContent = group.label; - groupsEl.appendChild(groupEl); - - this.configureRemoveButtonForGroup_(groupEl); - this.configureDragAndDropForGroup_(groupEl); - }, this); - - // Adjust dropdown. - tr.b.iterItems(unusedGroups, function(key, group) { - var groupEl = document.createElement('possible-group'); - groupEl.textContent = group.label; - groupEl.addEventListener('click', function() { - var newKeys = this.currentGroupKeys.slice(); - newKeys.push(key); - this.currentGroupKeys = newKeys; - addGroupEl.close(); - }.bind(this)); - addGroupEl.appendChild(groupEl); - }, this); - - // Hide dropdown if needed. - if (tr.b.dictionaryLength(unusedGroups) == 0) { - addGroupEl.style.display = 'none'; - } else { - addGroupEl.style.display = ''; - } - }, - - configureRemoveButtonForGroup_: function(groupEl) { - var removeEl = groupEl.querySelector('#remove'); - removeEl.addEventListener('click', function() { - var newKeys = this.currentGroupKeys.slice(); - var i = newKeys.indexOf(groupEl.groupKey); - newKeys.splice(i, 1); - this.currentGroupKeys = newKeys; - }.bind(this)); - - groupEl.addEventListener('mouseenter', function() { - removeEl.setAttribute('hovered', true); - }); - groupEl.addEventListener('mouseleave', function() { - removeEl.removeAttribute('hovered'); - }); - }, - - configureDragAndDropForGroup_: function(groupEl) { - var groupsEl = groupEl.parentElement; - - groupEl.setAttribute('draggable', true); - - groupEl.addEventListener('dragstart', function(e) { - e.dataTransfer.setData('groupKey', groupEl.groupKey); - groupEl.querySelector('#remove').removeAttribute('hovered'); - groupEl.classList.add('dragging'); - this.dragging_ = true; - }.bind(this)); - - groupEl.addEventListener('dragend', function(e) { - console.log(e.type, groupEl.groupKey); - for (var i = 0; i < groupsEl.children.length; i++) - groupsEl.children[i].classList.remove('drop-targeted'); - groupEl.classList.remove('dragging'); - this.dragging_ = false; - }.bind(this)); - - // Drop targeting. - groupEl.addEventListener('dragenter', function(e) { - if (!this.dragging_) - return; - groupEl.classList.add('drop-targeted'); - if (this.dragging_) - e.preventDefault(); - }.bind(this)); - - groupEl.addEventListener('dragleave', function(e) { - if (!this.dragging_) - return; - groupEl.classList.remove('drop-targeted'); - e.preventDefault(); - }.bind(this)); - - - // Drop logic. - groupEl.addEventListener('dragover', function(e) { - if (!this.dragging_) - return; - e.preventDefault(); - groupEl.classList.add('drop-targeted'); - }.bind(this)); - - groupEl.addEventListener('drop', function(e) { - if (!this.dragging_) - return; - - var srcKey = e.dataTransfer.getData('groupKey'); - var dstKey = groupEl.groupKey; - - if (srcKey === dstKey) - return; - - var newKeys = this.currentGroupKeys_.slice(); - - var srcIndex = this.currentGroupKeys_.indexOf(srcKey); - newKeys.splice(srcIndex, 1); - - var dstIndex = this.currentGroupKeys_.indexOf(dstKey); - newKeys.splice(dstIndex, 0, srcKey); - - this.currentGroupKeys = newKeys; - - e.dataTransfer.clearData(); - e.preventDefault(); - e.stopPropagation(); - }.bind(this)); - } - }); - - return { - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/grouping_table_groupby_picker_test.html b/chromium/third_party/catapult/tracing/tracing/ui/base/grouping_table_groupby_picker_test.html deleted file mode 100644 index 1bbbc4f2057..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/grouping_table_groupby_picker_test.html +++ /dev/null @@ -1,60 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2016 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/base/grouping_table_groupby_picker.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - test('basic', function() { - var picker = document.createElement( - 'tr-ui-b-grouping-table-groupby-picker'); - picker.settingsKey = 'basic-test'; - picker.possibleGroups = [ - {key: 'a', label: 'A'}, - {key: 'b', label: 'B'}, - {key: 'c', label: 'C'}, - {key: 'd', label: 'D'}, - {key: 'e', label: 'E'} - ]; - picker.defaultGroupKeys = ['a', 'b', 'd']; - this.addHTMLOutput(picker); - }); - - test('allGroupsAdded', function() { - var picker = document.createElement( - 'tr-ui-b-grouping-table-groupby-picker'); - picker.settingsKey = 'basic-test'; - picker.possibleGroups = [ - {key: 'a', label: 'A'}, - {key: 'b', label: 'B'}, - {key: 'c', label: 'C'}, - {key: 'd', label: 'D'}, - {key: 'e', label: 'E'} - ]; - picker.defaultGroupKeys = ['a', 'b', 'c', 'd', 'e']; - this.addHTMLOutput(picker); - }); - - test('noGroupsAdded', function() { - var picker = document.createElement( - 'tr-ui-b-grouping-table-groupby-picker'); - picker.settingsKey = 'basic-test'; - picker.possibleGroups = [ - {key: 'a', label: 'A'}, - {key: 'b', label: 'B'}, - {key: 'c', label: 'C'}, - {key: 'd', label: 'D'}, - {key: 'e', label: 'E'} - ]; - picker.defaultGroupKeys = []; - this.addHTMLOutput(picker); - }); - -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/heading.html b/chromium/third_party/catapult/tracing/tracing/ui/base/heading.html deleted file mode 100644 index 0c884b65a96..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/heading.html +++ /dev/null @@ -1,142 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel='import' href='/tracing/ui/base/constants.html'> - -<polymer-element name='tr-ui-heading'> - <template> - <style> - :host { - background-color: rgb(243, 245, 247); - border-right: 1px solid #8e8e8e; - display: block; - height: 100%; - margin: 0; - padding: 0 5px 0 0; - } - - heading { - display: block; - overflow-x: hidden; - text-align: left; - text-overflow: ellipsis; - white-space: nowrap; - } - - #arrow { - -webkit-flex: 0 0 auto; - font-family: sans-serif; - margin-left: 5px; - margin-right: 5px; - width: 8px; - } - - #link, #heading_content { - display: none; - } - </style> - <heading id='heading' on-click='{{onHeadingDivClicked_}}'> - <span id='arrow'></span> - <span id='heading_content'></span> - <tr-ui-a-analysis-link id='link'></tr-ui-a-analysis-link> - </heading> - </template> - - <script> - 'use strict'; - Polymer({ - DOWN_ARROW: String.fromCharCode(0x25BE), - RIGHT_ARROW: String.fromCharCode(0x25B8), - - ready: function(viewport) { - // Minus 6 == 1px border + 5px padding right. - this.style.width = (tr.ui.b.constants.HEADING_WIDTH - 6) + 'px'; - - this.heading_ = ''; - this.expanded_ = true; - this.arrowVisible_ = false; - this.selectionGenerator_ = undefined; - - this.updateContents_(); - }, - - get heading() { - return this.heading_; - }, - - set heading(text) { - if (this.heading_ === text) - return; - - this.heading_ = text; - this.updateContents_(); - }, - - set arrowVisible(val) { - if (this.arrowVisible_ === val) - return; - - this.arrowVisible_ = !!val; - this.updateContents_(); - }, - - set tooltip(text) { - this.$.heading.title = text; - }, - - set selectionGenerator(generator) { - if (this.selectionGenerator_ === generator) - return; - - this.selectionGenerator_ = generator; - this.updateContents_(); - }, - - get expanded() { - return this.expanded_; - }, - - set expanded(expanded) { - if (this.expanded_ === expanded) - return; - - this.expanded_ = !!expanded; - this.updateContents_(); - }, - - onHeadingDivClicked_: function() { - this.dispatchEvent(new tr.b.Event('heading-clicked', {'bubbles': true})); - }, - - updateContents_: function() { - if (this.arrowVisible_) { - this.$.arrow.style.display = ''; - } else { - this.$.arrow.style.display = 'none'; - this.$.heading.style.display = this.expanded_ ? '' : 'none'; - } - - if (this.arrowVisible_) { - this.$.arrow.textContent = - this.expanded_ ? this.DOWN_ARROW : this.RIGHT_ARROW; - } - - this.$.link.style.display = 'none'; - this.$.heading_content.style.display = 'none'; - - if (this.selectionGenerator_) { - this.$.link.style.display = 'inline-block'; - this.$.link.selection = this.selectionGenerator_; - this.$.link.textContent = this.heading_; - } else { - this.$.heading_content.style.display = 'inline-block'; - this.$.heading_content.textContent = this.heading_; - } - } - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/hot_key.html b/chromium/third_party/catapult/tracing/tracing/ui/base/hot_key.html deleted file mode 100644 index 699b41a8e0a..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/hot_key.html +++ /dev/null @@ -1,64 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> -<link rel="import" href="/tracing/base/guid.html"> -<script> -'use strict'; - -tr.exportTo('tr.ui.b', function() { - function HotKey(dict) { - if (dict.eventType === undefined) - throw new Error('eventType must be given'); - if (dict.keyCode === undefined && dict.keyCodes === undefined) - throw new Error('keyCode or keyCodes must be given'); - if (dict.keyCode !== undefined && dict.keyCodes !== undefined) - throw new Error('Only keyCode or keyCodes can be given'); - if (dict.callback === undefined) - throw new Error('callback must be given'); - - this.eventType_ = dict.eventType; - this.keyCodes_ = []; - - if (dict.keyCode) - this.pushKeyCode_(dict.keyCode); - else if (dict.keyCodes) { - dict.keyCodes.forEach(this.pushKeyCode_, this); - } - - this.useCapture_ = !!dict.useCapture; - this.callback_ = dict.callback; - this.thisArg_ = dict.thisArg !== undefined ? dict.thisArg : undefined; - - this.helpText_ = dict.helpText !== undefined ? dict.helpText : undefined; - } - - HotKey.prototype = { - get eventType() { - return this.eventType_; - }, - - get keyCodes() { - return this.keyCodes_; - }, - - get helpText() { - return this.helpText_; - }, - - call: function(e) { - this.callback_.call(this.thisArg_, e); - }, - - pushKeyCode_: function(keyCode) { - this.keyCodes_.push(keyCode); - } - }; - - return { - HotKey: HotKey - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/hotkey_controller.html b/chromium/third_party/catapult/tracing/tracing/ui/base/hotkey_controller.html deleted file mode 100644 index 892b7e7593a..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/hotkey_controller.html +++ /dev/null @@ -1,298 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> -<link rel="import" href="/tracing/base/guid.html"> -<link rel="import" href="/tracing/ui/base/hot_key.html"> - -<polymer-element name="tv-ui-b-hotkey-controller"> - <script> - 'use strict'; - Polymer({ - created: function() { - this.isAttached_ = false; - this.globalMode_ = false; - this.slavedToParentController_ = undefined; - this.curHost_ = undefined; - this.childControllers_ = []; - - this.bubblingKeyDownHotKeys_ = {}; - this.capturingKeyDownHotKeys_ = {}; - this.bubblingKeyPressHotKeys_ = {}; - this.capturingKeyPressHotKeys_ = {}; - - this.onBubblingKeyDown_ = this.onKey_.bind(this, false); - this.onCapturingKeyDown_ = this.onKey_.bind(this, true); - this.onBubblingKeyPress_ = this.onKey_.bind(this, false); - this.onCapturingKeyPress_ = this.onKey_.bind(this, true); - }, - - attached: function() { - this.isAttached_ = true; - - var host = this.findHost_(); - if (host.__hotkeyController) - throw new Error('Multiple hotkey controllers attached to this host'); - - host.__hotkeyController = this; - this.curHost_ = host; - - var parentElement; - if (host.parentElement) - parentElement = host.parentElement; - else - parentElement = host.parentNode.host; - var parentController = tr.b.getHotkeyControllerForElement( - parentElement); - - if (parentController) { - this.slavedToParentController_ = parentController; - parentController.addChildController_(this); - return; - } - - host.addEventListener('keydown', this.onBubblingKeyDown_, false); - host.addEventListener('keydown', this.onCapturingKeyDown_, true); - host.addEventListener('keypress', this.onBubblingKeyPress_, false); - host.addEventListener('keypress', this.onCapturingKeyPress_, true); - }, - - detached: function() { - this.isAttached_ = false; - - var host = this.curHost_; - if (!host) - return; - - delete host.__hotkeyController; - this.curHost_ = undefined; - - if (this.slavedToParentController_) { - this.slavedToParentController_.removeChildController_(this); - this.slavedToParentController_ = undefined; - return; - } - - host.removeEventListener('keydown', this.onBubblingKeyDown_, false); - host.removeEventListener('keydown', this.onCapturingKeyDown_, true); - host.removeEventListener('keypress', this.onBubblingKeyPress_, false); - host.removeEventListener('keypress', this.onCapturingKeyPress_, true); - }, - - addChildController_: function(controller) { - var i = this.childControllers_.indexOf(controller); - if (i !== -1) - throw new Error('Controller already registered'); - this.childControllers_.push(controller); - }, - - removeChildController_: function(controller) { - var i = this.childControllers_.indexOf(controller); - if (i === -1) - throw new Error('Controller not registered'); - this.childControllers_.splice(i, 1); - return controller; - }, - - getKeyMapForEventType_: function(eventType, useCapture) { - if (eventType === 'keydown') { - if (!useCapture) - return this.bubblingKeyDownHotKeys_; - else - return this.capturingKeyDownHotKeys_; - } else if (eventType === 'keypress') { - if (!useCapture) - return this.bubblingKeyPressHotKeys_; - else - return this.capturingKeyPressHotKeys_; - } else { - throw new Error('Unsupported key event'); - } - }, - - addHotKey: function(hotKey) { - if (!(hotKey instanceof tr.ui.b.HotKey)) - throw new Error('hotKey must be a tr.ui.b.HotKey'); - - var keyMap = this.getKeyMapForEventType_( - hotKey.eventType, hotKey.useCapture); - - for (var i = 0; i < hotKey.keyCodes.length; i++) { - var keyCode = hotKey.keyCodes[i]; - if (keyMap[keyCode]) - throw new Error('Key is already bound for keyCode=' + keyCode); - } - - for (var i = 0; i < hotKey.keyCodes.length; i++) { - var keyCode = hotKey.keyCodes[i]; - keyMap[keyCode] = hotKey; - } - return hotKey; - }, - - removeHotKey: function(hotKey) { - if (!(hotKey instanceof tr.ui.b.HotKey)) - throw new Error('hotKey must be a tr.ui.b.HotKey'); - - var keyMap = this.getKeyMapForEventType_( - hotKey.eventType, hotKey.useCapture); - - for (var i = 0; i < hotKey.keyCodes.length; i++) { - var keyCode = hotKey.keyCodes[i]; - if (!keyMap[keyCode]) - throw new Error('Key is not bound for keyCode=' + keyCode); - keyMap[keyCode] = hotKey; - } - for (var i = 0; i < hotKey.keyCodes.length; i++) { - var keyCode = hotKey.keyCodes[i]; - delete keyMap[keyCode]; - } - return hotKey; - }, - - get globalMode() { - return this.globalMode_; - }, - - set globalMode(globalMode) { - var wasAttached = this.isAttached_; - if (wasAttached) - this.detached(); - this.globalMode_ = !!globalMode; - if (wasAttached) - this.attached(); - }, - - get topmostConroller_() { - if (this.slavedToParentController_) - return this.slavedToParentController_.topmostConroller_; - return this; - }, - - childRequestsGeneralFocus: function(child) { - var topmost = this.topmostConroller_; - if (topmost.curHost_) { - if (topmost.curHost_.hasAttribute('tabIndex')) { - topmost.curHost_.focus(); - } else { - if (document.activeElement) - document.activeElement.blur(); - } - } else { - if (document.activeElement) - document.activeElement.blur(); - } - }, - - childRequestsBlur: function(child) { - child.blur(); - - var topmost = this.topmostConroller_; - if (topmost.curHost_) { - topmost.curHost_.focus(); - } - }, - - findHost_: function() { - if (this.globalMode_) { - return document.body; - } else { - if (this.parentElement) - return this.parentElement; - - var node = this; - while (node.parentNode) { - node = node.parentNode; - } - return node.host; - } - }, - - appendMatchingHotKeysTo_: function(matchedHotKeys, - useCapture, e) { - var localKeyMap = this.getKeyMapForEventType_(e.type, useCapture); - var localHotKey = localKeyMap[e.keyCode]; - if (localHotKey) - matchedHotKeys.push(localHotKey); - - for (var i = 0; i < this.childControllers_.length; i++) { - var controller = this.childControllers_[i]; - controller.appendMatchingHotKeysTo_(matchedHotKeys, - useCapture, e); - } - }, - - onKey_: function(useCapture, e) { - // Keys dispatched to INPUT elements still bubble, even when they're - // handled. So, skip any events that targeted the input element. - if (useCapture == false && e.path[0].tagName == 'INPUT') - return; - - var sortedControllers; - - var matchedHotKeys = []; - this.appendMatchingHotKeysTo_(matchedHotKeys, useCapture, e); - - if (matchedHotKeys.length === 0) - return false; - - if (matchedHotKeys.length > 1) { - // TODO(nduca): To do support for coddling hotKeys, we need to - // sort the listeners by their capturing/bubbling order and then pick - // the one that would topologically win the tie, per DOM dispatch rules. - throw new Error('More than one hotKey is currently unsupported'); - } - - - var hotKey = matchedHotKeys[0]; - - var prevented = 0; - prevented |= hotKey.call(e); - - // We want to return false if preventDefaulted, or one of the handlers - // return false. But otherwise, we want to return undefiend. - return !prevented && e.defaultPrevented; - } - }); - </script> -</polymer-element> -<script> -'use strict'; - -tr.exportTo('tr.b', function() { - - function getHotkeyControllerForElement(refElement) { - var curElement = refElement; - while (curElement) { - if (curElement.tagName === 'tv-ui-b-hotkey-controller') - return curElement; - - if (curElement.__hotkeyController) - return curElement.__hotkeyController; - - if (curElement.parentElement) { - curElement = curElement.parentElement; - continue; - } - - // Probably inside a shadow - curElement = findHost(curElement); - } - return undefined; - } - - function findHost(initialNode) { - var node = initialNode; - while (node.parentNode) { - node = node.parentNode; - } - return node.host; - } - - return { - getHotkeyControllerForElement: getHotkeyControllerForElement - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/hotkey_controller_test.html b/chromium/third_party/catapult/tracing/tracing/ui/base/hotkey_controller_test.html deleted file mode 100644 index 0895e724250..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/hotkey_controller_test.html +++ /dev/null @@ -1,138 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/event.html"> -<link rel="import" href="/tracing/ui/base/hotkey_controller.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var KeyEventManager = tr.b.KeyEventManager; - - function newKeyEvent(eventType, dict) { - var e = new tr.b.Event(eventType, true, true); - if (dict.keyCode === undefined) - throw new Error('keyCode required'); - e.keyCode = dict.keyCode; - return e; - } - - test('simpleHotkeyManager', function() { - var rootElement = document.createElement('div'); - document.body.appendChild(rootElement); - try { - var elementShadow = rootElement.createShadowRoot(); - - var hkc = document.createElement('tv-ui-b-hotkey-controller'); - elementShadow.appendChild(hkc); - - var subElement = document.createElement('div'); - elementShadow.appendChild(subElement); - - assert.equal(tr.b.getHotkeyControllerForElement(subElement), hkc); - - var didGetCalled = false; - hkc.addHotKey(new tr.ui.b.HotKey({ - eventType: 'keydown', - keyCode: 73, useCapture: true, - callback: function() { - didGetCalled = true; - } - })); - - // Ensure it is called when events target the root element. - var e = newKeyEvent('keydown', {keyCode: 73}); - rootElement.dispatchEvent(e); - assert.isTrue(didGetCalled); - - // Ensure it is still called when we target the sub element. - didGetCalled = false; - var e = newKeyEvent('keydown', {keyCode: 73}); - subElement.dispatchEvent(e); - assert.isTrue(didGetCalled); - - } finally { - document.body.removeChild(rootElement); - } - }); - - test('nestedHotkeyController', function() { - var rootElement = document.createElement('div'); - document.body.appendChild(rootElement); - try { - var elementShadow = rootElement.createShadowRoot(); - - var hkc = document.createElement('tv-ui-b-hotkey-controller'); - elementShadow.appendChild(hkc); - - var subElement = document.createElement('div'); - elementShadow.appendChild(subElement); - assert.equal(tr.b.getHotkeyControllerForElement(elementShadow), hkc); - - var subHKC = document.createElement('tv-ui-b-hotkey-controller'); - subElement.appendChild(subHKC); - - assert.equal(tr.b.getHotkeyControllerForElement(subElement), subHKC); - - var didGetCalled = false; - subHKC.addHotKey(new tr.ui.b.HotKey({ - eventType: 'keydown', - keyCode: 73, useCapture: true, - callback: function() { - didGetCalled = true; - } - })); - - // Ensure it is called when events target the root element. - var e = newKeyEvent('keydown', {keyCode: 73}); - rootElement.dispatchEvent(e); - assert.isTrue(didGetCalled); - } finally { - document.body.removeChild(rootElement); - } - }); - - test('inputInsideHKC', function() { - var rootElement = document.createElement('div'); - document.body.appendChild(rootElement); - try { - var elementShadow = rootElement.createShadowRoot(); - - var hkc = document.createElement('tv-ui-b-hotkey-controller'); - elementShadow.appendChild(hkc); - - var inputEl = document.createElement('input'); - elementShadow.appendChild(inputEl); - - var didGetCalled = false; - hkc.addHotKey(new tr.ui.b.HotKey({ - eventType: 'keypress', - keyCode: 'a'.charCodeAt(0), useCapture: false, - callback: function() { - didGetCalled = true; - } - })); - - // Ensure it is called when events target the root element. - didGetCalled = false; - var e = newKeyEvent('keypress', {keyCode: 'a'.charCodeAt(0)}); - rootElement.dispatchEvent(e); - assert.isTrue(didGetCalled); - - // Handler should NOT be called when events target the input element. - didGetCalled = false; - var e = newKeyEvent('keypress', {keyCode: 'a'.charCodeAt(0)}); - inputEl.dispatchEvent(e); - assert.isFalse(didGetCalled); - } finally { - document.body.removeChild(rootElement); - } - }); - -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/info_bar.html b/chromium/third_party/catapult/tracing/tracing/ui/base/info_bar.html deleted file mode 100644 index a9b188556d1..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/info_bar.html +++ /dev/null @@ -1,82 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/base/dom_helpers.html"> -<link rel="import" href="/tracing/ui/base/ui.html"> - -<polymer-element name='tr-ui-b-info-bar' is='HTMLDivElement'> - <template> - <style> - :host { - align-items: center; - flex: 0 0 auto; - background-color: rgb(252, 235, 162); - border-bottom: 1px solid #A3A3A3; - border-left: 1px solid white; - border-right: 1px solid #A3A3A3; - border-top: 1px solid white; - display: flex; - height: 26px; - padding: 0 3px 0 3px; - } - - :host(.info-bar-hidden) { - display: none; - } - - #message { flex: 1 1 auto; } - </style> - - <span id='message'></span> - <span id='buttons'></span> - </template> - - <script> - 'use strict'; - - Polymer({ - ready: function() { - this.messageEl_ = this.$.message; - this.buttonsEl_ = this.$.buttons; - - this.message = ''; - this.visible = false; - }, - - get message() { - return this.messageEl_.textContent; - }, - - set message(message) { - this.messageEl_.textContent = message; - }, - - get visible() { - return !this.classList.contains('info-bar-hidden'); - }, - - set visible(visible) { - if (visible) - this.classList.remove('info-bar-hidden'); - else - this.classList.add('info-bar-hidden'); - }, - - removeAllButtons: function() { - this.buttonsEl_.textContent = ''; - }, - - addButton: function(text, clickCallback) { - var button = document.createElement('button'); - button.textContent = text; - button.addEventListener('click', clickCallback); - this.buttonsEl_.appendChild(button); - return button; - } - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/info_bar_group.html b/chromium/third_party/catapult/tracing/tracing/ui/base/info_bar_group.html deleted file mode 100644 index 4d44a1b1099..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/info_bar_group.html +++ /dev/null @@ -1,65 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> -<link rel='import' href='/tracing/ui/base/info_bar.html'> - -<polymer-element name='tr-ui-b-info-bar-group' is='HTMLUnknownElement'> - <template> - <style> - :host { - flex: 0 0 auto; - flex-direction: column; - display: flex; - } - </style> - <div id='messages'></div> - </template> - - <script> - 'use strict'; - Polymer({ - ready: function() { - this.messages_ = []; - }, - - clearMessages: function() { - this.messages_ = []; - this.updateContents_(); - }, - - addMessage: function(text, opt_buttons) { - opt_buttons = opt_buttons || []; - for (var i = 0; i < opt_buttons.length; i++) { - if (opt_buttons[i].buttonText === undefined) - throw new Error('buttonText must be provided'); - if (opt_buttons[i].onClick === undefined) - throw new Error('onClick must be provided'); - } - - this.messages_.push({ - text: text, - buttons: opt_buttons || [] - }); - this.updateContents_(); - }, - - updateContents_: function() { - this.$.messages.textContent = ''; - this.messages_.forEach(function(message) { - var bar = document.createElement('tr-ui-b-info-bar'); - bar.message = message.text; - bar.visible = true; - - message.buttons.forEach(function(button) { - bar.addButton(button.buttonText, button.onClick); - }, this); - - this.$.messages.appendChild(bar); - }, this); - } - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/info_bar_group_test.html b/chromium/third_party/catapult/tracing/tracing/ui/base/info_bar_group_test.html deleted file mode 100644 index 5600d4043a3..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/info_bar_group_test.html +++ /dev/null @@ -1,51 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> -<link rel="import" href="/tracing/ui/base/info_bar_group.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - test('group-instantiate', function() { - var infoBarGroup = document.createElement('tr-ui-b-info-bar-group'); - infoBarGroup.addMessage( - 'Message 1', - [{buttonText: 'ok', onClick: function() {}}]); - infoBarGroup.addMessage( - 'Message 2', - [{buttonText: 'button 2', onClick: function() {}}]); - this.addHTMLOutput(infoBarGroup); - }); - - test('group-populate-then-clear', function() { - var infoBarGroup = document.createElement('tr-ui-b-info-bar-group'); - infoBarGroup.addMessage( - 'Message 1', - [{buttonText: 'ok', onClick: function() {}}]); - infoBarGroup.addMessage( - 'Message 2', - [{buttonText: 'button 2', onClick: function() {}}]); - infoBarGroup.clearMessages(); - assert.equal(infoBarGroup.children.length, 0); - }); - - test('group-populate-clear-repopulate', function() { - var infoBarGroup = document.createElement('tr-ui-b-info-bar-group'); - infoBarGroup.addMessage( - 'Message 1', - [{buttonText: 'ok', onClick: function() {}}]); - infoBarGroup.addMessage( - 'Message 2', - [{buttonText: 'button 2', onClick: function() {}}]); - infoBarGroup.clearMessages(); - infoBarGroup.addMessage( - 'Message 1', - [{buttonText: 'ok', onClick: function() {}}]); - this.addHTMLOutput(infoBarGroup); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/info_bar_test.html b/chromium/third_party/catapult/tracing/tracing/ui/base/info_bar_test.html deleted file mode 100644 index fffec0f8d4b..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/info_bar_test.html +++ /dev/null @@ -1,47 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> -<link rel="import" href="/tracing/ui/base/info_bar.html"> -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - test('instantiate', function() { - var infoBar = document.createElement('tr-ui-b-info-bar'); - infoBar.message = 'This is an info'; - infoBar.visible = true; - this.addHTMLOutput(infoBar); - }); - - test('buttons', function() { - var infoBar = document.createElement('tr-ui-b-info-bar'); - infoBar.visible = true; - infoBar.message = 'This is an info bar with buttons'; - var didClick = false; - var button = infoBar.addButton('More info...', function() { - didClick = true; - }); - button.click(); - assert.isTrue(didClick); - this.addHTMLOutput(infoBar); - }); - - test('hiding', function() { - var infoBar = document.createElement('tr-ui-b-info-bar'); - infoBar.message = 'This is an info bar'; - infoBar.visible = true; - this.addHTMLOutput(infoBar); - - assert.equal(getComputedStyle(infoBar)['display'], 'flex'); - - infoBar.visible = false; - assert.equal(getComputedStyle(infoBar)['display'], 'none'); - - infoBar.visible = true; - assert.equal(getComputedStyle(infoBar)['display'], 'flex'); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/line_chart.css b/chromium/third_party/catapult/tracing/tracing/ui/base/line_chart.css deleted file mode 100644 index e2c945b8be3..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/line_chart.css +++ /dev/null @@ -1,13 +0,0 @@ -/* Copyright 2014 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -* /deep/ .line-chart .line { - fill: none; - stroke-width: 1.5px; -} - -* /deep/ .line-chart #brushes > rect { - fill: rgb(192, 192, 192); -} diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/line_chart.html b/chromium/third_party/catapult/tracing/tracing/ui/base/line_chart.html deleted file mode 100644 index ba431695242..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/line_chart.html +++ /dev/null @@ -1,63 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/base/chart_base_2d_brushable_x.html"> - -<link rel="stylesheet" href="/tracing/ui/base/line_chart.css"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.b', function() { - var ChartBase2DBrushX = tr.ui.b.ChartBase2DBrushX; - - /** - * @constructor - */ - var LineChart = tr.ui.b.define('line-chart', ChartBase2DBrushX); - - LineChart.prototype = { - __proto__: ChartBase2DBrushX.prototype, - - decorate: function() { - ChartBase2DBrushX.prototype.decorate.call(this); - this.classList.add('line-chart'); - }, - - isDatumFieldSeries_: function(fieldName) { - return fieldName != 'x'; - }, - - getXForDatum_: function(datum, index) { - return datum.x; - }, - - updateDataContents_: function(dataSel) { - dataSel.selectAll('*').remove(); - var dataBySeriesKey = this.getDataBySeriesKey_(); - var pathsSel = dataSel.selectAll('path').data(this.seriesKeys_); - pathsSel.enter() - .append('path') - .attr('class', 'line') - .style('stroke', function(key) { - return tr.ui.b.getColorOfKey(key); - }) - .attr('d', function(key) { - var line = d3.svg.line() - .x(function(d) { return this.xScale_(d.x); }.bind(this)) - .y(function(d) { return this.yScale_(d[key]); }.bind(this)); - return line(dataBySeriesKey[key]); - }.bind(this)); - pathsSel.exit().remove(); - } - }; - - return { - LineChart: LineChart - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/line_chart_test.html b/chromium/third_party/catapult/tracing/tracing/ui/base/line_chart_test.html deleted file mode 100644 index 5a6cc13b754..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/line_chart_test.html +++ /dev/null @@ -1,163 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> -<link rel="import" href="/tracing/ui/base/line_chart.html"> -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - test('instantiation_singleSeries', function() { - var chart = new tr.ui.b.LineChart(); - chart.width = 400; - chart.height = 200; - chart.chartTitle = 'Chart title'; - var data = [ - {x: 10, y: 100}, - {x: 20, y: 110}, - {x: 30, y: 100}, - {x: 40, y: 50} - ]; - chart.data = data; - this.addHTMLOutput(chart); - }); - - test('instantiation_twoSeries', function() { - var chart = new tr.ui.b.LineChart(); - - chart.width = 400; - chart.height = 200; - chart.chartTitle = 'Chart title'; - var data = [ - {x: 10, alpha: 100, beta: 50}, - {x: 20, alpha: 110, beta: 75}, - {x: 30, alpha: 100, beta: 125}, - {x: 40, alpha: 50, beta: 125} - ]; - chart.data = data; - - var r = new tr.b.Range(); - r.addValue(20); - r.addValue(40); - chart.brushedRange = r; - - this.addHTMLOutput(chart); - }); - - test('instantiation_twoSparseSeriesWithFirstValueSparse', function() { - var chart = new tr.ui.b.LineChart(); - - chart.width = 400; - chart.height = 200; - chart.chartTitle = 'Chart title'; - var data = [ - {x: 10, alpha: 20, beta: undefined}, - {x: 20, alpha: undefined, beta: 10}, - {x: 30, alpha: 10, beta: undefined}, - {x: 45, alpha: undefined, beta: 20}, - {x: 50, alpha: 30, beta: 30} - ]; - chart.data = data; - - this.addHTMLOutput(chart); - }); - - test('instantiation_twoSparseSeriesWithFirstValueNotSparse', function() { - var chart = new tr.ui.b.LineChart(); - - chart.width = 400; - chart.height = 200; - chart.chartTitle = 'Chart title'; - var data = [ - {x: 10, alpha: 20, beta: 40}, - {x: 20, alpha: undefined, beta: 10}, - {x: 30, alpha: 10, beta: undefined}, - {x: 45, alpha: undefined, beta: 20}, - {x: 50, alpha: 30, beta: undefined} - ]; - chart.data = data; - - this.addHTMLOutput(chart); - }); - - test('brushRangeFromIndices', function() { - var chart = new tr.ui.b.LineChart(); - var data = [ - {x: 10, value: 50}, - {x: 30, value: 60}, - {x: 70, value: 70}, - {x: 80, value: 80}, - {x: 120, value: 90} - ]; - chart.data = data; - var r = new tr.b.Range(); - - // Range min should be 10. - r = chart.computeBrushRangeFromIndices(-2, 1); - assert.equal(r.min, 10); - - // Range max should be 120. - r = chart.computeBrushRangeFromIndices(3, 10); - assert.equal(r.max, 120); - - // Range should be [10, 120] - r = chart.computeBrushRangeFromIndices(-2, 10); - assert.equal(r.min, 10); - assert.equal(r.max, 120); - - // Range should be [20, 100] - r = chart.computeBrushRangeFromIndices(1, 3); - assert.equal(r.min, 20); - assert.equal(r.max, 100); - }); - - test('instantiation_interactiveBrushing', function() { - var chart = new tr.ui.b.LineChart(); - chart.width = 400; - chart.height = 200; - chart.chartTitle = 'Chart title'; - var data = [ - {x: 10, value: 50}, - {x: 20, value: 60}, - {x: 30, value: 80}, - {x: 40, value: 20}, - {x: 50, value: 30}, - {x: 60, value: 20}, - {x: 70, value: 15}, - {x: 80, value: 20} - ]; - chart.data = data; - - var mouseDownIndex = undefined; - var curMouseIndex = undefined; - - function updateBrushedRange() { - if (mouseDownIndex === undefined) { - chart.brushedRange = new tr.b.Range(); - return; - } - chart.brushedRange = chart.computeBrushRangeFromIndices( - mouseDownIndex, curMouseIndex); - } - - chart.addEventListener('item-mousedown', function(e) { - mouseDownIndex = e.index; - curMouseIndex = e.index; - updateBrushedRange(); - }); - chart.addEventListener('item-mousemove', function(e) { - if (e.button == undefined) - return; - curMouseIndex = e.index; - updateBrushedRange(); - }); - chart.addEventListener('item-mouseup', function(e) { - curMouseIndex = e.index; - updateBrushedRange(); - }); - this.addHTMLOutput(chart); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/list_and_associated_view.css b/chromium/third_party/catapult/tracing/tracing/ui/base/list_and_associated_view.css deleted file mode 100644 index 78319f3d8db..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/list_and_associated_view.css +++ /dev/null @@ -1,17 +0,0 @@ -/* Copyright (c) 2012 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -* /deep/ x-list-and-associated-view { - -webkit-flex-direction: row; - display: -webkit-flex; -} - -* /deep/ x-list-and-associated-view > .x-list-view { - min-width: 100px; -} - -* /deep/ x-list-and-associated-view > :nth-child(2) { - -webkit-flex: 1; -} diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/list_and_associated_view.html b/chromium/third_party/catapult/tracing/tracing/ui/base/list_and_associated_view.html deleted file mode 100644 index 3d1d8260954..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/list_and_associated_view.html +++ /dev/null @@ -1,138 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="stylesheet" href="/tracing/ui/base/list_and_associated_view.css"> - -<link rel="import" href="/tracing/ui/base/list_view.html"> -<link rel="import" href="/tracing/ui/base/ui.html"> - -<script> -'use strict'; - -/** - * @fileoverview A list of things, and a viewer for the currently selected - * thing. - */ -tr.exportTo('tr.ui.b', function() { - - /** - * @constructor - */ - var ListAndAssociatedView = tr.ui.b.define('x-list-and-associated-view'); - ListAndAssociatedView.prototype = { - __proto__: HTMLUnknownElement.prototype, - - decorate: function() { - this.list_ = undefined; - this.listProperty_ = undefined; - this.view_ = undefined; - this.viewProperty_ = undefined; - this.listView_ = new tr.ui.b.ListView(); - this.listView_.addEventListener('selection-changed', - this.onSelectionChanged_.bind(this)); - this.placeholder_ = document.createElement('div'); - this.appendChild(this.listView_); - this.appendChild(this.placeholder_); - }, - - get listView() { - return this.listView_; - }, - - get list() { - return this.list_; - }, - - set list(list) { - this.list_ = list; - this.updateChildren_(); - }, - - get listProperty() { - return this.listProperty_; - }, - - set listProperty(listProperty) { - this.listProperty_ = listProperty; - this.updateChildren_(); - }, - - get view() { - return this.view_; - }, - - set view(view) { - this.view_ = view; - this.updateChildren_(); - }, - - get viewProperty() { - return this.viewProperty_; - }, - - set viewProperty(viewProperty) { - this.viewProperty_ = viewProperty; - this.updateChildren_(); - }, - - updateChildren_: function() { - var complete = this.list_ && - this.listProperty_ && - this.view_ && - this.viewProperty_; - if (!complete) { - this.replaceChild(this.placeholder_, - this.children[1]); - return; - } - - for (var i = 0; i < this.list_.length; i++) { - var itemEl; - if (i >= this.listView_.children.length) { - itemEl = document.createElement('div'); - this.listView_.appendChild(itemEl); - } else { - itemEl = this.listView_.children[i]; - } - itemEl.item = this.list_[i]; - var getter = this.list_[i].__lookupGetter__(this.listProperty_); - if (getter) - itemEl.textContent = getter.call(this.list_[i]); - else - itemEl.textContent = this.list_[i][this.listProperty_]; - } - - if (this.children[1] == this.placeholder_) { - this.replaceChild(this.view_, - this.children[1]); - } - if (this.listView_.children.length && - !this.listView_.selectedElement) - this.listView_.selectedElement = this.listView_.children[0]; - }, - - onSelectionChanged_: function(e) { - var setter = this.view_.__lookupSetter__(this.viewProperty_); - if (!setter) { - var prop = this.viewProperty_; - setter = function(value) { this[prop] = value; } - } - if (this.listView_.selectedElement) { - setter.call(this.view_, - this.listView_.selectedElement.item); - } else { - setter.call(this.view_, - undefined); - } - } - }; - - return { - ListAndAssociatedView: ListAndAssociatedView - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/list_and_associated_view_test.html b/chromium/third_party/catapult/tracing/tracing/ui/base/list_and_associated_view_test.html deleted file mode 100644 index f35a8b26861..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/list_and_associated_view_test.html +++ /dev/null @@ -1,98 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> -<link rel="import" href="/tracing/ui/base/list_and_associated_view.html"> -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var ListAndAssociatedView = tr.ui.b.ListAndAssociatedView; - - var SimpleView = tr.ui.b.define('div'); - SimpleView.prototype = { - __proto__: HTMLDivElement.prototype, - - decorate: function() { - this.item_ = undefined; - }, - - set item(item) { - this.item_ = item; - }, - get item() { - return this.item_; - } - }; - - test('listViewNamingWithField', function() { - var lav = new ListAndAssociatedView(); - var list = [ - {x: '1'}, - {x: '2'}, - {x: '3'} - ]; - var view = new SimpleView(); - - lav.list = list; - lav.listProperty = 'x'; - lav.view = view; - lav.viewProperty = 'item'; - - var lavListView = lav.listView; - assert.equal(lavListView.children.length, 3); - assert.equal(lavListView.children[0].textContent, '1'); - }); - - test('listViewNamingWithProperty', function() { - var lav = new ListAndAssociatedView(); - - function X(x) { - this.x = x; - } - X.prototype = { - get title() { - return this.x; - } - }; - - var list = [ - new X('1'), - new X('2'), - new X('3') - ]; - var view = new SimpleView(); - - lav.list = list; - lav.listProperty = 'title'; - lav.view = view; - lav.viewProperty = 'item'; - - var lavListView = lav.listView; - assert.equal(lavListView.children.length, 3); - assert.equal(lavListView.children[0].textContent, '1'); - }); - - test('selectionChangesView', function() { - var lav = new ListAndAssociatedView(); - var list = [ - {x: '1'}, - {x: '2'}, - {x: '3'} - ]; - var view = new SimpleView(); - - lav.list = list; - lav.listProperty = 'x'; - lav.view = view; - lav.viewProperty = 'item'; - var lavListView = lav.listView; - - assert.equal(list[0], view.item); - lavListView.children[1].selected = true; - assert.equal(list[1], view.item); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/list_view.css b/chromium/third_party/catapult/tracing/tracing/ui/base/list_view.css deleted file mode 100644 index 0a9ef18ed67..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/list_view.css +++ /dev/null @@ -1,30 +0,0 @@ -/* Copyright (c) 2012 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -* /deep/ .x-list-view { - -webkit-user-select: none; - display: block; -} -* /deep/ .x-list-view:focus { - outline: none; -} - -* /deep/ .x-list-view * { - -webkit-user-select: none; -} - -* /deep/ .x-list-view > .list-item { - padding: 2px 4px 2px 4px; -} - -* /deep/ .x-list-view:focus > .list-item[selected] { - background-color: rgb(171, 217, 202); - outline: 1px dotted rgba(0,0,0,0.1); - outline-offset: 0; -} - -* /deep/ .x-list-view > .list-item[selected] { - background-color: rgb(103, 199, 165); -} diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/list_view.html b/chromium/third_party/catapult/tracing/tracing/ui/base/list_view.html deleted file mode 100644 index c8279565620..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/list_view.html +++ /dev/null @@ -1,167 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="stylesheet" href="/tracing/ui/base/list_view.css"> - -<link rel="import" href="/tracing/base/event.html"> -<link rel="import" href="/tracing/ui/base/container_that_decorates_its_children.html"> -<link rel="import" href="/tracing/ui/base/ui.html"> -<link rel="import" href="/tracing/ui/base/utils.html"> - -<script> -'use strict'; - -/** - * @fileoverview Simple list view. - */ -tr.exportTo('tr.ui.b', function() { - /** - * @constructor - */ - var ListView = tr.ui.b.define( - 'x-list-view', tr.ui.b.ContainerThatDecoratesItsChildren); - - ListView.prototype = { - __proto__: tr.ui.b.ContainerThatDecoratesItsChildren.prototype, - - decorate: function() { - tr.ui.b.ContainerThatDecoratesItsChildren.prototype.decorate.call(this); - - this.classList.add('x-list-view'); - this.onItemClicked_ = this.onItemClicked_.bind(this); - this.onKeyDown_ = this.onKeyDown_.bind(this); - this.tabIndex = 0; - this.addEventListener('keydown', this.onKeyDown_); - - this.selectionChanged_ = false; - }, - - decorateChild_: function(item) { - item.classList.add('list-item'); - item.addEventListener('click', this.onItemClicked_, true); - - var listView = this; - Object.defineProperty( - item, - 'selected', { - configurable: true, - set: function(value) { - var oldSelection = listView.selectedElement; - if (oldSelection && oldSelection != this && value) - listView.selectedElement.removeAttribute('selected'); - if (value) - this.setAttribute('selected', 'selected'); - else - this.removeAttribute('selected'); - var newSelection = listView.selectedElement; - if (newSelection != oldSelection) - tr.b.dispatchSimpleEvent(listView, 'selection-changed', false); - }, - get: function() { - return this.hasAttribute('selected'); - } - }); - }, - - undecorateChild_: function(item) { - this.selectionChanged_ |= item.selected; - - item.classList.remove('list-item'); - item.removeEventListener('click', this.onItemClicked_); - delete item.selected; - }, - - beginDecorating_: function() { - this.selectionChanged_ = false; - }, - - doneDecoratingForNow_: function() { - if (this.selectionChanged_) - tr.b.dispatchSimpleEvent(this, 'selection-changed', false); - }, - - get selectedElement() { - var el = this.querySelector('.list-item[selected]'); - if (!el) - return undefined; - return el; - }, - - set selectedElement(el) { - if (!el) { - if (this.selectedElement) - this.selectedElement.selected = false; - return; - } - - if (el.parentElement != this) - throw new Error( - 'Can only select elements that are children of this list view'); - el.selected = true; - }, - - getElementByIndex: function(index) { - return this.querySelector('.list-item:nth-child(' + index + ')'); - }, - - clear: function() { - var changed = this.selectedElement !== undefined; - tr.ui.b.ContainerThatDecoratesItsChildren.prototype.clear.call(this); - if (changed) - tr.b.dispatchSimpleEvent(this, 'selection-changed', false); - }, - - onItemClicked_: function(e) { - var currentSelectedElement = this.selectedElement; - if (currentSelectedElement) - currentSelectedElement.removeAttribute('selected'); - var element = e.target; - while (element.parentElement != this) - element = element.parentElement; - if (element !== currentSelectedElement) - element.setAttribute('selected', 'selected'); - tr.b.dispatchSimpleEvent(this, 'selection-changed', false); - }, - - onKeyDown_: function(e) { - if (this.selectedElement === undefined) - return; - - if (e.keyCode == 38) { // Up arrow. - var prev = this.selectedElement.previousSibling; - if (prev) { - prev.selected = true; - tr.ui.b.scrollIntoViewIfNeeded(prev); - e.preventDefault(); - return true; - } - } else if (e.keyCode == 40) { // Down arrow. - var next = this.selectedElement.nextSibling; - if (next) { - next.selected = true; - tr.ui.b.scrollIntoViewIfNeeded(next); - e.preventDefault(); - return true; - } - } - }, - - addItem: function(textContent) { - var item = document.createElement('div'); - item.textContent = textContent; - this.appendChild(item); - return item; - } - - }; - - return { - ListView: ListView - }; - -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/list_view_test.html b/chromium/third_party/catapult/tracing/tracing/ui/base/list_view_test.html deleted file mode 100644 index 4f068437088..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/list_view_test.html +++ /dev/null @@ -1,67 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> -<link rel="import" href="/tracing/ui/base/list_view.html"> -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var ListView = tr.ui.b.ListView; - - test('instantiate', function() { - var view = new ListView(); - var i1 = view.addItem('item 1'); - var i2 = view.addItem('item 2'); - var i3 = view.addItem('item 3'); - this.addHTMLOutput(view); - }); - - test('programmaticSelection', function() { - var view = new ListView(); - var i1 = view.addItem('item 1'); - var i2 = view.addItem('item 2'); - var i3 = view.addItem('item 3'); - - i2.selected = true; - assert.isTrue(i2.hasAttribute('selected')); - i3.selected = true; - assert.isFalse(i2.hasAttribute('selected')); - assert.isTrue(i3.hasAttribute('selected')); - }); - - test('clickSelection', function() { - var view = new ListView(); - var didFireSelectionChange = false; - view.addEventListener('selection-changed', function() { - didFireSelectionChange = true; - }); - var i1 = view.addItem('item 1'); - var i2 = view.addItem('item 2'); - var i3 = view.addItem('item 3'); - - didFireSelectionChange = false; - i2.click(); - assert.isTrue(didFireSelectionChange); - assert.equal(view.selectedElement, i2); - - didFireSelectionChange = false; - i3.click(); - assert.isTrue(didFireSelectionChange); - assert.equal(view.selectedElement, i3); - - // Click the same target again. - didFireSelectionChange = false; - i3.click(); - assert.isTrue(didFireSelectionChange); - assert.isUndefined(view.selectedElement); - - didFireSelectionChange = false; - i1.click(); - assert.isTrue(didFireSelectionChange); - assert.equal(view.selectedElement, i1); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/mouse_mode_icon.html b/chromium/third_party/catapult/tracing/tracing/ui/base/mouse_mode_icon.html deleted file mode 100644 index f31837e5c1b..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/mouse_mode_icon.html +++ /dev/null @@ -1,112 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> -<link rel="import" href="/tracing/base/iteration_helpers.html"> -<link rel="import" href="/tracing/ui/base/mouse_modes.html"> - -<polymer-element name="tr-ui-b-mouse-mode-icon"> - <template> - <style> - :host { - display: block; - background-image: url(../images/ui-states.png); - width: 27px; - height: 30px; - } - :host.active { - cursor: auto; - } - </style> - </template> - <script> - 'use strict'; - - Polymer({ - publish: { - modeName: { - value: undefined, - reflect: true - } - }, - - created: function() { - this.active_ = false; - this.acceleratorKey_ = undefined; - }, - - ready: function() { - this.updateContents_(); - }, - - get mode() { - return tr.ui.b.MOUSE_SELECTOR_MODE[this.modeName]; - }, - - set mode(mode) { - var modeInfo = tr.ui.b.MOUSE_SELECTOR_MODE_INFOS[mode]; - var modeName = tr.b.findFirstKeyInDictMatching( - tr.ui.b.MOUSE_SELECTOR_MODE, - function(modeName, candidateMode) { - return candidateMode === mode; - }); - if (modeName === undefined) - throw new Error('Unknown mode'); - this.modeName = modeName; - }, - - modeNameChanged: function() { - this.updateContents_(); - }, - - get active() { - return this.active_; - }, - - set active(active) { - this.active_ = !!active; - if (this.active_) - this.classList.add('active'); - else - this.classList.remove('active'); - this.updateContents_(); - }, - - get acceleratorKey() { - return this.acceleratorKey_; - }, - - set acceleratorKey(acceleratorKey) { - this.acceleratorKey_ = acceleratorKey; - this.updateContents_(); - }, - - updateContents_: function() { - if (this.modeName === undefined) - return; - - var mode = this.mode; - if (mode === undefined) - throw new Error('Invalid mode'); - - var modeInfo = tr.ui.b.MOUSE_SELECTOR_MODE_INFOS[mode]; - if (!modeInfo) - throw new Error('Invalid mode'); - - var title = modeInfo.title; - if (this.acceleratorKey_) - title = title + ' (' + this.acceleratorKey_ + ')'; - this.title = title; - - var bp; - if (this.active_) - bp = modeInfo.activeBackgroundPosition; - else - bp = modeInfo.defaultBackgroundPosition; - this.style.backgroundPosition = bp; - } - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/mouse_mode_icon_test.html b/chromium/third_party/catapult/tracing/tracing/ui/base/mouse_mode_icon_test.html deleted file mode 100644 index 905a1bbcf0d..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/mouse_mode_icon_test.html +++ /dev/null @@ -1,41 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> -<link rel="import" href="/tracing/base/settings.html"> -<link rel="import" href="/tracing/ui/base/mouse_mode_icon.html"> -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var MOUSE_SELECTOR_MODE = tr.ui.b.MOUSE_SELECTOR_MODE; - - test('inactive', function() { - var icon = document.createElement('tr-ui-b-mouse-mode-icon'); - icon.mode = MOUSE_SELECTOR_MODE.SELECTION; - assert.equal(icon.modeName, 'SELECTION'); - icon.acceleratorKey = 'a'; - this.addHTMLOutput(icon); - }); - - test('active', function() { - var icon = document.createElement('tr-ui-b-mouse-mode-icon'); - icon.mode = MOUSE_SELECTOR_MODE.SELECTION; - assert.equal(icon.modeName, 'SELECTION'); - icon.active = true; - this.addHTMLOutput(icon); - }); - - test('modeNameSetter', function() { - var icon = document.createElement('tr-ui-b-mouse-mode-icon'); - icon.setAttribute('modeName', 'SELECTION'); - this.addHTMLOutput(icon); - - return Promise.resolve().then(function() { - assert.equal(icon.mode, 1); - }); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/mouse_mode_selector.html b/chromium/third_party/catapult/tracing/tracing/ui/base/mouse_mode_selector.html deleted file mode 100644 index a8980d5ee8d..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/mouse_mode_selector.html +++ /dev/null @@ -1,574 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/event.html"> -<link rel="import" href="/tracing/base/iteration_helpers.html"> -<link rel="import" href="/tracing/ui/base/hotkey_controller.html"> -<link rel="import" href="/tracing/ui/base/mouse_tracker.html"> -<link rel="import" href="/tracing/ui/base/ui.html"> -<link rel="import" href="/tracing/ui/base/utils.html"> -<link rel="import" href="/tracing/ui/base/mouse_modes.html"> -<link rel="import" href="/tracing/ui/base/mouse_mode_icon.html"> - -<polymer-element name="tr-ui-b-mouse-mode-selector"> - <template> - <style> - :host { - - -webkit-user-drag: element; - -webkit-user-select: none; - - background: #DDD; - border: 1px solid #BBB; - border-radius: 4px; - box-shadow: 0 1px 2px rgba(0,0,0,0.2); - left: calc(100% - 120px); - position: absolute; - top: 100px; - user-select: none; - width: 29px; - z-index: 20; - } - - .drag-handle { - background: url(../images/ui-states.png) 2px 3px no-repeat; - background-repeat: no-repeat; - border-bottom: 1px solid #BCBCBC; - cursor: move; - display: block; - height: 13px; - width: 27px; - } - - .tool-button { - background-position: center center; - background-repeat: no-repeat; - border-bottom: 1px solid #BCBCBC; - border-top: 1px solid #F1F1F1; - cursor: pointer; - } - - .buttons > .tool-button:last-child { - border-bottom: none; - } - - </style> - <div class="drag-handle"></div> - <div class="buttons"> - </div> - </template> -</polymer-element> -<script> -'use strict'; - -tr.exportTo('tr.ui.b', function() { - var MOUSE_SELECTOR_MODE = tr.ui.b.MOUSE_SELECTOR_MODE; - var MOUSE_SELECTOR_MODE_INFOS = tr.ui.b.MOUSE_SELECTOR_MODE_INFOS; - - - var MIN_MOUSE_SELECTION_DISTANCE = 4; - - var MODIFIER = { - SHIFT: 0x1, - SPACE: 0x2, - CMD_OR_CTRL: 0x4 - }; - - function isCmdOrCtrlPressed(event) { - if (tr.isMac) - return event.metaKey; - else - return event.ctrlKey; - } - - /** - * Provides a panel for switching the interaction mode of the mouse. - * It handles the user interaction and dispatches events for the various - * modes. - */ - Polymer('tr-ui-b-mouse-mode-selector', { - __proto__: HTMLDivElement.prototype, - - created: function() { - this.supportedModeMask_ = MOUSE_SELECTOR_MODE.ALL_MODES; - - this.initialRelativeMouseDownPos_ = {x: 0, y: 0}; - - this.defaultMode_ = MOUSE_SELECTOR_MODE.PANSCAN; - this.settingsKey_ = undefined; - this.mousePos_ = {x: 0, y: 0}; - this.mouseDownPos_ = {x: 0, y: 0}; - - this.onMouseDown_ = this.onMouseDown_.bind(this); - this.onMouseMove_ = this.onMouseMove_.bind(this); - this.onMouseUp_ = this.onMouseUp_.bind(this); - - this.onKeyDown_ = this.onKeyDown_.bind(this); - this.onKeyUp_ = this.onKeyUp_.bind(this); - - this.mode_ = undefined; - this.modeToKeyCodeMap_ = {}; - this.modifierToModeMap_ = {}; - - this.targetElement_ = undefined; - this.modeBeforeAlternativeModeActivated_ = null; - - this.isInteracting_ = false; - this.isClick_ = false; - }, - - ready: function() { - this.buttonsEl_ = this.shadowRoot.querySelector('.buttons'); - this.dragHandleEl_ = this.shadowRoot.querySelector('.drag-handle'); - this.supportedModeMask = MOUSE_SELECTOR_MODE.ALL_MODES; - - this.dragHandleEl_.addEventListener('mousedown', - this.onDragHandleMouseDown_.bind(this)); - - this.buttonsEl_.addEventListener('mouseup', this.onButtonMouseUp_); - this.buttonsEl_.addEventListener('mousedown', this.onButtonMouseDown_); - this.buttonsEl_.addEventListener('click', this.onButtonPress_.bind(this)); - }, - - attached: function() { - document.addEventListener('keydown', this.onKeyDown_); - document.addEventListener('keyup', this.onKeyUp_); - }, - - detached: function() { - document.removeEventListener('keydown', this.onKeyDown_); - document.removeEventListener('keyup', this.onKeyUp_); - }, - - get targetElement() { - return this.targetElement_; - }, - - set targetElement(target) { - if (this.targetElement_) - this.targetElement_.removeEventListener('mousedown', this.onMouseDown_); - this.targetElement_ = target; - if (this.targetElement_) - this.targetElement_.addEventListener('mousedown', this.onMouseDown_); - }, - - get defaultMode() { - return this.defaultMode_; - }, - - set defaultMode(defaultMode) { - this.defaultMode_ = defaultMode; - }, - - get settingsKey() { - return this.settingsKey_; - }, - - set settingsKey(settingsKey) { - this.settingsKey_ = settingsKey; - if (!this.settingsKey_) - return; - - var mode = tr.b.Settings.get(this.settingsKey_ + '.mode', undefined); - // Modes changed from 1,2,3,4 to 0x1, 0x2, 0x4, 0x8. Fix any stray - // settings to the best of our abilities. - if (MOUSE_SELECTOR_MODE_INFOS[mode] === undefined) - mode = undefined; - - // Restoring settings against unsupported modes should just go back to the - // default mode. - if ((mode & this.supportedModeMask_) === 0) - mode = undefined; - - if (!mode) - mode = this.defaultMode_; - this.mode = mode; - - var pos = tr.b.Settings.get(this.settingsKey_ + '.pos', undefined); - if (pos) - this.pos = pos; - }, - - get supportedModeMask() { - return this.supportedModeMask_; - }, - - /** - * Sets the supported modes. Should be an OR-ing of MOUSE_SELECTOR_MODE - * values. - */ - set supportedModeMask(supportedModeMask) { - if (this.mode && (supportedModeMask & this.mode) === 0) - throw new Error('supportedModeMask must include current mode.'); - - function createButtonForMode(mode) { - return button; - } - - this.supportedModeMask_ = supportedModeMask; - this.buttonsEl_.textContent = ''; - for (var modeName in MOUSE_SELECTOR_MODE) { - if (modeName == 'ALL_MODES') - continue; - var mode = MOUSE_SELECTOR_MODE[modeName]; - if ((this.supportedModeMask_ & mode) === 0) - continue; - - var button = document.createElement('tr-ui-b-mouse-mode-icon'); - button.mode = mode; - button.classList.add('tool-button'); - - this.buttonsEl_.appendChild(button); - } - }, - - getButtonForMode_: function(mode) { - for (var i = 0; i < this.buttonsEl_.children.length; i++) { - var buttonEl = this.buttonsEl_.children[i]; - if (buttonEl.mode === mode) - return buttonEl; - } - return undefined; - }, - - get mode() { - return this.currentMode_; - }, - - set mode(newMode) { - if (newMode !== undefined) { - if (typeof newMode !== 'number') - throw new Error('Mode must be a number'); - if ((newMode & this.supportedModeMask_) === 0) - throw new Error('Cannot switch to this mode, it is not supported'); - if (MOUSE_SELECTOR_MODE_INFOS[newMode] === undefined) - throw new Error('Unrecognized mode'); - } - - var modeInfo; - - if (this.currentMode_ === newMode) - return; - - if (this.currentMode_) { - var buttonEl = this.getButtonForMode_(this.currentMode_); - if (buttonEl) - buttonEl.active = false; - - // End event. - if (this.isInteracting_) { - - var mouseEvent = this.createEvent_( - MOUSE_SELECTOR_MODE_INFOS[this.mode].eventNames.end); - this.dispatchEvent(mouseEvent); - } - - // Exit event. - modeInfo = MOUSE_SELECTOR_MODE_INFOS[this.currentMode_]; - tr.b.dispatchSimpleEvent(this, modeInfo.eventNames.exit, true); - } - - this.currentMode_ = newMode; - - if (this.currentMode_) { - var buttonEl = this.getButtonForMode_(this.currentMode_); - if (buttonEl) - buttonEl.active = true; - - // Entering a new mode resets mouse down pos. - this.mouseDownPos_.x = this.mousePos_.x; - this.mouseDownPos_.y = this.mousePos_.y; - - // Enter event. - modeInfo = MOUSE_SELECTOR_MODE_INFOS[this.currentMode_]; - if (!this.isInAlternativeMode_) - tr.b.dispatchSimpleEvent(this, modeInfo.eventNames.enter, true); - - // Begin event. - if (this.isInteracting_) { - var mouseEvent = this.createEvent_( - MOUSE_SELECTOR_MODE_INFOS[this.mode].eventNames.begin); - this.dispatchEvent(mouseEvent); - } - - - } - - if (this.settingsKey_ && !this.isInAlternativeMode_) - tr.b.Settings.set(this.settingsKey_ + '.mode', this.mode); - }, - - setKeyCodeForMode: function(mode, keyCode) { - if ((mode & this.supportedModeMask_) === 0) - throw new Error('Mode not supported'); - this.modeToKeyCodeMap_[mode] = keyCode; - - if (!this.buttonsEl_) - return; - - var buttonEl = this.getButtonForMode_(mode); - if (buttonEl) - buttonEl.acceleratorKey = String.fromCharCode(keyCode); - }, - - setCurrentMousePosFromEvent_: function(e) { - this.mousePos_.x = e.clientX; - this.mousePos_.y = e.clientY; - }, - - createEvent_: function(eventName, sourceEvent) { - var event = new tr.b.Event(eventName, true); - event.clientX = this.mousePos_.x; - event.clientY = this.mousePos_.y; - event.deltaX = this.mousePos_.x - this.mouseDownPos_.x; - event.deltaY = this.mousePos_.y - this.mouseDownPos_.y; - event.mouseDownX = this.mouseDownPos_.x; - event.mouseDownY = this.mouseDownPos_.y; - event.didPreventDefault = false; - event.preventDefault = function() { - event.didPreventDefault = true; - if (sourceEvent) - sourceEvent.preventDefault(); - }; - event.stopPropagation = function() { - sourceEvent.stopPropagation(); - }; - event.stopImmediatePropagation = function() { - throw new Error('Not implemented'); - }; - return event; - }, - - onMouseDown_: function(e) { - if (e.button !== 0) - return; - this.setCurrentMousePosFromEvent_(e); - var mouseEvent = this.createEvent_( - MOUSE_SELECTOR_MODE_INFOS[this.mode].eventNames.begin, e); - if (this.mode === MOUSE_SELECTOR_MODE.SELECTION) - mouseEvent.appendSelection = isCmdOrCtrlPressed(e); - this.dispatchEvent(mouseEvent); - this.isInteracting_ = true; - this.isClick_ = true; - tr.ui.b.trackMouseMovesUntilMouseUp(this.onMouseMove_, this.onMouseUp_); - }, - - onMouseMove_: function(e) { - this.setCurrentMousePosFromEvent_(e); - - var mouseEvent = this.createEvent_( - MOUSE_SELECTOR_MODE_INFOS[this.mode].eventNames.update, e); - this.dispatchEvent(mouseEvent); - - if (this.isInteracting_) - this.checkIsClick_(e); - }, - - onMouseUp_: function(e) { - if (e.button !== 0) - return; - - var mouseEvent = this.createEvent_( - MOUSE_SELECTOR_MODE_INFOS[this.mode].eventNames.end, e); - mouseEvent.isClick = this.isClick_; - this.dispatchEvent(mouseEvent); - - if (this.isClick_ && !mouseEvent.didPreventDefault) - this.dispatchClickEvents_(e); - - this.isInteracting_ = false; - this.updateAlternativeModeState_(e); - }, - - onButtonMouseDown_: function(e) { - e.preventDefault(); - e.stopImmediatePropagation(); - }, - - onButtonMouseUp_: function(e) { - e.preventDefault(); - e.stopImmediatePropagation(); - }, - - onButtonPress_: function(e) { - this.modeBeforeAlternativeModeActivated_ = undefined; - this.mode = e.target.mode; - e.preventDefault(); - }, - - onKeyDown_: function(e) { - // Keys dispatched to INPUT elements still bubble, even when they're - // handled. So, skip any events that targeted the input element. - if (e.path[0].tagName == 'INPUT') - return; - - if (e.keyCode === ' '.charCodeAt(0)) - this.spacePressed_ = true; - this.updateAlternativeModeState_(e); - }, - - onKeyUp_: function(e) { - // Keys dispatched to INPUT elements still bubble, even when they're - // handled. So, skip any events that targeted the input element. - if (e.path[0].tagName == 'INPUT') - return; - - if (e.keyCode === ' '.charCodeAt(0)) - this.spacePressed_ = false; - - var didHandleKey = false; - tr.b.iterItems(this.modeToKeyCodeMap_, function(modeStr, keyCode) { - if (e.keyCode === keyCode) { - this.modeBeforeAlternativeModeActivated_ = undefined; - var mode = parseInt(modeStr); - this.mode = mode; - didHandleKey = true; - } - }, this); - - if (didHandleKey) { - e.preventDefault(); - e.stopPropagation(); - return; - } - this.updateAlternativeModeState_(e); - }, - - updateAlternativeModeState_: function(e) { - var shiftPressed = e.shiftKey; - var spacePressed = this.spacePressed_; - var cmdOrCtrlPressed = isCmdOrCtrlPressed(e); - - // Figure out the new mode - var smm = this.supportedModeMask_; - var newMode; - var isNewModeAnAlternativeMode = false; - if (shiftPressed && - (this.modifierToModeMap_[MODIFIER.SHIFT] & smm) !== 0) { - newMode = this.modifierToModeMap_[MODIFIER.SHIFT]; - isNewModeAnAlternativeMode = true; - } else if (spacePressed && - (this.modifierToModeMap_[MODIFIER.SPACE] & smm) !== 0) { - newMode = this.modifierToModeMap_[MODIFIER.SPACE]; - isNewModeAnAlternativeMode = true; - } else if (cmdOrCtrlPressed && - (this.modifierToModeMap_[MODIFIER.CMD_OR_CTRL] & smm) !== 0) { - newMode = this.modifierToModeMap_[MODIFIER.CMD_OR_CTRL]; - isNewModeAnAlternativeMode = true; - } else { - // Go to the old mode, if there is one. - if (this.isInAlternativeMode_) { - newMode = this.modeBeforeAlternativeModeActivated_; - isNewModeAnAlternativeMode = false; - } else { - newMode = undefined; - } - } - - // Maybe a mode change isn't needed. - if (this.mode === newMode || newMode === undefined) - return; - - // Okay, we're changing. - if (isNewModeAnAlternativeMode) - this.modeBeforeAlternativeModeActivated_ = this.mode; - this.mode = newMode; - }, - - get isInAlternativeMode_() { - return !!this.modeBeforeAlternativeModeActivated_; - }, - - setModifierForAlternateMode: function(mode, modifier) { - this.modifierToModeMap_[modifier] = mode; - }, - - get pos() { - return { - x: parseInt(this.style.left), - y: parseInt(this.style.top) - }; - }, - - set pos(pos) { - pos = this.constrainPositionToBounds_(pos); - - this.style.left = pos.x + 'px'; - this.style.top = pos.y + 'px'; - - if (this.settingsKey_) - tr.b.Settings.set(this.settingsKey_ + '.pos', this.pos); - }, - - constrainPositionToBounds_: function(pos) { - var parent = this.offsetParent || document.body; - var parentRect = tr.ui.b.windowRectForElement(parent); - - var top = 0; - var bottom = parentRect.height - this.offsetHeight; - var left = 0; - var right = parentRect.width - this.offsetWidth; - - var res = {}; - res.x = Math.max(pos.x, left); - res.x = Math.min(res.x, right); - - res.y = Math.max(pos.y, top); - res.y = Math.min(res.y, bottom); - return res; - }, - - onDragHandleMouseDown_: function(e) { - e.preventDefault(); - e.stopImmediatePropagation(); - - var mouseDownPos = { - x: e.clientX - this.offsetLeft, - y: e.clientY - this.offsetTop - }; - tr.ui.b.trackMouseMovesUntilMouseUp(function(e) { - var pos = {}; - pos.x = e.clientX - mouseDownPos.x; - pos.y = e.clientY - mouseDownPos.y; - this.pos = pos; - }.bind(this)); - }, - - checkIsClick_: function(e) { - if (!this.isInteracting_ || !this.isClick_) - return; - - var deltaX = this.mousePos_.x - this.mouseDownPos_.x; - var deltaY = this.mousePos_.y - this.mouseDownPos_.y; - var minDist = MIN_MOUSE_SELECTION_DISTANCE; - - if (deltaX * deltaX + deltaY * deltaY > minDist * minDist) - this.isClick_ = false; - }, - - dispatchClickEvents_: function(e) { - if (!this.isClick_) - return; - - var modeInfo = MOUSE_SELECTOR_MODE_INFOS[MOUSE_SELECTOR_MODE.SELECTION]; - var eventNames = modeInfo.eventNames; - - var mouseEvent = this.createEvent_(eventNames.begin); - mouseEvent.appendSelection = isCmdOrCtrlPressed(e); - this.dispatchEvent(mouseEvent); - - mouseEvent = this.createEvent_(eventNames.end); - this.dispatchEvent(mouseEvent); - } - }); - - return { - MIN_MOUSE_SELECTION_DISTANCE: MIN_MOUSE_SELECTION_DISTANCE, - MODIFIER: MODIFIER - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/mouse_mode_selector_test.html b/chromium/third_party/catapult/tracing/tracing/ui/base/mouse_mode_selector_test.html deleted file mode 100644 index 56719d76bd6..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/mouse_mode_selector_test.html +++ /dev/null @@ -1,44 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> -<link rel="import" href="/tracing/base/settings.html"> -<link rel="import" href="/tracing/ui/base/mouse_mode_selector.html"> -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var MOUSE_SELECTOR_MODE = tr.ui.b.MOUSE_SELECTOR_MODE; - test('instantiate', function() { - var sel = document.createElement('tr-ui-b-mouse-mode-selector'); - sel.supportedModeMask = - MOUSE_SELECTOR_MODE.SELECTION | - MOUSE_SELECTOR_MODE.PANSCAN; - this.addHTMLOutput(sel); - }); - - test('changeMaskWithUnsupportedMode', function() { - var sel = document.createElement('tr-ui-b-mouse-mode-selector'); - sel.mode = MOUSE_SELECTOR_MODE.SELECTION; - assert.throw(function() { - sel.supportedModeMask = MOUSE_SELECTOR_MODE.ZOOM; - }); - }); - - test('modePersists', function() { - var sel1 = document.createElement('tr-ui-b-mouse-mode-selector'); - sel1.defaultMode_ = MOUSE_SELECTOR_MODE.ZOOM; - sel1.settingsKey = 'foo'; - assert.equal(sel1.mode, MOUSE_SELECTOR_MODE.ZOOM); - - sel1.mode = MOUSE_SELECTOR_MODE.PANSCAN; - - var sel2 = document.createElement('tr-ui-b-mouse-mode-selector'); - sel2.settingsKey = 'foo'; - assert.equal(sel2.mode, MOUSE_SELECTOR_MODE.PANSCAN); - }); - -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/mouse_modes.html b/chromium/third_party/catapult/tracing/tracing/ui/base/mouse_modes.html deleted file mode 100644 index 9387ef2ce68..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/mouse_modes.html +++ /dev/null @@ -1,93 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> -<link rel="import" href="/tracing/base/base.html"> -<script> -'use strict'; - -tr.exportTo('tr.ui.b', function() { - var MOUSE_SELECTOR_MODE = {}; - MOUSE_SELECTOR_MODE.SELECTION = 0x1; - MOUSE_SELECTOR_MODE.PANSCAN = 0x2; - MOUSE_SELECTOR_MODE.ZOOM = 0x4; - MOUSE_SELECTOR_MODE.TIMING = 0x8; - MOUSE_SELECTOR_MODE.ROTATE = 0x10; - MOUSE_SELECTOR_MODE.ALL_MODES = 0x1F; - - var MOUSE_SELECTOR_MODE_INFOS = {}; - MOUSE_SELECTOR_MODE_INFOS[MOUSE_SELECTOR_MODE.PANSCAN] = { - mode: MOUSE_SELECTOR_MODE.PANSCAN, - title: 'pan', - eventNames: { - enter: 'enterpan', - begin: 'beginpan', - update: 'updatepan', - end: 'endpan', - exit: 'exitpan' - }, - activeBackgroundPosition: '-30px -10px', - defaultBackgroundPosition: '0 -10px' - }; - MOUSE_SELECTOR_MODE_INFOS[MOUSE_SELECTOR_MODE.SELECTION] = { - mode: MOUSE_SELECTOR_MODE.SELECTION, - title: 'selection', - eventNames: { - enter: 'enterselection', - begin: 'beginselection', - update: 'updateselection', - end: 'endselection', - exit: 'exitselection' - }, - activeBackgroundPosition: '-30px -40px', - defaultBackgroundPosition: '0 -40px' - }; - - MOUSE_SELECTOR_MODE_INFOS[MOUSE_SELECTOR_MODE.ZOOM] = { - mode: MOUSE_SELECTOR_MODE.ZOOM, - title: 'zoom', - eventNames: { - enter: 'enterzoom', - begin: 'beginzoom', - update: 'updatezoom', - end: 'endzoom', - exit: 'exitzoom' - }, - activeBackgroundPosition: '-30px -70px', - defaultBackgroundPosition: '0 -70px' - }; - MOUSE_SELECTOR_MODE_INFOS[MOUSE_SELECTOR_MODE.TIMING] = { - mode: MOUSE_SELECTOR_MODE.TIMING, - title: 'timing', - eventNames: { - enter: 'entertiming', - begin: 'begintiming', - update: 'updatetiming', - end: 'endtiming', - exit: 'exittiming' - }, - activeBackgroundPosition: '-30px -100px', - defaultBackgroundPosition: '0 -100px' - }; - MOUSE_SELECTOR_MODE_INFOS[MOUSE_SELECTOR_MODE.ROTATE] = { - mode: MOUSE_SELECTOR_MODE.ROTATE, - title: 'rotate', - eventNames: { - enter: 'enterrotate', - begin: 'beginrotate', - update: 'updaterotate', - end: 'endrotate', - exit: 'exitrotate' - }, - activeBackgroundPosition: '-30px -130px', - defaultBackgroundPosition: '0 -130px' - }; - - return { - MOUSE_SELECTOR_MODE_INFOS: MOUSE_SELECTOR_MODE_INFOS, - MOUSE_SELECTOR_MODE: MOUSE_SELECTOR_MODE - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/mouse_tracker.html b/chromium/third_party/catapult/tracing/tracing/ui/base/mouse_tracker.html deleted file mode 100644 index 3ee8c77b49b..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/mouse_tracker.html +++ /dev/null @@ -1,114 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> -<link rel="import" href="/tracing/base/base.html"> -<script> -'use strict'; - -/** - * @fileoverview A Mouse-event abtraction that waits for - * mousedown, then watches for subsequent mousemove events - * until the next mouseup event, then waits again. - * State changes are signaled with - * 'mouse-tracker-start' : mousedown and tracking - * 'mouse-tracker-move' : mouse move - * 'mouse-tracker-end' : mouseup and not tracking. - */ - -tr.exportTo('tr.ui.b', function() { - - /** - * @constructor - * @param {HTMLElement} targetElement will recv events 'mouse-tracker-start', - * 'mouse-tracker-move', 'mouse-tracker-end'. - */ - function MouseTracker(opt_targetElement) { - this.onMouseDown_ = this.onMouseDown_.bind(this); - this.onMouseMove_ = this.onMouseMove_.bind(this); - this.onMouseUp_ = this.onMouseUp_.bind(this); - - this.targetElement = opt_targetElement; - } - - MouseTracker.prototype = { - - get targetElement() { - return this.targetElement_; - }, - - set targetElement(targetElement) { - if (this.targetElement_) - this.targetElement_.removeEventListener('mousedown', this.onMouseDown_); - this.targetElement_ = targetElement; - if (this.targetElement_) - this.targetElement_.addEventListener('mousedown', this.onMouseDown_); - }, - - onMouseDown_: function(e) { - if (e.button !== 0) - return true; - - e = this.remakeEvent_(e, 'mouse-tracker-start'); - this.targetElement_.dispatchEvent(e); - document.addEventListener('mousemove', this.onMouseMove_); - document.addEventListener('mouseup', this.onMouseUp_); - this.targetElement_.addEventListener('blur', this.onMouseUp_); - this.savePreviousUserSelect_ = document.body.style['-webkit-user-select']; - document.body.style['-webkit-user-select'] = 'none'; - e.preventDefault(); - return true; - }, - - onMouseMove_: function(e) { - e = this.remakeEvent_(e, 'mouse-tracker-move'); - this.targetElement_.dispatchEvent(e); - }, - - onMouseUp_: function(e) { - document.removeEventListener('mousemove', this.onMouseMove_); - document.removeEventListener('mouseup', this.onMouseUp_); - this.targetElement_.removeEventListener('blur', this.onMouseUp_); - document.body.style['-webkit-user-select'] = - this.savePreviousUserSelect_; - e = this.remakeEvent_(e, 'mouse-tracker-end'); - this.targetElement_.dispatchEvent(e); - }, - - remakeEvent_: function(e, newType) { - var remade = new tr.b.Event(newType, true, true); - remade.x = e.x; - remade.y = e.y; - remade.offsetX = e.offsetX; - remade.offsetY = e.offsetY; - remade.clientX = e.clientX; - remade.clientY = e.clientY; - return remade; - } - - }; - - function trackMouseMovesUntilMouseUp(mouseMoveHandler, - opt_mouseUpHandler, opt_keyUpHandler) { - function cleanupAndDispatchToMouseUp(e) { - document.removeEventListener('mousemove', mouseMoveHandler); - if (opt_keyUpHandler) - document.removeEventListener('keyup', opt_keyUpHandler); - document.removeEventListener('mouseup', cleanupAndDispatchToMouseUp); - if (opt_mouseUpHandler) - opt_mouseUpHandler(e); - } - document.addEventListener('mousemove', mouseMoveHandler); - if (opt_keyUpHandler) - document.addEventListener('keyup', opt_keyUpHandler); - document.addEventListener('mouseup', cleanupAndDispatchToMouseUp); - } - - return { - MouseTracker: MouseTracker, - trackMouseMovesUntilMouseUp: trackMouseMovesUntilMouseUp - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/name_bar_chart.html b/chromium/third_party/catapult/tracing/tracing/ui/base/name_bar_chart.html deleted file mode 100644 index dcfdbaa17c6..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/name_bar_chart.html +++ /dev/null @@ -1,95 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/range.html"> -<link rel="import" href="/tracing/ui/base/d3.html"> -<link rel="import" href="/tracing/ui/base/bar_chart.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.b', function() { - var BarChart = tr.ui.b.BarChart; - - // @constructor - var NameBarChart = tr.ui.b.define('name-bar-chart', BarChart); - - NameBarChart.prototype = { - __proto__: BarChart.prototype, - - decorate: function() { - BarChart.prototype.decorate.call(this); - this.classList.remove('bar-chart'); - this.classList.add('name-bar-chart'); - this.bottomMargin_ = 40; - }, - - isDatumFieldSeries_: function(fieldName) { - return fieldName != 'x'; - }, - - getXForDatum_: function(datum, index) { - return index; - }, - - getMargin_: function() { - var margin = BarChart.prototype.getMargin_.call(this); - margin.bottom = this.bottomMargin_; - return margin; - }, - - updateXAxis_: function(xAxis) { - xAxis.selectAll('*').remove(); - var y = this.chartAreaSize.height + 10; - var nameTexts = xAxis.selectAll('text') - .data(this.data_); - nameTexts - .enter() - .append('text') - .attr('transform', function(d, index) { - var cx = this.xScale_(index); - // If you change the angle, then check the Math.cos() below. - return 'rotate(45 ' + cx + ' ' + y + ')'; - }.bind(this)) - .attr('x', function(d, index) { - return this.xScale_(index); - }.bind(this)) - .attr('y', function(d) { - return y; - }.bind(this)) - .text(function(d, index) { - return d.x; - }.bind(this)); - nameTexts.exit().remove(); - - // If the nameTexts extend past the bottom of the chart, then increase - // this.bottomMargin_ and re-render. - var bottomMargin = this.bottomMargin_; - window.requestAnimationFrame(function() { - nameTexts[0].forEach(function(t) { - var box = t.getBBox(); - // When the text is rotated, its height is the hypotenuse - // of a small triangle H, and its width is the hypotenuse of a larger - // triangle W. The bottomMargin must be equal to a side of H plus a - // side of W. - var h = Math.cos(Math.PI / 4) * (box.height + box.width); - bottomMargin = Math.max(this.bottomMargin_, h); - }, this); - - if (Math.round(bottomMargin) !== Math.round(this.bottomMargin_)) { - this.bottomMargin_ = bottomMargin; - this.updateContents_(); - } - }.bind(this)); - } - }; - - return { - NameBarChart: NameBarChart - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/name_bar_chart_test.html b/chromium/third_party/catapult/tracing/tracing/ui/base/name_bar_chart_test.html deleted file mode 100644 index 341a5a8fcb7..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/name_bar_chart_test.html +++ /dev/null @@ -1,172 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/base/name_bar_chart.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - test('instantiation_singleSeries', function() { - var chart = new tr.ui.b.NameBarChart(); - chart.width = 200; - chart.height = 200; - chart.chartTitle = 'Chart title'; - var data = [ - {x: 'apple', value: 100}, - {x: 'ball', value: 110}, - {x: 'cat', value: 100}, - {x: 'dog', value: 50} - ]; - chart.data = data; - this.addHTMLOutput(chart); - }); - - test('undefined', function() { - var chart = new tr.ui.b.NameBarChart(); - assert.throws(function() { - chart.data = undefined; - }); - }); - - test('instantiation_twoSeries', function() { - var chart = new tr.ui.b.NameBarChart(); - - chart.width = 200; - chart.height = 200; - chart.chartTitle = 'Chart title'; - var data = [ - {x: 'apple', alpha: 100, beta: 50}, - {x: 'ball', alpha: 110, beta: 75}, - {x: 'cat', alpha: 100, beta: 125}, - {x: 'dog', alpha: 50, beta: 125} - ]; - chart.data = data; - - var r = new tr.b.Range(); - r.addValue(20); - r.addValue(40); - chart.brushedRange = r; - - this.addHTMLOutput(chart); - }); - - test('instantiation_twoSparseSeriesWithFirstValueSparse', function() { - var chart = new tr.ui.b.NameBarChart(); - - chart.width = 200; - chart.height = 200; - chart.chartTitle = 'Chart title'; - var data = [ - {x: 'apple', alpha: 20, beta: undefined}, - {x: 'ball', alpha: undefined, beta: 10}, - {x: 'cat', alpha: 10, beta: undefined}, - {x: 'dog', alpha: undefined, beta: 20}, - {x: 'echo', alpha: 30, beta: 30} - ]; - chart.data = data; - - this.addHTMLOutput(chart); - }); - - test('instantiation_twoSparseSeriesWithFirstValueNotSparse', function() { - var chart = new tr.ui.b.NameBarChart(); - - chart.width = 200; - chart.height = 200; - chart.chartTitle = 'Chart title'; - var data = [ - {x: 'apple', alpha: 20, beta: 40}, - {x: 'ball', alpha: undefined, beta: 10}, - {x: 'cat', alpha: 10, beta: undefined}, - {x: 'dog', alpha: undefined, beta: 20}, - {x: 'echo', alpha: 30, beta: undefined} - ]; - chart.data = data; - - this.addHTMLOutput(chart); - }); - - test('brushRangeFromIndices', function() { - var chart = new tr.ui.b.NameBarChart(); - var data = [ - {x: 'apple', value: 50}, - {x: 'ball', value: 60}, - {x: 'cat', value: 70}, - {x: 'dog', value: 80}, - {x: 'echo', value: 90} - ]; - chart.data = data; - var r = new tr.b.Range(); - - // Range min should be 10. - r = chart.computeBrushRangeFromIndices(-2, 1); - assert.equal(r.min, 0); - - // Range max should be 120. - r = chart.computeBrushRangeFromIndices(3, 10); - assert.equal(r.max, 4); - - // Range should be [10, 120] - r = chart.computeBrushRangeFromIndices(-2, 10); - assert.equal(r.min, 0); - assert.equal(r.max, 4); - - // Range should be [20, 100] - r = chart.computeBrushRangeFromIndices(1, 3); - assert.equal(r.min, 0.5); - assert.equal(r.max, 3.5); - }); - - test('instantiation_interactiveBrushing', function() { - var chart = new tr.ui.b.NameBarChart(); - chart.width = 300; - chart.height = 200; - chart.chartTitle = 'Chart title'; - var data = [ - {x: 'apple', value: 50}, - {x: 'ball', value: 60}, - {x: 'cat', value: 80}, - {x: 'dog', value: 20}, - {x: 'echo', value: 30}, - {x: 'fortune', value: 20}, - {x: 'gpu', value: 15}, - {x: 'happy', value: 20} - ]; - chart.data = data; - - var mouseDownIndex = undefined; - var currentMouseIndex = undefined; - - function updateBrushedRange() { - var r = new tr.b.Range(); - r.min = Math.max(0, Math.min(mouseDownIndex, currentMouseIndex)); - r.max = Math.min(data.length, Math.max(mouseDownIndex, - currentMouseIndex) + 1); - chart.brushedRange = r; - } - - chart.addEventListener('item-mousedown', function(e) { - mouseDownIndex = e.index; - currentMouseIndex = e.index; - updateBrushedRange(); - }); - chart.addEventListener('item-mousemove', function(e) { - if (e.button === undefined) - return; - currentMouseIndex = e.index; - updateBrushedRange(); - }); - chart.addEventListener('item-mouseup', function(e) { - currentMouseIndex = e.index; - updateBrushedRange(); - }); - this.addHTMLOutput(chart); - }); -}); -</script> - diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/overlay.html b/chromium/third_party/catapult/tracing/tracing/ui/base/overlay.html deleted file mode 100644 index df8e13ceddf..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/overlay.html +++ /dev/null @@ -1,340 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/utils.html"> -<link rel="import" href="/tracing/base/event.html"> -<link rel="import" href="/tracing/ui/base/ui.html"> -<link rel="import" href="/tracing/ui/base/utils.html"> - -<template id="overlay-template"> - <style> - overlay-mask { - left: 0; - padding: 8px; - position: absolute; - top: 0; - z-index: 1000; - font-family: sans-serif; - -webkit-justify-content: center; - background: rgba(0, 0, 0, 0.8); - display: -webkit-flex; - height: 100%; - left: 0; - position: fixed; - top: 0; - width: 100%; - } - overlay-mask:focus { - outline: none; - } - overlay-vertical-centering-container { - -webkit-justify-content: center; - -webkit-flex-direction: column; - display: -webkit-flex; - } - overlay-frame { - z-index: 1100; - background: rgb(255, 255, 255); - border: 1px solid #ccc; - margin: 75px; - display: -webkit-flex; - -webkit-flex-direction: column; - min-height: 0; - } - title-bar { - -webkit-align-items: center; - -webkit-flex-direction: row; - border-bottom: 1px solid #ccc; - background-color: #ddd; - display: -webkit-flex; - padding: 5px; - -webkit-flex: 0 0 auto; - } - title { - display: inline; - font-weight: bold; - -webkit-box-flex: 1; - -webkit-flex: 1 1 auto; - } - close-button { - -webkit-align-self: flex-end; - border: 1px solid #eee; - background-color: #999; - font-size: 10pt; - font-weight: bold; - padding: 2px; - text-align: center; - width: 16px; - } - close-button:hover { - background-color: #ddd; - border-color: black; - cursor: pointer; - } - overlay-content { - display: -webkit-flex; - -webkit-flex: 1 1 auto; - -webkit-flex-direction: column; - overflow-y: auto; - padding: 10px; - min-width: 300px; - min-height: 0; - } - button-bar { - -webkit-align-items: baseline; - border-top: 1px solid #ccc; - display: -webkit-flex; - -webkit-flex: 0 0 auto; - -webkit-flex-direction: row-reverse; - padding: 4px; - } - </style> - - <overlay-mask> - <overlay-vertical-centering-container> - <overlay-frame> - <title-bar> - <title></title> - <close-button>✕</close-button> - </title-bar> - <overlay-content> - <content></content> - </overlay-content> - <button-bar></button-bar> - </overlay-frame> - </overlay-vertical-centering-container> - </overlay-mask> -</template> - -<script> -'use strict'; - -/** - * @fileoverview Implements an element that is hidden by default, but - * when shown, dims and (attempts to) disable the main document. - * - * You can turn any div into an overlay. Note that while an - * overlay element is shown, its parent is changed. Hiding the overlay - * restores its original parentage. - * - */ -tr.exportTo('tr.ui.b', function() { - if (tr.isHeadless) - return {}; - - var THIS_DOC = document.currentScript.ownerDocument; - - /** - * Creates a new overlay element. It will not be visible until shown. - * @constructor - * @extends {HTMLDivElement} - */ - var Overlay = tr.ui.b.define('overlay'); - - Overlay.prototype = { - __proto__: HTMLDivElement.prototype, - - /** - * Initializes the overlay element. - */ - decorate: function() { - this.classList.add('overlay'); - - this.parentEl_ = this.ownerDocument.body; - - this.visible_ = false; - this.userCanClose_ = true; - - this.onKeyDown_ = this.onKeyDown_.bind(this); - this.onClick_ = this.onClick_.bind(this); - this.onFocusIn_ = this.onFocusIn_.bind(this); - this.onDocumentClick_ = this.onDocumentClick_.bind(this); - this.onClose_ = this.onClose_.bind(this); - - this.addEventListener('visible-change', - tr.ui.b.Overlay.prototype.onVisibleChange_.bind(this), true); - - // Setup the shadow root - var createShadowRoot = this.createShadowRoot || - this.webkitCreateShadowRoot; - this.shadow_ = createShadowRoot.call(this); - this.shadow_.appendChild(tr.ui.b.instantiateTemplate('#overlay-template', - THIS_DOC)); - - this.closeBtn_ = this.shadow_.querySelector('close-button'); - this.closeBtn_.addEventListener('click', this.onClose_); - - this.shadow_ - .querySelector('overlay-frame') - .addEventListener('click', this.onClick_); - - this.observer_ = new WebKitMutationObserver( - this.didButtonBarMutate_.bind(this)); - this.observer_.observe(this.shadow_.querySelector('button-bar'), - { childList: true }); - - // title is a variable on regular HTMLElements. However, we want to - // use it for something more useful. - Object.defineProperty( - this, 'title', { - get: function() { - return this.shadow_.querySelector('title').textContent; - }, - set: function(title) { - this.shadow_.querySelector('title').textContent = title; - } - }); - }, - - set userCanClose(userCanClose) { - this.userCanClose_ = userCanClose; - this.closeBtn_.style.display = - userCanClose ? 'block' : 'none'; - }, - - get buttons() { - return this.shadow_.querySelector('button-bar'); - }, - - get visible() { - return this.visible_; - }, - - set visible(newValue) { - if (this.visible_ === newValue) - return; - - this.visible_ = newValue; - var e = new tr.b.Event('visible-change'); - this.dispatchEvent(e); - }, - - onVisibleChange_: function() { - this.visible_ ? this.show_() : this.hide_(); - }, - - show_: function() { - this.parentEl_.appendChild(this); - - if (this.userCanClose_) { - this.addEventListener('keydown', this.onKeyDown_.bind(this)); - this.addEventListener('click', this.onDocumentClick_.bind(this)); - } - - this.parentEl_.addEventListener('focusin', this.onFocusIn_); - this.tabIndex = 0; - - // Focus the first thing we find that makes sense. (Skip the close button - // as it doesn't make sense as the first thing to focus.) - var focusEl = undefined; - var elList = this.querySelectorAll('button, input, list, select, a'); - if (elList.length > 0) { - if (elList[0] === this.closeBtn_) { - if (elList.length > 1) - focusEl = elList[1]; - } else { - focusEl = elList[0]; - } - } - if (focusEl === undefined) - focusEl = this; - focusEl.focus(); - }, - - hide_: function() { - this.parentEl_.removeChild(this); - - this.parentEl_.removeEventListener('focusin', this.onFocusIn_); - - if (this.closeBtn_) - this.closeBtn_.removeEventListener('click', this.onClose_); - - document.removeEventListener('keydown', this.onKeyDown_); - document.removeEventListener('click', this.onDocumentClick_); - }, - - onClose_: function(e) { - this.visible = false; - if ((e.type != 'keydown') || - (e.type === 'keydown' && e.keyCode === 27)) - e.stopPropagation(); - e.preventDefault(); - tr.b.dispatchSimpleEvent(this, 'closeclick'); - }, - - onFocusIn_: function(e) { - if (e.target === this) - return; - - window.setTimeout(function() { this.focus(); }, 0); - e.preventDefault(); - e.stopPropagation(); - }, - - didButtonBarMutate_: function(e) { - var hasButtons = this.buttons.children.length > 0; - if (hasButtons) - this.shadow_.querySelector('button-bar').style.display = undefined; - else - this.shadow_.querySelector('button-bar').style.display = 'none'; - }, - - onKeyDown_: function(e) { - // Disallow shift-tab back to another element. - if (e.keyCode === 9 && // tab - e.shiftKey && - e.target === this) { - e.preventDefault(); - return; - } - - if (e.keyCode !== 27) // escape - return; - - this.onClose_(e); - }, - - onClick_: function(e) { - e.stopPropagation(); - }, - - onDocumentClick_: function(e) { - if (!this.userCanClose_) - return; - - this.onClose_(e); - } - }; - - Overlay.showError = function(msg, opt_err) { - var o = new Overlay(); - o.title = 'Error'; - o.textContent = msg; - if (opt_err) { - var e = tr.b.normalizeException(opt_err); - - var stackDiv = document.createElement('pre'); - stackDiv.textContent = e.stack; - stackDiv.style.paddingLeft = '8px'; - stackDiv.style.margin = 0; - o.appendChild(stackDiv); - } - var b = document.createElement('button'); - b.textContent = 'OK'; - b.addEventListener('click', function() { - o.visible = false; - }); - o.buttons.appendChild(b); - o.visible = true; - return o; - } - - return { - Overlay: Overlay - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/overlay_test.html b/chromium/third_party/catapult/tracing/tracing/ui/base/overlay_test.html deleted file mode 100644 index d1d1b31e8e3..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/overlay_test.html +++ /dev/null @@ -1,124 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> -<link rel="import" href="/tracing/ui/base/overlay.html"> -<link rel="import" href="/tracing/ui/base/dom_helpers.html"> -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - function addShowButtonForDialog(dlg) { - var btn = document.createElement('button'); - btn.textContent = 'Launch Overlay'; - btn.addEventListener('click', function(e) { - dlg.visible = true; - e.stopPropagation(); - }); - - this.addHTMLOutput(btn); - } - - function makeButton(title) { - var btn = document.createElement('button'); - btn.textContent = title; - return btn; - } - - function makeCloseButton(dlg) { - var btn = makeButton('close'); - btn.addEventListener('click', function(e) { - dlg.onClose_(e); - }); - return btn; - } - - test('instantiate', function() { - var dlg = new tr.ui.b.Overlay(); - dlg.classList.add('example-overlay'); - dlg.title = 'ExampleOverlay'; - dlg.innerHTML = 'hello'; - dlg.buttons.appendChild(makeButton('i am a button')); - dlg.buttons.appendChild(makeCloseButton(dlg)); - dlg.buttons.appendChild(tr.ui.b.createSpan( - {textContent: 'i am a span'})); - addShowButtonForDialog.call(this, dlg); - }); - - test('instantiate_noButtons', function() { - var dlg = new tr.ui.b.Overlay(); - dlg.classList.add('example-overlay'); - dlg.title = 'ExampleOverlay'; - dlg.innerHTML = 'hello'; - addShowButtonForDialog.call(this, dlg); - }); - - test('instantiate_disableUserClose', function() { - var dlg = new tr.ui.b.Overlay(); - dlg.classList.add('example-overlay'); - dlg.userCanClose = false; - dlg.title = 'Unclosable'; - dlg.innerHTML = 'This has no close X button.'; - dlg.buttons.appendChild(makeCloseButton(dlg)); - addShowButtonForDialog.call(this, dlg); - }); - - test('instantiateTall', function() { - var dlg = new tr.ui.b.Overlay(); - dlg.title = 'TallContent'; - var contentEl = document.createElement('div'); - contentEl.style.overflowY = 'auto'; - dlg.appendChild(contentEl); - - for (var i = 0; i < 1000; i++) { - var el = document.createElement('div'); - el.textContent = 'line ' + i; - contentEl.appendChild(el); - } - - - dlg.buttons.appendChild(makeButton('i am a button')); - addShowButtonForDialog.call(this, dlg); - }); - - test('instantiateTallWithManyDirectChildren', function() { - var dlg = new tr.ui.b.Overlay(); - dlg.title = 'TallContent'; - for (var i = 0; i < 100; i++) { - var el = document.createElement('div'); - el.style.webkitFlex = '1 0 auto'; - el.textContent = 'line ' + i; - dlg.appendChild(el); - } - - dlg.buttons.appendChild(makeButton('i am a button')); - addShowButtonForDialog.call(this, dlg); - }); - - test('closeclickEvent', function() { - var dlg = new tr.ui.b.Overlay(); - dlg.title = 'Test closeclick event'; - var closeBtn = makeCloseButton(dlg); - dlg.buttons.appendChild(closeBtn); - - var closeClicked = false; - dlg.addEventListener('closeclick', function() { - closeClicked = true; - }); - - return new Promise(function(resolve, reject) { - function pressClose() { - closeBtn.click(); - if (closeClicked) - resolve(); - else - reject(new Error('closeclick event is not dispatched')); - } - dlg.visible = true; - setTimeout(pressClose, 60); - }); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/pie_chart.css b/chromium/third_party/catapult/tracing/tracing/ui/base/pie_chart.css deleted file mode 100644 index e6dc135bf12..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/pie_chart.css +++ /dev/null @@ -1,16 +0,0 @@ -/* Copyright 2014 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ -* /deep/ .pie-chart .arc-text { - font-size: 8pt; -} - -* /deep/ .pie-chart .label { - font-size: 10pt; -} - -* /deep/ .pie-chart polyline { - fill: none; - stroke: black; -} diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/pie_chart.html b/chromium/third_party/catapult/tracing/tracing/ui/base/pie_chart.html deleted file mode 100644 index 5edfd795219..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/pie_chart.html +++ /dev/null @@ -1,277 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> -<link rel="import" href="/tracing/base/range.html"> -<link rel="import" href="/tracing/ui/base/d3.html"> -<link rel="import" href="/tracing/ui/base/dom_helpers.html"> -<link rel="import" href="/tracing/ui/base/chart_base.html"> -<link rel="stylesheet" href="/tracing/ui/base/pie_chart.css"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.b', function() { - var ChartBase = tr.ui.b.ChartBase; - var getColorOfKey = tr.ui.b.getColorOfKey; - - var MIN_RADIUS = 100; - - /** - * @constructor - */ - var PieChart = tr.ui.b.define('pie-chart', ChartBase); - - PieChart.prototype = { - __proto__: ChartBase.prototype, - - decorate: function() { - ChartBase.prototype.decorate.call(this); - this.classList.add('pie-chart'); - - this.data_ = undefined; - this.seriesKeys_ = undefined; - - var chartAreaSel = d3.select(this.chartAreaElement); - var pieGroupSel = chartAreaSel.append('g') - .attr('class', 'pie-group'); - this.pieGroup_ = pieGroupSel.node(); - - this.pathsGroup_ = pieGroupSel.append('g') - .attr('class', 'paths') - .node(); - this.labelsGroup_ = pieGroupSel.append('g') - .attr('class', 'labels') - .node(); - this.linesGroup_ = pieGroupSel.append('g') - .attr('class', 'lines') - .node(); - }, - - get data() { - return this.data_; - }, - - - /** - * @param {Array} data Data for the chart, where each element in the array - * must be of the form {label: str, value: number}. - */ - set data(data) { - if (data !== undefined) { - // Figure out the label values in the data set. E.g. from - // [{label: 'a', ...}, {label: 'b', ...}] - // we would commpute ['a', 'y']. These become the series keys. - var seriesKeys = []; - var seenSeriesKeys = {}; - data.forEach(function(d) { - var k = d.label; - if (seenSeriesKeys[k]) - throw new Error('Label ' + k + ' has been used already'); - seriesKeys.push(k); - seenSeriesKeys[k] = true; - }, this); - this.seriesKeys_ = seriesKeys; - } else { - this.seriesKeys_ = undefined; - } - this.data_ = data; - this.updateContents_(); - }, - - get margin() { - var margin = {top: 0, right: 0, bottom: 0, left: 0}; - if (this.chartTitle_) - margin.top += 40; - return margin; - }, - - getMinSize: function() { - this.updateContents_(); - - var labelSel = d3.select(this.labelsGroup_).selectAll('.label'); - var maxLabelWidth = -Number.MAX_VALUE; - var leftTextHeightSum = 0; - var rightTextHeightSum = 0; - labelSel.each(function(l) { - var r = this.getBoundingClientRect(); - maxLabelWidth = Math.max(maxLabelWidth, r.width + 32); - if (this.style.textAnchor == 'end') { - leftTextHeightSum += r.height; - } else { - rightTextHeightSum += r.height; - } - }); - - var titleWidth = this.querySelector( - '#title').getBoundingClientRect().width; - var margin = this.margin; - var marginWidth = margin.left + margin.right; - var marginHeight = margin.top + margin.bottom; - return { - width: Math.max(2 * MIN_RADIUS + 2 * maxLabelWidth, - titleWidth * 1.1) + marginWidth, - height: marginHeight + Math.max(2 * MIN_RADIUS, - leftTextHeightSum, - rightTextHeightSum) * 1.25 - }; - }, - - - getLegendKeys_: function() { - // This class creates its own legend, instead of using ChartBase. - return undefined; - }, - - updateScales_: function(width, height) { - if (this.data_ === undefined) - return; - }, - - updateContents_: function() { - ChartBase.prototype.updateContents_.call(this); - if (!this.data_) - return; - - var width = this.chartAreaSize.width; - var height = this.chartAreaSize.height; - var radius = Math.max(MIN_RADIUS, Math.min(width, height * 0.95) / 2); - - d3.select(this.pieGroup_).attr( - 'transform', - 'translate(' + width / 2 + ',' + height / 2 + ')'); - - // Bind the pie layout to its data - var pieLayout = d3.layout.pie() - .value(function(d) { return d.value; }) - .sort(null); - - var piePathsSel = d3.select(this.pathsGroup_) - .datum(this.data_) - .selectAll('path') - .data(pieLayout); - - function midAngle(d) { - return d.startAngle + (d.endAngle - d.startAngle) / 2; - } - - var pathsArc = d3.svg.arc() - .innerRadius(0) - .outerRadius(radius - 30); - - var valueLabelArc = d3.svg.arc() - .innerRadius(radius - 100) - .outerRadius(radius - 30); - - var lineBeginArc = d3.svg.arc() - .innerRadius(radius - 50) - .outerRadius(radius - 50); - - var lineEndArc = d3.svg.arc() - .innerRadius(radius) - .outerRadius(radius); - - // Paths. - piePathsSel.enter().append('path') - .attr('class', 'arc') - .attr('fill', function(d, i) { - var origData = this.data_[i]; - var highlighted = (origData.label === - this.currentHighlightedLegendKey); - return getColorOfKey(origData.label, highlighted); - }.bind(this)) - .attr('d', pathsArc) - .on('click', function(d, i) { - var origData = this.data_[i]; - var event = new tr.b.Event('item-click'); - event.data = origData; - event.index = i; - this.dispatchEvent(event); - d3.event.stopPropagation(); - }.bind(this)) - .on('mouseenter', function(d, i) { - var origData = this.data_[i]; - this.pushTempHighlightedLegendKey(origData.label); - }.bind(this)) - .on('mouseleave', function(d, i) { - var origData = this.data_[i]; - this.popTempHighlightedLegendKey(origData.label); - }.bind(this)); - - // Value labels. - piePathsSel.enter().append('text') - .attr('class', 'arc-text') - .attr('transform', function(d) { - return 'translate(' + valueLabelArc.centroid(d) + ')'; - }) - .attr('dy', '.35em') - .style('text-anchor', 'middle') - .text(function(d, i) { - var origData = this.data_[i]; - if (origData.valueText === undefined) - return ''; - - if (d.endAngle - d.startAngle < 0.4) - return ''; - return origData.valueText; - }.bind(this)); - - piePathsSel.exit().remove(); - - // Labels. - var labelSel = d3.select(this.labelsGroup_).selectAll('.label') - .data(pieLayout(this.data_)); - labelSel.enter() - .append('text') - .attr('class', 'label') - .attr('dy', '.35em'); - - labelSel.text(function(d) { - if (d.data.label.length > 40) - return d.data.label.substr(0, 40) + '...'; - return d.data.label; - }); - labelSel.attr('transform', function(d) { - var pos = lineEndArc.centroid(d); - pos[0] = radius * (midAngle(d) < Math.PI ? 1 : -1); - return 'translate(' + pos + ')'; - }); - labelSel.style('text-anchor', function(d) { - return midAngle(d) < Math.PI ? 'start' : 'end'; - }); - - // Lines. - var lineSel = d3.select(this.linesGroup_).selectAll('.line') - .data(pieLayout(this.data_)); - lineSel.enter() - .append('polyline') - .attr('class', 'line') - .attr('dy', '.35em'); - lineSel.attr('points', function(d) { - var pos = lineEndArc.centroid(d); - pos[0] = radius * 0.95 * (midAngle(d) < Math.PI ? 1 : -1); - return [lineBeginArc.centroid(d), lineEndArc.centroid(d), pos]; - }); - }, - - updateHighlight_: function() { - ChartBase.prototype.updateHighlight_.call(this); - // Update color of pie segments. - var pathsGroupSel = d3.select(this.pathsGroup_); - var that = this; - pathsGroupSel.selectAll('.arc').each(function(d, i) { - var origData = that.data_[i]; - var highlighted = origData.label == that.currentHighlightedLegendKey; - var color = getColorOfKey(origData.label, highlighted); - this.style.fill = color; - }); - } - }; - - return { - PieChart: PieChart - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/pie_chart_test.html b/chromium/third_party/catapult/tracing/tracing/ui/base/pie_chart_test.html deleted file mode 100644 index 7c0b35f5462..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/pie_chart_test.html +++ /dev/null @@ -1,207 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> -<link rel="import" href="/tracing/ui/base/pie_chart.html"> -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - test('simple', function() { - var chart = new tr.ui.b.PieChart(); - chart.width = 400; - chart.height = 200; - assert.equal(chart.getAttribute('width'), '400'); - assert.equal(chart.getAttribute('height'), '200'); - chart.chartTitle = 'Chart title'; - var data = [ - {label: 'a', value: 100}, - {label: 'b', value: 200}, - {label: 'c', value: 300} - ]; - chart.data = data; - chart.highlightedLegendKey = 'a'; - chart.pushTempHighlightedLegendKey('b'); - chart.highlightedLegendKey = 'c'; - assert.equal(chart.currentHighlightedLegendKey, 'b'); - chart.popTempHighlightedLegendKey('b'); - assert.equal(chart.highlightedLegendKey, 'c'); - this.addHTMLOutput(chart); - }); - - test('withValueText', function() { - var chart = new tr.ui.b.PieChart(); - chart.width = 400; - chart.height = 200; - chart.chartTitle = 'Chart title'; - var data = [ - {label: 'a', value: 100, valueText: '100ms'}, - {label: 'b', value: 200, valueText: '200ms'}, - {label: 'c', value: 300, valueText: '300ms'} - ]; - chart.data = data; - this.addHTMLOutput(chart); - }); - - test('clickEvent', function() { - var chart = new tr.ui.b.PieChart(); - chart.width = 400; - chart.height = 200; - chart.chartTitle = 'Chart title'; - var data = [ - {label: 'a', value: 100, foo: 42}, - {label: 'b', value: 200, foo: 43} - ]; - chart.data = data; - - var didGetClick = false; - chart.addEventListener('item-click', function(event) { - assert.equal(event.index, 1); - assert.equal(event.data.foo, 43); - didGetClick = true; - }); - - var arc0 = chart.querySelectorAll('.paths > path')[1]; - tr.b.dispatchSimpleEvent(arc0, 'click'); - assert.isTrue(didGetClick); - }); - - test('lotsOfValues', function() { - var chart = new tr.ui.b.PieChart(); - chart.chartTitle = 'Chart title'; - var data = [ - {label: 'a', value: 100}, - {label: 'bb', value: 200}, - {label: 'cccc', value: 300}, - {label: 'dd', value: 50}, - {label: 'eeeee', value: 250}, - {label: 'fffffff', value: 120}, - {label: 'ggg', value: 90}, - {label: 'hhhh', value: 175}, - {label: 'toolongiiiiiiiiiiiiiiiiiiiiiiiii', value: 325}, - {label: 'jjjjjj', value: 140}, - {label: 'kkkkkkkkk', value: 170}, - {label: 'lll', value: 220} - ]; - chart.data = data; - this.addHTMLOutput(chart); - - var minSize = chart.getMinSize(); - chart.setSize(chart.getMinSize()); - }); - - test('denseValues', function() { - var chart = new tr.ui.b.PieChart(); - chart.chartTitle = 'Chart title'; - var data = [ - { - valueText: '2.855ms', - value: 2.854999999999997, - label: '156959' - }, - { - valueText: '9.949ms', - value: 9.948999999999998, - label: '16131' - }, - { - valueText: '42.314ms', - value: 42.314000000000725, - label: '51511' - }, - { - valueText: '31.069ms', - value: 31.06900000000028, - label: 'AudioOutputDevice' - }, - { - valueText: '1.418ms', - value: 1.418, - label: 'BrowserBlockingWorker2/50951' - }, - { - valueText: '0.044ms', - value: 0.044, - label: 'BrowserBlockingWorker3/50695' - }, - { - valueText: '18.526ms', - value: 18.52599999999993, - label: 'Chrome_ChildIOThread' - }, - { - valueText: '2.888ms', - value: 2.888, - label: 'Chrome_FileThread' - }, - { - valueText: '0.067ms', - value: 0.067, - label: 'Chrome_HistoryThread' - }, - { - valueText: '25.421ms', - value: 25.421000000000046, - label: 'Chrome_IOThread' - }, - { - valueText: '0.019ms', - value: 0.019, - label: 'Chrome_ProcessLauncherThread' - }, - { - valueText: '643.088ms', - value: 643.087999999995, - label: 'Compositor' - }, - { - valueText: '4.05ms', - value: 4.049999999999973, - label: 'CompositorRasterWorker1/22031' - }, - { - valueText: '50.04ms', - value: 50.040000000000106, - label: 'CrBrowserMain' - }, - { - valueText: '1256.513ms', - value: 1256.5130000000042, - label: 'CrGpuMain' - }, - { - valueText: '5502.195ms', - value: 5502.19499999999, - label: 'CrRendererMain' - }, - { - valueText: '15.553ms', - value: 15.552999999999862, - label: 'FFmpegDemuxer' - }, - { - valueText: '63.706ms', - value: 63.706000000001524, - label: 'Media' - }, - { - valueText: '2.742ms', - value: 2.7419999999999987, - label: 'PowerSaveBlocker' - }, - { - valueText: '0.115ms', - value: 0.11500000000000005, - label: 'Watchdog' - } - ]; - chart.data = data; - this.addHTMLOutput(chart); - - var minSize = chart.getMinSize(); - chart.setSize(chart.getMinSize()); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/polymer_utils.html b/chromium/third_party/catapult/tracing/tracing/ui/base/polymer_utils.html deleted file mode 100644 index b8c5e9d050d..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/polymer_utils.html +++ /dev/null @@ -1,64 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> -<link rel="import" href="/tracing/base/base.html"> - -<script> -'use strict'; - -/** - * @fileoverview Helper code for working with Polymer. - */ -tr.exportTo('tr.ui.b', function() { - - function getPolymerElementNamed(tagName) { - for (var i = 0; i < Polymer.elements.length; i++) { - if (Polymer.elements[i].name === tagName) - return Polymer.elements[i]; - } - } - - function getPolymerElementsThatSubclass(tagName) { - if (Polymer.waitingFor().length) { - throw new Error('There are unresolved polymer elements. ' + - 'Wait until Polymer.whenReady'); - } - - var baseElement; - var elementNamesThatExtend = {}; - Polymer.elements.forEach(function(element) { - if (element.name === tagName) - baseElement = element; - - if (element.extends) { - if (elementNamesThatExtend[element.extends] === undefined) - elementNamesThatExtend[element.extends] = []; - elementNamesThatExtend[element.extends].push(element.name); - } - }); - - if (!baseElement) - throw new Error(tagName + ' is not a polymer element'); - - var allFoundSubElementNames = [baseElement.name]; - for (var i = 0; i < allFoundSubElementNames.length; i++) { - var elementName = allFoundSubElementNames[i]; - allFoundSubElementNames.push.apply( - allFoundSubElementNames, elementNamesThatExtend[elementName]); - } - - // Remove the base element tag name from the list. - allFoundSubElementNames.shift(); - - return allFoundSubElementNames; - } - - return { - getPolymerElementNamed: getPolymerElementNamed, - getPolymerElementsThatSubclass: getPolymerElementsThatSubclass - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/polymer_utils_test.html b/chromium/third_party/catapult/tracing/tracing/ui/base/polymer_utils_test.html deleted file mode 100644 index 698ec0cdc17..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/polymer_utils_test.html +++ /dev/null @@ -1,73 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright 2016 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/base/polymer_utils.html"> - -<!-- -The Polymer elements defined in this file form the following class hierarchy: - - A (common superclass) - / \ - B C - / \ - D E - / \ - F G ---> - -<polymer-element name="polymer-utils-test-element-a" noscript> -</polymer-element> - -<polymer-element name="polymer-utils-test-element-b" - extends="polymer-utils-test-element-a" noscript> -</polymer-element> - -<polymer-element name="polymer-utils-test-element-c" - extends="polymer-utils-test-element-a" noscript> -</polymer-element> - -<polymer-element name="polymer-utils-test-element-d" - extends="polymer-utils-test-element-c" noscript> -</polymer-element> - -<polymer-element name="polymer-utils-test-element-e" - extends="polymer-utils-test-element-c" noscript> -</polymer-element> - -<polymer-element name="polymer-utils-test-element-f" - extends="polymer-utils-test-element-d" noscript> -</polymer-element> - -<polymer-element name="polymer-utils-test-element-g" - extends="polymer-utils-test-element-d" noscript> -</polymer-element> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - test('getPolymerElementsThatSubclass', function() { - function checkSubclasses(classNameSuffix, subclassNameSuffixes) { - var className = 'polymer-utils-test-element-' + classNameSuffix; - var subclassNames = subclassNameSuffixes.map( - function(subclassNameSuffix) { - return 'polymer-utils-test-element-' + subclassNameSuffix; - }); - assert.sameMembers( - tr.ui.b.getPolymerElementsThatSubclass(className), subclassNames); - } - - checkSubclasses('a', ['b', 'c', 'd', 'e', 'f', 'g']); - checkSubclasses('b', []); - checkSubclasses('c', ['d', 'e', 'f', 'g']); - checkSubclasses('d', ['f', 'g']); - checkSubclasses('e', []); - checkSubclasses('f', []); - checkSubclasses('g', []); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/quad_stack_view.html b/chromium/third_party/catapult/tracing/tracing/ui/base/quad_stack_view.html deleted file mode 100644 index 7c181a61857..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/quad_stack_view.html +++ /dev/null @@ -1,689 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> -<link rel="import" href="/tracing/base/bbox2.html"> -<link rel="import" href="/tracing/base/math.html"> -<link rel="import" href="/tracing/base/quad.html"> -<link rel="import" href="/tracing/base/raf.html"> -<link rel="import" href="/tracing/base/rect.html"> -<link rel="import" href="/tracing/base/settings.html"> -<link rel="import" href="/tracing/ui/base/camera.html"> -<link rel="import" href="/tracing/ui/base/mouse_mode_selector.html"> -<link rel="import" href="/tracing/ui/base/mouse_tracker.html"> -<link rel="import" href="/tracing/ui/base/utils.html"> - -<style> -* /deep/ quad-stack-view { - display: block; - float: left; - height: 100%; - overflow: hidden; - position: relative; /* For the absolute positioned mouse-mode-selector */ - width: 100%; -} - -* /deep/ quad-stack-view > #header { - position: absolute; - font-size: 70%; - top: 10px; - left: 10px; - width: 800px; -} -* /deep/ quad-stack-view > #stacking-distance-slider { - position: absolute; - font-size: 70%; - top: 10px; - right: 10px; -} - -* /deep/ quad-stack-view > #chrome-left { - background-image: url('../images/chrome-left.png'); - display: none; -} - -* /deep/ quad-stack-view > #chrome-mid { - background-image: url('../images/chrome-mid.png'); - display: none; -} - -* /deep/ quad-stack-view > #chrome-right { - background-image: url('../images/chrome-right.png'); - display: none; -} -</style> - -<template id='quad-stack-view-template'> - <div id="header"></div> - <input id="stacking-distance-slider" type="range" min=1 max=400 step=1> - </input> - <canvas id='canvas'></canvas> - <img id='chrome-left'/> - <img id='chrome-mid'/> - <img id='chrome-right'/> -</template> - -<script> -'use strict'; - -/** - * @fileoverview QuadStackView controls the content and viewing angle a - * QuadStack. - */ -tr.exportTo('tr.ui.b', function() { - var THIS_DOC = document.currentScript.ownerDocument; - - var constants = {}; - constants.IMAGE_LOAD_RETRY_TIME_MS = 500; - constants.SUBDIVISION_MINIMUM = 1; - constants.SUBDIVISION_RECURSION_DEPTH = 3; - constants.SUBDIVISION_DEPTH_THRESHOLD = 100; - constants.FAR_PLANE_DISTANCE = 10000; - - // Care of bckenney@ via - // http://extremelysatisfactorytotalitarianism.com/blog/?p=2120 - function drawTexturedTriangle(ctx, img, p0, p1, p2, t0, t1, t2) { - var tmp_p0 = [p0[0], p0[1]]; - var tmp_p1 = [p1[0], p1[1]]; - var tmp_p2 = [p2[0], p2[1]]; - var tmp_t0 = [t0[0], t0[1]]; - var tmp_t1 = [t1[0], t1[1]]; - var tmp_t2 = [t2[0], t2[1]]; - - ctx.beginPath(); - ctx.moveTo(tmp_p0[0], tmp_p0[1]); - ctx.lineTo(tmp_p1[0], tmp_p1[1]); - ctx.lineTo(tmp_p2[0], tmp_p2[1]); - ctx.closePath(); - - tmp_p1[0] -= tmp_p0[0]; - tmp_p1[1] -= tmp_p0[1]; - tmp_p2[0] -= tmp_p0[0]; - tmp_p2[1] -= tmp_p0[1]; - - tmp_t1[0] -= tmp_t0[0]; - tmp_t1[1] -= tmp_t0[1]; - tmp_t2[0] -= tmp_t0[0]; - tmp_t2[1] -= tmp_t0[1]; - - var det = 1 / (tmp_t1[0] * tmp_t2[1] - tmp_t2[0] * tmp_t1[1]), - - // linear transformation - a = (tmp_t2[1] * tmp_p1[0] - tmp_t1[1] * tmp_p2[0]) * det, - b = (tmp_t2[1] * tmp_p1[1] - tmp_t1[1] * tmp_p2[1]) * det, - c = (tmp_t1[0] * tmp_p2[0] - tmp_t2[0] * tmp_p1[0]) * det, - d = (tmp_t1[0] * tmp_p2[1] - tmp_t2[0] * tmp_p1[1]) * det, - - // translation - e = tmp_p0[0] - a * tmp_t0[0] - c * tmp_t0[1], - f = tmp_p0[1] - b * tmp_t0[0] - d * tmp_t0[1]; - - ctx.save(); - ctx.transform(a, b, c, d, e, f); - ctx.clip(); - ctx.drawImage(img, 0, 0); - ctx.restore(); - } - - function drawTriangleSub( - ctx, img, p0, p1, p2, t0, t1, t2, opt_recursion_depth) { - var depth = opt_recursion_depth || 0; - - // We may subdivide if we are not at the limit of recursion. - var subdivisionIndex = 0; - if (depth < constants.SUBDIVISION_MINIMUM) { - subdivisionIndex = 7; - } else if (depth < constants.SUBDIVISION_RECURSION_DEPTH) { - if (Math.abs(p0[2] - p1[2]) > constants.SUBDIVISION_DEPTH_THRESHOLD) - subdivisionIndex += 1; - if (Math.abs(p0[2] - p2[2]) > constants.SUBDIVISION_DEPTH_THRESHOLD) - subdivisionIndex += 2; - if (Math.abs(p1[2] - p2[2]) > constants.SUBDIVISION_DEPTH_THRESHOLD) - subdivisionIndex += 4; - } - - // These need to be created every time, since temporaries - // outside of the scope will be rewritten in recursion. - var p01 = vec4.create(); - var p02 = vec4.create(); - var p12 = vec4.create(); - var t01 = vec2.create(); - var t02 = vec2.create(); - var t12 = vec2.create(); - - // Calculate the position before w-divide. - for (var i = 0; i < 2; ++i) { - p0[i] *= p0[2]; - p1[i] *= p1[2]; - p2[i] *= p2[2]; - } - - // Interpolate the 3d position. - for (var i = 0; i < 4; ++i) { - p01[i] = (p0[i] + p1[i]) / 2; - p02[i] = (p0[i] + p2[i]) / 2; - p12[i] = (p1[i] + p2[i]) / 2; - } - - // Re-apply w-divide to the original points and the interpolated ones. - for (var i = 0; i < 2; ++i) { - p0[i] /= p0[2]; - p1[i] /= p1[2]; - p2[i] /= p2[2]; - - p01[i] /= p01[2]; - p02[i] /= p02[2]; - p12[i] /= p12[2]; - } - - // Interpolate the texture coordinates. - for (var i = 0; i < 2; ++i) { - t01[i] = (t0[i] + t1[i]) / 2; - t02[i] = (t0[i] + t2[i]) / 2; - t12[i] = (t1[i] + t2[i]) / 2; - } - - // Based on the index, we subdivide the triangle differently. - // Assuming the triangle is p0, p1, p2 and points between i j - // are represented as pij (that is, a point between p2 and p0 - // is p02, etc), then the new triangles are defined by - // the 3rd 4th and 5th arguments into the function. - switch (subdivisionIndex) { - case 1: - drawTriangleSub(ctx, img, p0, p01, p2, t0, t01, t2, depth + 1); - drawTriangleSub(ctx, img, p01, p1, p2, t01, t1, t2, depth + 1); - break; - case 2: - drawTriangleSub(ctx, img, p0, p1, p02, t0, t1, t02, depth + 1); - drawTriangleSub(ctx, img, p1, p02, p2, t1, t02, t2, depth + 1); - break; - case 3: - drawTriangleSub(ctx, img, p0, p01, p02, t0, t01, t02, depth + 1); - drawTriangleSub(ctx, img, p02, p01, p2, t02, t01, t2, depth + 1); - drawTriangleSub(ctx, img, p01, p1, p2, t01, t1, t2, depth + 1); - break; - case 4: - drawTriangleSub(ctx, img, p0, p12, p2, t0, t12, t2, depth + 1); - drawTriangleSub(ctx, img, p0, p1, p12, t0, t1, t12, depth + 1); - break; - case 5: - drawTriangleSub(ctx, img, p0, p01, p2, t0, t01, t2, depth + 1); - drawTriangleSub(ctx, img, p2, p01, p12, t2, t01, t12, depth + 1); - drawTriangleSub(ctx, img, p01, p1, p12, t01, t1, t12, depth + 1); - break; - case 6: - drawTriangleSub(ctx, img, p0, p12, p02, t0, t12, t02, depth + 1); - drawTriangleSub(ctx, img, p0, p1, p12, t0, t1, t12, depth + 1); - drawTriangleSub(ctx, img, p02, p12, p2, t02, t12, t2, depth + 1); - break; - case 7: - drawTriangleSub(ctx, img, p0, p01, p02, t0, t01, t02, depth + 1); - drawTriangleSub(ctx, img, p01, p12, p02, t01, t12, t02, depth + 1); - drawTriangleSub(ctx, img, p01, p1, p12, t01, t1, t12, depth + 1); - drawTriangleSub(ctx, img, p02, p12, p2, t02, t12, t2, depth + 1); - break; - default: - // In the 0 case and all other cases, we simply draw the triangle. - drawTexturedTriangle(ctx, img, p0, p1, p2, t0, t1, t2); - break; - } - } - - // Created to avoid creating garbage when doing bulk transforms. - var tmp_vec4 = vec4.create(); - function transform(transformed, point, matrix, viewport) { - vec4.set(tmp_vec4, point[0], point[1], 0, 1); - vec4.transformMat4(tmp_vec4, tmp_vec4, matrix); - - var w = tmp_vec4[3]; - if (w < 1e-6) w = 1e-6; - - transformed[0] = ((tmp_vec4[0] / w) + 1) * viewport.width / 2; - transformed[1] = ((tmp_vec4[1] / w) + 1) * viewport.height / 2; - transformed[2] = w; - } - - function drawProjectedQuadBackgroundToContext( - quad, p1, p2, p3, p4, ctx, quadCanvas) { - if (quad.imageData) { - quadCanvas.width = quad.imageData.width; - quadCanvas.height = quad.imageData.height; - quadCanvas.getContext('2d').putImageData(quad.imageData, 0, 0); - var quadBBox = new tr.b.BBox2(); - quadBBox.addQuad(quad); - var iw = quadCanvas.width; - var ih = quadCanvas.height; - drawTriangleSub( - ctx, quadCanvas, - p1, p2, p4, - [0, 0], [iw, 0], [0, ih]); - drawTriangleSub( - ctx, quadCanvas, - p2, p3, p4, - [iw, 0], [iw, ih], [0, ih]); - } - - if (quad.backgroundColor) { - ctx.fillStyle = quad.backgroundColor; - ctx.beginPath(); - ctx.moveTo(p1[0], p1[1]); - ctx.lineTo(p2[0], p2[1]); - ctx.lineTo(p3[0], p3[1]); - ctx.lineTo(p4[0], p4[1]); - ctx.closePath(); - ctx.fill(); - } - } - - function drawProjectedQuadOutlineToContext( - quad, p1, p2, p3, p4, ctx, quadCanvas) { - ctx.beginPath(); - ctx.moveTo(p1[0], p1[1]); - ctx.lineTo(p2[0], p2[1]); - ctx.lineTo(p3[0], p3[1]); - ctx.lineTo(p4[0], p4[1]); - ctx.closePath(); - ctx.save(); - if (quad.borderColor) - ctx.strokeStyle = quad.borderColor; - else - ctx.strokeStyle = 'rgb(128,128,128)'; - - if (quad.shadowOffset) { - ctx.shadowColor = 'rgb(0, 0, 0)'; - ctx.shadowOffsetX = quad.shadowOffset[0]; - ctx.shadowOffsetY = quad.shadowOffset[1]; - if (quad.shadowBlur) - ctx.shadowBlur = quad.shadowBlur; - } - - if (quad.borderWidth) - ctx.lineWidth = quad.borderWidth; - else - ctx.lineWidth = 1; - - ctx.stroke(); - ctx.restore(); - } - - function drawProjectedQuadSelectionOutlineToContext( - quad, p1, p2, p3, p4, ctx, quadCanvas) { - if (!quad.upperBorderColor) - return; - - ctx.lineWidth = 8; - ctx.strokeStyle = quad.upperBorderColor; - - ctx.beginPath(); - ctx.moveTo(p1[0], p1[1]); - ctx.lineTo(p2[0], p2[1]); - ctx.lineTo(p3[0], p3[1]); - ctx.lineTo(p4[0], p4[1]); - ctx.closePath(); - ctx.stroke(); - } - - function drawProjectedQuadToContext( - passNumber, quad, p1, p2, p3, p4, ctx, quadCanvas) { - if (passNumber === 0) { - drawProjectedQuadBackgroundToContext( - quad, p1, p2, p3, p4, ctx, quadCanvas); - } else if (passNumber === 1) { - drawProjectedQuadOutlineToContext( - quad, p1, p2, p3, p4, ctx, quadCanvas); - } else if (passNumber === 2) { - drawProjectedQuadSelectionOutlineToContext( - quad, p1, p2, p3, p4, ctx, quadCanvas); - } else { - throw new Error('Invalid pass number'); - } - } - - var tmp_p1 = vec3.create(); - var tmp_p2 = vec3.create(); - var tmp_p3 = vec3.create(); - var tmp_p4 = vec3.create(); - function transformAndProcessQuads( - matrix, viewport, quads, numPasses, handleQuadFunc, opt_arg1, opt_arg2) { - - for (var passNumber = 0; passNumber < numPasses; passNumber++) { - for (var i = 0; i < quads.length; i++) { - var quad = quads[i]; - transform(tmp_p1, quad.p1, matrix, viewport); - transform(tmp_p2, quad.p2, matrix, viewport); - transform(tmp_p3, quad.p3, matrix, viewport); - transform(tmp_p4, quad.p4, matrix, viewport); - handleQuadFunc(passNumber, quad, - tmp_p1, tmp_p2, tmp_p3, tmp_p4, - opt_arg1, opt_arg2); - } - } - } - - /** - * @constructor - */ - var QuadStackView = tr.ui.b.define('quad-stack-view'); - - QuadStackView.prototype = { - __proto__: HTMLUnknownElement.prototype, - - decorate: function() { - this.className = 'quad-stack-view'; - - var node = tr.ui.b.instantiateTemplate('#quad-stack-view-template', - THIS_DOC); - this.appendChild(node); - this.updateHeaderVisibility_(); - this.canvas_ = this.querySelector('#canvas'); - this.chromeImages_ = { - left: this.querySelector('#chrome-left'), - mid: this.querySelector('#chrome-mid'), - right: this.querySelector('#chrome-right') - }; - - var stackingDistanceSlider = this.querySelector( - '#stacking-distance-slider'); - stackingDistanceSlider.value = tr.b.Settings.get( - 'quadStackView.stackingDistance', 45); - stackingDistanceSlider.addEventListener( - 'change', this.onStackingDistanceChange_.bind(this)); - stackingDistanceSlider.addEventListener( - 'input', this.onStackingDistanceChange_.bind(this)); - - this.trackMouse_(); - - this.camera_ = new tr.ui.b.Camera(this.mouseModeSelector_); - this.camera_.addEventListener('renderrequired', - this.onRenderRequired_.bind(this)); - this.cameraWasReset_ = false; - this.camera_.canvas = this.canvas_; - - this.viewportRect_ = tr.b.Rect.fromXYWH(0, 0, 0, 0); - - this.pixelRatio_ = window.devicePixelRatio || 1; - }, - - updateHeaderVisibility_: function() { - if (this.headerText) - this.querySelector('#header').style.display = ''; - else - this.querySelector('#header').style.display = 'none'; - }, - - get headerText() { - return this.querySelector('#header').textContent; - }, - - set headerText(headerText) { - this.querySelector('#header').textContent = headerText; - this.updateHeaderVisibility_(); - }, - - onStackingDistanceChange_: function(e) { - tr.b.Settings.set('quadStackView.stackingDistance', - this.stackingDistance); - this.scheduleRender(); - e.stopPropagation(); - }, - - get stackingDistance() { - return this.querySelector('#stacking-distance-slider').value; - }, - - get mouseModeSelector() { - return this.mouseModeSelector_; - }, - - get camera() { - return this.camera_; - }, - - set quads(q) { - this.quads_ = q; - this.scheduleRender(); - }, - - set deviceRect(rect) { - if (!rect || rect.equalTo(this.deviceRect_)) - return; - - this.deviceRect_ = rect; - this.camera_.deviceRect = rect; - this.chromeQuad_ = undefined; - }, - - resize: function() { - if (!this.offsetParent) - return true; - - var width = parseInt(window.getComputedStyle(this.offsetParent).width); - var height = parseInt(window.getComputedStyle(this.offsetParent).height); - var rect = tr.b.Rect.fromXYWH(0, 0, width, height); - - if (rect.equalTo(this.viewportRect_)) - return false; - - this.viewportRect_ = rect; - this.style.width = width + 'px'; - this.style.height = height + 'px'; - this.canvas_.style.width = width + 'px'; - this.canvas_.style.height = height + 'px'; - this.canvas_.width = this.pixelRatio_ * width; - this.canvas_.height = this.pixelRatio_ * height; - if (!this.cameraWasReset_) { - this.camera_.resetCamera(); - this.cameraWasReset_ = true; - } - return true; - }, - - readyToDraw: function() { - // If src isn't set yet, set it to ensure we can use - // the image to draw onto a canvas. - if (!this.chromeImages_.left.src) { - var leftContent = - window.getComputedStyle(this.chromeImages_.left).backgroundImage; - leftContent = tr.ui.b.extractUrlString(leftContent); - - var midContent = - window.getComputedStyle(this.chromeImages_.mid).backgroundImage; - midContent = tr.ui.b.extractUrlString(midContent); - - var rightContent = - window.getComputedStyle(this.chromeImages_.right).backgroundImage; - rightContent = tr.ui.b.extractUrlString(rightContent); - - this.chromeImages_.left.src = leftContent; - this.chromeImages_.mid.src = midContent; - this.chromeImages_.right.src = rightContent; - } - - // If all of the images are loaded (height > 0), then - // we are ready to draw. - return (this.chromeImages_.left.height > 0) && - (this.chromeImages_.mid.height > 0) && - (this.chromeImages_.right.height > 0); - }, - - get chromeQuad() { - if (this.chromeQuad_) - return this.chromeQuad_; - - // Draw the chrome border into a separate canvas. - var chromeCanvas = document.createElement('canvas'); - var offsetY = this.chromeImages_.left.height; - - chromeCanvas.width = this.deviceRect_.width; - chromeCanvas.height = this.deviceRect_.height + offsetY; - - var leftWidth = this.chromeImages_.left.width; - var midWidth = this.chromeImages_.mid.width; - var rightWidth = this.chromeImages_.right.width; - - var chromeCtx = chromeCanvas.getContext('2d'); - chromeCtx.drawImage(this.chromeImages_.left, 0, 0); - - chromeCtx.save(); - chromeCtx.translate(leftWidth, 0); - - // Calculate the scale of the mid image. - var s = (this.deviceRect_.width - leftWidth - rightWidth) / midWidth; - chromeCtx.scale(s, 1); - - chromeCtx.drawImage(this.chromeImages_.mid, 0, 0); - chromeCtx.restore(); - - chromeCtx.drawImage( - this.chromeImages_.right, leftWidth + s * midWidth, 0); - - // Construct the quad. - var chromeRect = tr.b.Rect.fromXYWH( - this.deviceRect_.x, - this.deviceRect_.y - offsetY, - this.deviceRect_.width, - this.deviceRect_.height + offsetY); - var chromeQuad = tr.b.Quad.fromRect(chromeRect); - chromeQuad.stackingGroupId = this.maxStackingGroupId_ + 1; - chromeQuad.imageData = chromeCtx.getImageData( - 0, 0, chromeCanvas.width, chromeCanvas.height); - chromeQuad.shadowOffset = [0, 0]; - chromeQuad.shadowBlur = 5; - chromeQuad.borderWidth = 3; - this.chromeQuad_ = chromeQuad; - return this.chromeQuad_; - }, - - scheduleRender: function() { - if (this.redrawScheduled_) - return false; - this.redrawScheduled_ = true; - tr.b.requestAnimationFrame(this.render, this); - }, - - onRenderRequired_: function(e) { - this.scheduleRender(); - }, - - stackTransformAndProcessQuads_: function( - numPasses, handleQuadFunc, includeChromeQuad, opt_arg1, opt_arg2) { - var mv = this.camera_.modelViewMatrix; - var p = this.camera_.projectionMatrix; - - var viewport = tr.b.Rect.fromXYWH( - 0, 0, this.canvas_.width, this.canvas_.height); - - // Calculate the quad stacks. - var quadStacks = []; - for (var i = 0; i < this.quads_.length; ++i) { - var quad = this.quads_[i]; - var stackingId = quad.stackingGroupId || 0; - while (stackingId >= quadStacks.length) - quadStacks.push([]); - - quadStacks[stackingId].push(quad); - } - - var mvp = mat4.create(); - this.maxStackingGroupId_ = quadStacks.length; - var effectiveStackingDistance = - this.stackingDistance * this.camera_.stackingDistanceDampening; - - // Draw the quad stacks, raising each subsequent level. - mat4.multiply(mvp, p, mv); - for (var i = 0; i < quadStacks.length; ++i) { - transformAndProcessQuads(mvp, viewport, quadStacks[i], - numPasses, handleQuadFunc, - opt_arg1, opt_arg2); - - mat4.translate(mv, mv, [0, 0, effectiveStackingDistance]); - mat4.multiply(mvp, p, mv); - } - - if (includeChromeQuad && this.deviceRect_) { - transformAndProcessQuads(mvp, viewport, [this.chromeQuad], - numPasses, drawProjectedQuadToContext, - opt_arg1, opt_arg2); - } - }, - - render: function() { - this.redrawScheduled_ = false; - - if (!this.readyToDraw()) { - setTimeout(this.scheduleRender.bind(this), - constants.IMAGE_LOAD_RETRY_TIME_MS); - return; - } - - if (!this.quads_) - return; - - var canvasCtx = this.canvas_.getContext('2d'); - if (!this.resize()) - canvasCtx.clearRect(0, 0, this.canvas_.width, this.canvas_.height); - - var quadCanvas = document.createElement('canvas'); - this.stackTransformAndProcessQuads_( - 3, drawProjectedQuadToContext, true, - canvasCtx, quadCanvas); - quadCanvas.width = 0; // Hack: Frees the quadCanvas' resources. - }, - - trackMouse_: function() { - this.mouseModeSelector_ = document.createElement( - 'tr-ui-b-mouse-mode-selector'); - this.mouseModeSelector_.targetElement = this.canvas_; - this.mouseModeSelector_.supportedModeMask = - tr.ui.b.MOUSE_SELECTOR_MODE.SELECTION | - tr.ui.b.MOUSE_SELECTOR_MODE.PANSCAN | - tr.ui.b.MOUSE_SELECTOR_MODE.ZOOM | - tr.ui.b.MOUSE_SELECTOR_MODE.ROTATE; - this.mouseModeSelector_.mode = tr.ui.b.MOUSE_SELECTOR_MODE.PANSCAN; - this.mouseModeSelector_.pos = {x: 0, y: 100}; - this.appendChild(this.mouseModeSelector_); - this.mouseModeSelector_.settingsKey = - 'quadStackView.mouseModeSelector'; - - this.mouseModeSelector_.setModifierForAlternateMode( - tr.ui.b.MOUSE_SELECTOR_MODE.ROTATE, tr.ui.b.MODIFIER.SHIFT); - this.mouseModeSelector_.setModifierForAlternateMode( - tr.ui.b.MOUSE_SELECTOR_MODE.PANSCAN, tr.ui.b.MODIFIER.SPACE); - this.mouseModeSelector_.setModifierForAlternateMode( - tr.ui.b.MOUSE_SELECTOR_MODE.ZOOM, tr.ui.b.MODIFIER.CMD_OR_CTRL); - - this.mouseModeSelector_.addEventListener('updateselection', - this.onSelectionUpdate_.bind(this)); - this.mouseModeSelector_.addEventListener('endselection', - this.onSelectionUpdate_.bind(this)); - }, - - extractRelativeMousePosition_: function(e) { - var br = this.canvas_.getBoundingClientRect(); - return [ - this.pixelRatio_ * (e.clientX - this.canvas_.offsetLeft - br.left), - this.pixelRatio_ * (e.clientY - this.canvas_.offsetTop - br.top) - ]; - }, - - onSelectionUpdate_: function(e) { - var mousePos = this.extractRelativeMousePosition_(e); - var res = []; - function handleQuad(passNumber, quad, p1, p2, p3, p4) { - if (tr.b.pointInImplicitQuad(mousePos, p1, p2, p3, p4)) - res.push(quad); - } - this.stackTransformAndProcessQuads_(1, handleQuad, false); - var e = new tr.b.Event('selectionchange'); - e.quads = res; - this.dispatchEvent(e); - } - }; - - return { - QuadStackView: QuadStackView - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/radio_picker.html b/chromium/third_party/catapult/tracing/tracing/ui/base/radio_picker.html deleted file mode 100644 index 85d204a9a30..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/radio_picker.html +++ /dev/null @@ -1,122 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2016 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/base/ui.html"> - -<polymer-element name='tr-ui-b-radio-picker'> - <template> - <style> - #container { - display: flex; - flex-direction: column; - } - </style> - - <div id="container"> - </div> - - </template> - - <script> - 'use strict'; - - Polymer({ - created: function() { - this.needsInit_ = true; - this.settingsKey_ = undefined; - this.is_ready_ = false; - this.radio_buttons_ = undefined; - // Keeping track of which key is selected. This member should only be set - // set inside select() method to make sure that logical state & the UI - // state is consistent. - this.selectedKey_ = undefined; - }, - - ready: function() { - this.is_ready_ = true; - this.maybeInit_(); - this.maybeRenderRadioButtons_(); - }, - - get settingsKey() { - return this.settingsKey_; - }, - - set settingsKey(settingsKey) { - if (!this.needsInit_) - throw new Error('Already initialized.'); - this.settingsKey_ = settingsKey; - this.maybeInit_(); - }, - - maybeInit_: function() { - if (!this.needsInit_) - return; - if (this.settingsKey_ === undefined) - return; - this.needsInit_ = false; - this.select(tr.b.Settings.get(this.settingsKey_)); - }, - - set items(items) { - this.radio_buttons_ = {}; - items.forEach(function(e) { - if (e.key in this.radio_buttons_) - throw new Error(e.key + ' already exists'); - var radio_button = document.createElement('div'); - var input = document.createElement('input'); - var label = document.createElement('div'); - input.type = 'radio'; - input.addEventListener('click', function() { - this.select(e.key); - }.bind(this)); - label.innerHTML = e.label; - label.style.display = 'inline'; - radio_button.appendChild(input); - radio_button.appendChild(label); - this.radio_buttons_[e.key] = input; - }.bind(this)); - - this.maybeInit_(); - this.maybeRenderRadioButtons_(); - }, - - maybeRenderRadioButtons_: function() { - if (!this.is_ready_) - return; - if (this.radio_buttons_ === undefined) - return; - for (var key in this.radio_buttons_) - this.$.container.appendChild(this.radio_buttons_[key].parentElement); - if (this.selectedKey_ !== undefined) - this.select(this.selectedKey_); - }, - - select: function(key) { - if (key === undefined) - return; - if (this.radio_buttons_ == undefined) { - this.selectedKey_ = key; - return; - } - if (!(key in this.radio_buttons_)) - throw new Error(key + ' does not exists'); - // Unselect the previous radio, update the key & select the new one. - if (this.selectedKey_ !== undefined) - this.radio_buttons_[this.selectedKey_].checked = false; - this.selectedKey_ = key; - tr.b.Settings.set(this.settingsKey_, this.selectedKey_); - if (this.selectedKey_ !== undefined) - this.radio_buttons_[this.selectedKey_].checked = true; - }, - - get selectedKey() { - return this.selectedKey_; - }, - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/radio_picker_test.html b/chromium/third_party/catapult/tracing/tracing/ui/base/radio_picker_test.html deleted file mode 100644 index dea60cdd492..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/radio_picker_test.html +++ /dev/null @@ -1,89 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2016 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/base/radio_picker.html"> -<link rel="import" href="/tracing/ui/base/dom_helpers.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - test('basic', function() { - var rp = document.createElement('tr-ui-b-radio-picker'); - rp.items = [ - {key: 'Toyota', label: 'I want to drive Toyota'}, - {key: 'Boeing', label: 'I want to fly'}, - {key: 'Submarine', label: 'I want to swim'} - ]; - this.addHTMLOutput(rp); - assert.equal(rp.selectedKey, undefined); - rp.select('Toyota'); - assert.equal(rp.selectedKey, 'Toyota'); - }); - - test('persistentState_setSelectedKeyAfterSettingItems', function() { - var items = [ - {key: 'Toyota', label: 'I want to drive Toyota'}, - {key: 'Boeing', label: 'I want to fly'}, - {key: 'Submarine', label: 'I want to swim'} - ]; - var container1 = tr.ui.b.createDiv({textContent: 'Radio Picker One'}); - container1.style.border = 'solid'; - var rp = document.createElement('tr-ui-b-radio-picker'); - rp.items = items; - rp.settingsKey = 'radio-picker-test-one'; - container1.appendChild(rp); - this.addHTMLOutput(container1); - assert.equal(rp.selectedKey, undefined); - rp.select('Toyota'); - assert.equal(rp.selectedKey, 'Toyota'); - - var container2 = tr.ui.b.createDiv({ - textContent: 'Radio Picker Two (same settingKey as Radio Picker One)'}); - container2.style.border = 'solid'; - var rp2 = document.createElement('tr-ui-b-radio-picker'); - rp2.items = items; - rp2.settingsKey = 'radio-picker-test-one'; - container2.appendChild(rp2); - this.addHTMLOutput(container2); - - assert.equal(rp2.selectedKey, 'Toyota'); - }); - - test('persistentState_setSelectedKeyBeforeSettingItems', function() { - var items = [ - {key: 'Toyota', label: 'I want to drive Toyota'}, - {key: 'Boeing', label: 'I want to fly'}, - {key: 'Submarine', label: 'I want to swim'} - ]; - var container1 = tr.ui.b.createDiv({textContent: 'Radio Picker One'}); - container1.style.border = 'solid'; - var rp = document.createElement('tr-ui-b-radio-picker'); - rp.settingsKey = 'radio-picker-test-two'; - rp.items = items; - container1.appendChild(rp); - this.addHTMLOutput(container1); - assert.equal(rp.selectedKey, undefined); - rp.select('Boeing'); - assert.equal(rp.selectedKey, 'Boeing'); - - var container2 = tr.ui.b.createDiv({ - textContent: 'Radio Picker Two (same settingKey as Radio Picker One)'}); - container2.style.border = 'solid'; - var rp2 = document.createElement('tr-ui-b-radio-picker'); - rp2.settingsKey = 'radio-picker-test-two'; - container2.appendChild(rp2); - this.addHTMLOutput(container2); - rp2.items = items; - - assert.equal(rp2.selectedKey, 'Boeing'); - }); - - - -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/resize_sensor.html b/chromium/third_party/catapult/tracing/tracing/ui/base/resize_sensor.html deleted file mode 100644 index bbb696062bf..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/resize_sensor.html +++ /dev/null @@ -1,50 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/base/utils.html"> - -<script src="/css-element-queries/src/ResizeSensor.js"></script> - -<!-- -@fileoverview A container that senses when its size changes. ---> -<polymer-element name="tr-ui-b-resize-sensor"> - <template> - <style> - :host { - display: flex; - flex: 1 1 auto; - } - </style> - <div id="container"> - <content></content> - </div> - </template> - - <script> - 'use strict'; - (function() { - Polymer({ - attached: function() { - // ResizeSensor only works if it's rooted in a document when it's - // created, so wait until the tr-ui-b-resize-sensor is attached to the - // DOM before creating the ResizeSensor. - this.sensor_ = new ResizeSensor(this.$.container, - this.onResize_.bind(this)); - // ResizeSensor appends a div to this.$.container. That div must be a - // direct sibling of <content>. - // ResizeSensor's first argument must be a Node, so it cannot be - // this.shadowRoot. - }, - - onResize_: function() { - this.dispatchEvent(new tr.b.Event('resize', false, false)); - } - }); - })(); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/resize_sensor_test.html b/chromium/third_party/catapult/tracing/tracing/ui/base/resize_sensor_test.html deleted file mode 100644 index fea1f71669b..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/resize_sensor_test.html +++ /dev/null @@ -1,56 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/task.html"> -<link rel="import" href="/tracing/ui/base/resize_sensor.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - function forceLayout(element) { - element.offsetHeight; - } - - test('instantiate', function() { - var sensor = document.createElement('tr-ui-b-resize-sensor'); - sensor.appendChild(document.createTextNode('hello')); - - var resizeCount = 0; - function onResize(event) { - resizeCount += 1; - } - - this.addHTMLOutput(sensor); - forceLayout(sensor); - sensor.addEventListener('resize', onResize); - - // Trigger a resize: - sensor.style.fontSize = '20pt'; - forceLayout(sensor); - - // The event doesn't fire synchronously, so return a Promise that will - // resolve whenever the test is done. - return new Promise(function(resolve, reject) { - // The resize event fires when the sensor is re-laid-out. - // Use requestAnimationFrame to wait until after the sensor is - // re-laid-out. - // This doesn't work if the page becomes invisible. - window.requestAnimationFrame(function() { - assert.equal(1, resizeCount); - sensor.removeEventListener('resize', onResize); - sensor.style.fontSize = '12pt'; - forceLayout(sensor); - window.requestAnimationFrame(function() { - assert.equal(1, resizeCount); - resolve(); - }); - }); - }); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/scatter_chart.html b/chromium/third_party/catapult/tracing/tracing/ui/base/scatter_chart.html deleted file mode 100644 index 5dffbe8da02..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/scatter_chart.html +++ /dev/null @@ -1,118 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/range.html"> -<link rel="import" href="/tracing/ui/base/chart_base_2d.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.b', function() { - var ChartBase2D = tr.ui.b.ChartBase2D; - - // @constructor - var ScatterChart = tr.ui.b.define('scatter-chart', ChartBase2D); - - // @constructor - ScatterChart.Dot = function(x, y, radius, color, breadcrumb) { - this.x = x; - this.y = y; - this.radius = radius; - this.color = color; - this.breadcrumb = breadcrumb; - }; - - ScatterChart.prototype = { - __proto__: ChartBase2D.prototype, - - decorate: function() { - ChartBase2D.prototype.decorate.call(this); - this.classList.add('scatter-chart'); - - this.brushedXRange_ = new tr.b.Range(); - this.brushedYRange_ = new tr.b.Range(); - }, - - setBrushedRanges: function(xRange, yRange) { - this.brushedXRange_.reset(); - this.brushedYRange_.reset(); - if (!xRange.isEmpty && !yRange.isEmpty) { - this.brushedXRange_.addRange(xRange); - this.brushedYRange_.addRange(yRange); - } - this.updateContents_(); - }, - - updateBrushContents_: function(brushSel) { - brushSel.selectAll('*').remove(); - var brushes = []; - if (!this.brushedXRange_.isEmpty && !this.brushedYRange_.isEmpty) - brushes.push({}); - var brushRectsSel = brushSel.selectAll('rect').data(brushes); - brushRectsSel.enter().append('rect'); - brushRectsSel.exit().remove(); - brushRectsSel - .attr('x', function(d) { - return this.xScale_(this.brushedXRange_.min); - }.bind(this)) - .attr('y', function(d) { - return this.yScale_(this.brushedYRange_.max); - }.bind(this)) - .attr('width', function(d) { - return this.xScale_(this.brushedXRange_.max) - - this.xScale_(this.brushedXRange_.min); - }.bind(this)) - .attr('height', function(d) { - return this.yScale_(this.brushedYRange_.min) - - this.yScale_(this.brushedYRange_.max); - }.bind(this)); - }, - - setDataFromCallbacks: function(data, getX, getY, getRadius, getColor) { - this.data = data.map(function(datum) { - return new ScatterChart.Dot(getX(datum), - getY(datum), - getRadius(datum), - getColor(datum), - datum); - }); - }, - - isDatumFieldSeries_: function(fieldName) { - return fieldName === 'y'; - }, - - getXForDatum_: function(datum, index) { - return datum.x; - }, - - updateDataContents_: function(dataSel) { - dataSel.selectAll('*').remove(); - var dotsSel = dataSel.selectAll('circle') - .data(this.data_) - .enter() - .append('circle'); - dotsSel.attr('cx', function(datum) { - return this.xScale_(datum.x); - }.bind(this)) - .attr('cy', function(datum) { - return this.yScale_(datum.y); - }.bind(this)) - .attr('r', function(datum) { - return tr.b.clamp(datum.radius, 2, 10); - }.bind(this)) - .attr('fill', function(datum) { - return datum.color; - }.bind(this)); - } - }; - - return { - ScatterChart: ScatterChart - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/scatter_chart_test.html b/chromium/third_party/catapult/tracing/tracing/ui/base/scatter_chart_test.html deleted file mode 100644 index 6b9243fa02f..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/scatter_chart_test.html +++ /dev/null @@ -1,71 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/base/scatter_chart.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - test('instantiation_singleSeries', function() { - var chart = new tr.ui.b.ScatterChart(); - chart.width = 400; - chart.height = 200; - chart.chartTitle = 'Chart title'; - var data = [ - {x: 10, y: 100, radius: 2, color: 'red'}, - {x: 20, y: 110, radius: 10, color: 'red'}, - {x: 30, y: 100, radius: 10, color: 'red'}, - {x: 40, y: 50, radius: 10, color: 'red'} - ]; - chart.data = data; - this.addHTMLOutput(chart); - }); - - test('instantiation_interactiveBrushing', function() { - var chart = new tr.ui.b.ScatterChart(); - chart.width = 400; - chart.height = 200; - chart.chartTitle = 'Chart title'; - var data = [ - {x: 10, y: 50, radius: 2, color: 'blue'}, - {x: 20, y: 60, radius: 3, color: 'red'}, - {x: 30, y: 80, radius: 4, color: 'orange'}, - {x: 40, y: 20, radius: 5, color: 'purple'}, - {x: 50, y: 30, radius: 6, color: 'yellow'}, - {x: 60, y: 20, radius: 7, color: 'green'}, - {x: 70, y: 15, radius: 8, color: 'blue'}, - {x: 80, y: 20, radius: 9, color: 'red'} - ]; - chart.data = data; - - var mouseDown = undefined; - - function updateBrushedRange(e) { - var xRange = new tr.b.Range(); - xRange.addValue(mouseDown.x); - xRange.addValue(e.x); - var yRange = new tr.b.Range(); - yRange.addValue(mouseDown.y); - yRange.addValue(e.y); - chart.setBrushedRanges(xRange, yRange); - } - - chart.addEventListener('item-mousedown', function(e) { - mouseDown = e; - }); - chart.addEventListener('item-mousemove', function(e) { - updateBrushedRange(e); - }); - chart.addEventListener('item-mouseup', function(e) { - updateBrushedRange(e); - mouseDown = undefined; - }); - this.addHTMLOutput(chart); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/tab_view.html b/chromium/third_party/catapult/tracing/tracing/ui/base/tab_view.html deleted file mode 100644 index c8ecceb51cd..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/tab_view.html +++ /dev/null @@ -1,428 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<polymer-element name="tr-ui-a-tab-view" - constructor="TracingAnalysisTabView"> - <template> - <style> - :host { - display: flex; - flex-flow: column nowrap; - overflow: hidden; - box-sizing: border-box; - } - - tab-strip[tabs-hidden] { - display: none; - } - - tab-strip { - background-color: rgb(236, 236, 236); - border-bottom: 1px solid #8e8e8e; - display: flex; - flex: 0 0 auto; - flex-flow: row; - overflow-x: auto; - padding: 0 10px 0 10px; - font-size: 12px; - } - - tab-button { - display: block; - flex: 0 0 auto; - padding: 4px 15px 1px 15px; - margin-top: 2px; - } - - tab-button[selected=true] { - background-color: white; - border: 1px solid rgb(163, 163, 163); - border-bottom: none; - padding: 3px 14px 1px 14px; - } - - tabs-content-container { - display: flex; - flex: 1 1 auto; - overflow: auto; - width: 100%; - } - - ::content > * { - flex: 1 1 auto; - } - - ::content > *:not([selected]) { - display: none; - } - - button-label { - display: inline; - } - - tab-strip-heading { - display: block; - flex: 0 0 auto; - padding: 4px 15px 1px 15px; - margin-top: 2px; - margin-before: 20px; - margin-after: 10px; - } - #tsh { - display: inline; - font-weight: bold; - } - </style> - - <tab-strip> - <tab-strip-heading id="tshh"> - <span id="tsh"></span> - </tab-strip-heading> - <template repeat="{{tab in tabs_}}"> - <tab-button - button-id="{{ tab.id }}" - on-click="{{ tabButtonSelectHandler_ }}" - selected="{{ selectedTab_.id === tab.id }}"> - <button-label>{{ tab.label ? tab.label : 'No Label'}}</button-label> - </tab-button> - </template> - </tab-strip> - - <tabs-content-container id='content-container'> - <content></content> - </tabs-content-container> - - </template> - - <script> - 'use strict'; - Polymer({ - ready: function() { - this.$.tshh.style.display = 'none'; - - // A tab is represented by the following tuple: - // (id, label, content, observer, savedScrollTop, savedScrollLeft). - // The properties are used in the following way: - // id: Uniquely identifies a tab. It is the same number as the index - // in the tabs array. Used primarily by the on-click event attached - // to buttons. - // label: A string, representing the label printed on the tab button. - // content: The light-dom child representing the contents of the tab. - // The content is appended to this tab-view by the user. - // observers: The observers attached to the content node to watch for - // attribute changes. The attributes of interest are: 'selected', - // and 'tab-label'. - // savedScrollTop/Left: Used to return the scroll position upon switching - // tabs. The values are generally saved when a tab switch occurs. - // - // The order of the tabs is relevant for the tab ordering. - this.tabs_ = []; - this.selectedTab_ = undefined; - - // Register any already existing children. - for (var i = 0; i < this.children.length; i++) - this.processAddedChild_(this.children[i]); - - // In case the user decides to add more tabs, make sure we watch for - // any child mutations. - this.childrenObserver_ = new MutationObserver( - this.childrenUpdated_.bind(this)); - this.childrenObserver_.observe(this, { childList: 'true' }); - }, - - get tabStripHeadingText() { - return this.$.tsh.textContent; - }, - - set tabStripHeadingText(tabStripHeadingText) { - this.$.tsh.textContent = tabStripHeadingText; - if (!!tabStripHeadingText) - this.$.tshh.style.display = ''; - else - this.$.tshh.style.display = 'none'; - }, - - get selectedTab() { - // Make sure we process any pending children additions / removals, before - // trying to select a tab. Otherwise, we might not find some children. - this.childrenUpdated_( - this.childrenObserver_.takeRecords(), this.childrenObserver_); - - // Do not give access to the user to the inner data structure. - // A user should only be able to mutate the added tab content. - if (this.selectedTab_) - return this.selectedTab_.content; - return undefined; - }, - - set selectedTab(content) { - // Make sure we process any pending children additions / removals, before - // trying to select a tab. Otherwise, we might not find some children. - this.childrenUpdated_( - this.childrenObserver_.takeRecords(), this.childrenObserver_); - - if (content === undefined || content === null) { - this.changeSelectedTabById_(undefined); - return; - } - - // Search for the specific node in our tabs list. - // If it is not there print a warning. - var contentTabId = undefined; - for (var i = 0; i < this.tabs_.length; i++) - if (this.tabs_[i].content === content) { - contentTabId = this.tabs_[i].id; - break; - } - - if (contentTabId === undefined) - return; - - this.changeSelectedTabById_(contentTabId); - }, - - get tabsHidden() { - var ts = this.shadowRoot.querySelector('tab-strip'); - return ts.hasAttribute('tabs-hidden'); - }, - - set tabsHidden(tabsHidden) { - tabsHidden = !!tabsHidden; - var ts = this.shadowRoot.querySelector('tab-strip'); - if (tabsHidden) - ts.setAttribute('tabs-hidden', true); - else - ts.removeAttribute('tabs-hidden'); - }, - - get tabs() { - return this.tabs_.map(function(tabObject) { - return tabObject.content; - }); - }, - - /** - * Function called on light-dom child addition. - */ - processAddedChild_: function(child) { - var observerAttributeSelected = new MutationObserver( - this.childAttributesChanged_.bind(this)); - var observerAttributeTabLabel = new MutationObserver( - this.childAttributesChanged_.bind(this)); - var tabObject = { - id: this.tabs_.length, - content: child, - label: child.getAttribute('tab-label'), - observers: { - forAttributeSelected: observerAttributeSelected, - forAttributeTabLabel: observerAttributeTabLabel - } - }; - - this.tabs_.push(tabObject); - if (child.hasAttribute('selected')) { - // When receiving a child with the selected attribute, if we have no - // selected tab, mark the child as the selected tab, otherwise keep - // the previous selection. - if (this.selectedTab_) - child.removeAttribute('selected'); - else - this.setSelectedTabById_(tabObject.id); - } - - // This is required because the user might have set the selected - // property before we got to process the child. - var previousSelected = child.selected; - - var tabView = this; - - Object.defineProperty( - child, - 'selected', { - configurable: true, - set: function(value) { - if (value) { - tabView.changeSelectedTabById_(tabObject.id); - return; - } - - var wasSelected = tabView.selectedTab_ === tabObject; - if (wasSelected) - tabView.changeSelectedTabById_(undefined); - }, - get: function() { - return this.hasAttribute('selected'); - } - }); - - if (previousSelected) - child.selected = previousSelected; - - observerAttributeSelected.observe(child, - { attributeFilter: ['selected'] }); - observerAttributeTabLabel.observe(child, - { attributeFilter: ['tab-label'] }); - - }, - - /** - * Function called on light-dom child removal. - */ - processRemovedChild_: function(child) { - for (var i = 0; i < this.tabs_.length; i++) { - // Make sure ids are the same as the tab position after removal. - this.tabs_[i].id = i; - if (this.tabs_[i].content === child) { - this.tabs_[i].observers.forAttributeSelected.disconnect(); - this.tabs_[i].observers.forAttributeTabLabel.disconnect(); - // The user has removed the currently selected tab. - if (this.tabs_[i] === this.selectedTab_) { - this.clearSelectedTab_(); - this.fire('selected-tab-change'); - } - child.removeAttribute('selected'); - delete child.selected; - // Remove the observer since we no longer care about this child. - this.tabs_.splice(i, 1); - i--; - } - } - }, - - - /** - * This function handles child attribute changes. The only relevant - * attributes for the tab-view are 'tab-label' and 'selected'. - */ - childAttributesChanged_: function(mutations, observer) { - var tabObject = undefined; - // First figure out which child has been changed. - for (var i = 0; i < this.tabs_.length; i++) { - var observers = this.tabs_[i].observers; - if (observers.forAttributeSelected === observer || - observers.forAttributeTabLabel === observer) { - tabObject = this.tabs_[i]; - break; - } - } - - // This should not happen, unless the user has messed with our internal - // data structure. - if (!tabObject) - return; - - // Next handle the attribute changes. - for (var i = 0; i < mutations.length; i++) { - var node = tabObject.content; - // 'tab-label' attribute has been changed. - if (mutations[i].attributeName === 'tab-label') - tabObject.label = node.getAttribute('tab-label'); - // 'selected' attribute has been changed. - if (mutations[i].attributeName === 'selected') { - // The attribute has been set. - var nodeIsSelected = node.hasAttribute('selected'); - if (nodeIsSelected) - this.changeSelectedTabById_(tabObject.id); - else - this.changeSelectedTabById_(undefined); - } - } - }, - - /** - * This function handles light-dom additions and removals from the - * tab-view component. - */ - childrenUpdated_: function(mutations, observer) { - mutations.forEach(function(mutation) { - for (var i = 0; i < mutation.removedNodes.length; i++) - this.processRemovedChild_(mutation.removedNodes[i]); - for (var i = 0; i < mutation.addedNodes.length; i++) - this.processAddedChild_(mutation.addedNodes[i]); - }, this); - }, - - /** - * Handler called when a click event happens on any of the tab buttons. - */ - tabButtonSelectHandler_: function(event, detail, sender) { - this.changeSelectedTabById_(sender.getAttribute('button-id')); - }, - - /** - * This does the actual work. :) - */ - changeSelectedTabById_: function(id) { - var newTab = id !== undefined ? this.tabs_[id] : undefined; - var changed = this.selectedTab_ !== newTab; - this.saveCurrentTabScrollPosition_(); - this.clearSelectedTab_(); - if (id !== undefined) { - this.setSelectedTabById_(id); - this.restoreCurrentTabScrollPosition_(); - } - - if (changed) - this.fire('selected-tab-change'); - }, - - /** - * This function updates the currently selected tab based on its internal - * id. The corresponding light-dom element receives the selected attribute. - */ - setSelectedTabById_: function(id) { - this.selectedTab_ = this.tabs_[id]; - // Disconnect observer while we mutate the child. - this.selectedTab_.observers.forAttributeSelected.disconnect(); - this.selectedTab_.content.setAttribute('selected', 'selected'); - // Reconnect the observer to watch for changes in the future. - this.selectedTab_.observers.forAttributeSelected.observe( - this.selectedTab_.content, { attributeFilter: ['selected'] }); - - }, - - saveTabStates: function() { - // Scroll positions of unselected tabs have already been saved. - this.saveCurrentTabScrollPosition_(); - }, - - saveCurrentTabScrollPosition_: function() { - if (this.selectedTab_) { - this.selectedTab_.content._savedScrollTop = - this.$['content-container'].scrollTop; - this.selectedTab_.content._savedScrollLeft = - this.$['content-container'].scrollLeft; - } - }, - - restoreCurrentTabScrollPosition_: function() { - if (this.selectedTab_) { - this.$['content-container'].scrollTop = - this.selectedTab_.content._savedScrollTop || 0; - this.$['content-container'].scrollLeft = - this.selectedTab_.content._savedScrollLeft || 0; - } - }, - - /** - * This function clears the currently selected tab. This handles removal - * of the selected attribute from the light-dom element. - */ - clearSelectedTab_: function() { - if (this.selectedTab_) { - // Disconnect observer while we mutate the child. - this.selectedTab_.observers.forAttributeSelected.disconnect(); - this.selectedTab_.content.removeAttribute('selected'); - // Reconnect the observer to watch for changes in the future. - this.selectedTab_.observers.forAttributeSelected.observe( - this.selectedTab_.content, { attributeFilter: ['selected'] }); - this.selectedTab_ = undefined; - } - } - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/tab_view_test.html b/chromium/third_party/catapult/tracing/tracing/ui/base/tab_view_test.html deleted file mode 100644 index 42f16e594ae..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/tab_view_test.html +++ /dev/null @@ -1,323 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/base/tab_view.html"> - -<template id="tab-view-test-template"> - <tr-ui-a-tab-view> - <p tab-label="Existing Label"> Tab with label already set </p> - <p> Tab Content with no label </p> - <p selected="selected" tab-label="Should be selected"> - Already selected tab - </p> - <p selected="selected" tab-label="Should not be selected"> - Second already selected tab - </p> - </tr-ui-a-tab-view> -</template> -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var THIS_DOC = document._currentScript.ownerDocument; - - test('instantiate', function() { - - var TAB_TEXT = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.' + - ' Cras eleifend elit nec erat tristique pellentesque. Cras placerat ' + - 'lectus, sed semper tortor ornare quis. Maecenas vitae hendrerit. ' + - 'Cras mattis interdum nisi, eget egestas dui iaculis ultricies. Proi' + - 'n magna at nibh fringilla tincidunt id vitae ante. Fusce nec urna n' + - 'on porttitor tincidunt. Pellentesque habitant morbi tristique senec' + - 'tus netus et malesuada fames ac turpis egestas. Suspendisse sed vel' + - 'it mollis ornare sit amet vel augue. Nullam rhoncus in tellus id. ' + - 'Vestibulum ante ipsum primis in faucibus orci luctus et ultrices ' + - 'cubilia Curae; Nunc at velit consectetur ipsum tempus tempus. Nunc ' + - 'mattis sapien, a placerat erat. Vivamus ac enim ultricies, gravida ' + - 'nulla ut, scelerisque magna. Sed a volutpat enim. Morbi vulputate, ' + - 'sed egestas mollis, urna nisl varius sem, sed venenatis turpis null' + - 'a ipsum. Suspendisse potenti.'; - - var tabViewContainer = document.createElement('div'); - tabViewContainer.style.width = '500px'; - tabViewContainer.style.height = '200px'; - - var tabView = new TracingAnalysisTabView(); - - var firstTab = document.createElement('div'); - firstTab.setAttribute('tab-label', 'First Tab Label'); - firstTab.innerHTML = '<p>' + TAB_TEXT + '<p>'; - - var secondTab = document.createElement('div'); - secondTab.setAttribute('tab-label', 'Second Tab Label'); - secondTab.innerHTML = '<b>' + 'Second Tab Text' + '</b>'; - - var thirdTab = document.createElement('div'); - thirdTab.setAttribute('tab-label', 'Third Tab Label'); - thirdTab.innerHTML = '<b>' + 'Third Tab Text' + '</b>'; - - tabView.appendChild(firstTab); - tabView.appendChild(secondTab); - tabView.appendChild(thirdTab); - tabViewContainer.appendChild(tabView); - - this.addHTMLOutput(tabViewContainer); - - thirdTab.setAttribute('tab-label', 'Something Different'); - - var button = document.createElement('button'); - button.textContent = 'Change label'; - - button.addEventListener('click', function() { - thirdTab.setAttribute('tab-label', 'Label Changed'); - }); - - tabView.selectedTab = secondTab; - this.addHTMLOutput(button); - }); - - - test('instantiateWithTabHeading', function() { - var TAB_TEXT = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.' + - ' Cras eleifend elit nec erat tristique pellentesque. Cras placerat ' + - 'lectus, sed semper tortor ornare quis. Maecenas vitae hendrerit. ' + - 'Cras mattis interdum nisi, eget egestas dui iaculis ultricies. Proi' + - 'n magna at nibh fringilla tincidunt id vitae ante. Fusce nec urna n' + - 'on porttitor tincidunt. Pellentesque habitant morbi tristique senec' + - 'tus netus et malesuada fames ac turpis egestas. Suspendisse sed vel' + - 'it mollis ornare sit amet vel augue. Nullam rhoncus in tellus id. ' + - 'Vestibulum ante ipsum primis in faucibus orci luctus et ultrices ' + - 'cubilia Curae; Nunc at velit consectetur ipsum tempus tempus. Nunc ' + - 'mattis sapien, a placerat erat. Vivamus ac enim ultricies, gravida ' + - 'nulla ut, scelerisque magna. Sed a volutpat enim. Morbi vulputate, ' + - 'sed egestas mollis, urna nisl varius sem, sed venenatis turpis null' + - 'a ipsum. Suspendisse potenti.'; - - var tabViewContainer = document.createElement('div'); - tabViewContainer.style.width = '500px'; - tabViewContainer.style.height = '200px'; - - var tabView = new TracingAnalysisTabView(); - tabView.tabStripHeadingText = 'Hello world:'; - - var firstTab = document.createElement('div'); - firstTab.setAttribute('tab-label', 'First Tab Label'); - firstTab.innerHTML = '<p>' + TAB_TEXT + '<p>'; - - var secondTab = document.createElement('div'); - secondTab.setAttribute('tab-label', 'Second Tab Label'); - secondTab.innerHTML = '<b>' + 'Second Tab Text' + '</b>'; - - var thirdTab = document.createElement('div'); - thirdTab.setAttribute('tab-label', 'Third Tab Label'); - thirdTab.innerHTML = '<b>' + 'Third Tab Text' + '</b>'; - - tabView.appendChild(firstTab); - tabView.appendChild(secondTab); - tabView.appendChild(thirdTab); - tabViewContainer.appendChild(tabView); - - this.addHTMLOutput(tabViewContainer); - tabView.selectedTab = secondTab; - }); - - test('instantiateChildrenAlreadyInside', function() { - var tabViewTemplate = THIS_DOC.querySelector('#tab-view-test-template'); - var tabView = tabViewTemplate.createInstance(); - - var tabViewContainer = document.createElement('div'); - tabViewContainer.style.width = '400px'; - tabViewContainer.style.height = '200px'; - - tabViewContainer.appendChild(tabView); - - this.addHTMLOutput(tabViewContainer); - - }); - - test('programaticallySetSelectedTab', function() { - var tabViewContainer = document.createElement('div'); - tabViewContainer.style.width = '500px'; - tabViewContainer.style.height = '200px'; - - var tabView = new TracingAnalysisTabView(); - - var t1 = document.createElement('div'); - var t2 = document.createElement('div'); - var t3 = document.createElement('div'); - - tabView.appendChild(t1); - tabView.appendChild(t2); - tabView.appendChild(t3); - - assert.isUndefined(tabView.selectedTab); - tabView.selectedTab = t1; - - assert.isTrue(t1.hasAttribute('selected')); - assert.isFalse(t2.hasAttribute('selected')); - assert.isFalse(t3.hasAttribute('selected')); - assert.isTrue(Object.is(t1, tabView.selectedTab)); - - tabView.selectedTab = t2; - assert.isFalse(t1.hasAttribute('selected')); - assert.isTrue(t2.hasAttribute('selected')); - assert.isFalse(t3.hasAttribute('selected')); - assert.isTrue(Object.is(t2, tabView.selectedTab)); - - tabView.selectedTab = t3; - assert.isFalse(t1.hasAttribute('selected')); - assert.isFalse(t2.hasAttribute('selected')); - assert.isTrue(t3.hasAttribute('selected')); - assert.isTrue(Object.is(t3, tabView.selectedTab)); - - t1.selected = true; - assert.isTrue(t1.hasAttribute('selected')); - assert.isFalse(t2.hasAttribute('selected')); - assert.isFalse(t3.hasAttribute('selected')); - assert.isTrue(Object.is(t1, tabView.selectedTab)); - - // Make sure just randomly setting a tab as not selected does not - // break the existing selection. - t2.selected = false; - t3.selected = false; - assert.isTrue(t1.hasAttribute('selected')); - assert.isFalse(t2.hasAttribute('selected')); - assert.isFalse(t3.hasAttribute('selected')); - assert.isTrue(Object.is(t1, tabView.selectedTab)); - - t3.selected = true; - assert.isFalse(t1.hasAttribute('selected')); - assert.isFalse(t2.hasAttribute('selected')); - assert.isTrue(t3.hasAttribute('selected')); - assert.isTrue(Object.is(t3, tabView.selectedTab)); - - tabViewContainer.appendChild(tabView); - - this.addHTMLOutput(tabViewContainer); - }); - - /** - * This test checks that if an element has a selected property already set, - * before being attached to the tabView, it still gets selected if the - * property is true, after it gets attached. - */ - test('instantiateSetSelectedTabAlreadySet', function() { - var tabViewContainer = document.createElement('div'); - tabViewContainer.style.width = '500px'; - tabViewContainer.style.height = '200px'; - - var tabView = new TracingAnalysisTabView(); - - var t1 = document.createElement('div'); - t1.textContent = 'This text should BE visible.'; - var t2 = document.createElement('div'); - t2.textContent = 'This text should NOT be visible.'; - var t3 = document.createElement('div'); - t3.textContent = 'This text should NOT be visible, also.'; - - t1.selected = true; - t2.selected = false; - t3.selected = false; - - tabView.appendChild(t1); - tabView.appendChild(t2); - tabView.appendChild(t3); - - t1.setAttribute('tab-label', 'This should be selected'); - t2.setAttribute('tab-label', 'Not selected'); - t3.setAttribute('tab-label', 'Not selected'); - - tabViewContainer.appendChild(tabView); - - this.addHTMLOutput(tabViewContainer); - }); - - test('selectingInvalidTabWorks', function() { - var tabView = new TracingAnalysisTabView(); - var t1 = document.createElement('div'); - var t2 = document.createElement('div'); - var t3 = document.createElement('div'); - var invalidChild = document.createElement('div'); - - tabView.appendChild(t1); - tabView.appendChild(t2); - tabView.appendChild(t3); - - tabView.selectedTab = t1; - - assert.equal(tabView.selectedTab, t1); - - // Make sure that selecting an invalid tab does not break the current - // selection. - tabView.selectedTab = invalidChild; - assert.equal(t1, tabView.selectedTab); - - // Also make sure the invalidChild does not influence the tab view when - // it has a selected property set. - invalidChild.selected = true; - tabView.selectedTab = invalidChild; - assert.equal(t1, tabView.selectedTab); - }); - - test('changeTabCausesEvent', function() { - var tabView = new TracingAnalysisTabView(); - var t1 = document.createElement('div'); - var t2 = document.createElement('div'); - var invalidChild = document.createElement('div'); - - tabView.appendChild(t1); - tabView.appendChild(t2); - - var numChangeEvents = 0; - tabView.addEventListener('selected-tab-change', function() { - numChangeEvents++; - }); - tabView.selectedTab = t1; - assert.equal(numChangeEvents, 1); - tabView.selectedTab = t1; - assert.equal(numChangeEvents, 1); - tabView.selectedTab = t2; - assert.equal(numChangeEvents, 2); - tabView.selectedTab = undefined; - assert.equal(numChangeEvents, 3); - }); - - /** - * This test makes sure that removing the selected tab does not select - * any other tab. - */ - test('instantiateRemovingSelectedTab', function() { - var tabViewContainer = document.createElement('div'); - tabViewContainer.style.width = '500px'; - tabViewContainer.style.height = '200px'; - - var tabView = new TracingAnalysisTabView(); - - var t1 = document.createElement('div'); - t1.textContent = 'This text should BE visible.'; - var t2 = document.createElement('div'); - t2.textContent = 'This text should NOT be visible.'; - var t3 = document.createElement('div'); - t3.textContent = 'This text should NOT be visible, also.'; - - tabView.appendChild(t1); - tabView.appendChild(t2); - tabView.appendChild(t3); - - t1.setAttribute('tab-label', 'This should not exist'); - t2.setAttribute('tab-label', 'Not selected'); - t3.setAttribute('tab-label', 'Not selected'); - - tabView.selectedTab = t1; - tabView.removeChild(t1); - - tabViewContainer.appendChild(tabView); - - this.addHTMLOutput(tabViewContainer); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/table.html b/chromium/third_party/catapult/tracing/tracing/ui/base/table.html deleted file mode 100644 index 1292a3af758..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/table.html +++ /dev/null @@ -1,1473 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/base/dom_helpers.html"> -<link rel="import" href="/tracing/ui/base/utils.html"> - -<!-- -@fileoverview A container that constructs a table-like container. ---> -<script> -'use strict'; - -tr.exportTo('tr.ui.b', function() { - - var TableFormat = {}; - - TableFormat.SelectionMode = { - // Selection disabled. - // Default highlight: none. - NONE: 0, - - // Row selection mode. - // Default highlight: dark row. - ROW: 1, - - // Cell selection mode. - // Default highlight: dark cell and light row. - CELL: 2 - }; - - TableFormat.HighlightStyle = { - // Highlight depends on the current selection mode. - DEFAULT: 0, - - // No highlight. - NONE: 1, - - // Light highlight. - LIGHT: 2, - - // Dark highlight. - DARK: 3 - }; - - TableFormat.ColumnAlignment = { - LEFT: 0 /* default */, - RIGHT: 1 - }; - - return { - TableFormat: TableFormat - }; -}); -</script> - -<polymer-element name="tr-ui-b-table"> - <template> - <style> - :host { - display: flex; - flex-direction: column; - } - - table { - font-size: 12px; - - flex: 1 1 auto; - align-self: stretch; - border-collapse: separate; - border-spacing: 0; - border-width: 0; - -webkit-user-select: initial; - } - - tr > td { - padding: 2px 4px 2px 4px; - vertical-align: text-top; - } - - tr:focus, - td:focus { - outline: 1px dotted rgba(0,0,0,0.1); - outline-offset: 0; - } - - button.toggle-button { - height: 15px; - line-height: 60%; - vertical-align: middle; - width: 100%; - } - - button > * { - height: 15px; - vertical-align: middle; - } - - td.button-column { - width: 30px; - } - - table > thead > tr > td.sensitive:hover { - background-color: #fcfcfc; - } - - table > thead > tr > td { - font-weight: bold; - text-align: left; - - background-color: #eee; - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; - - border-top: 1px solid #ffffff; - border-bottom: 1px solid #aaa; - } - - table > tfoot { - background-color: #eee; - font-weight: bold; - } - - /* Light row and cell highlight. */ - table > tbody[row-highlight-style="light"] > tr[selected], - table > tbody[cell-highlight-style="light"] > tr > td[selected] { - background-color: rgb(213, 236, 229); /* light turquoise */ - } - table > tbody[row-highlight-style="light"] > - tr:not(.empty-row):not([selected]):hover, - table > tbody[cell-highlight-style="light"] > - tr:not(.empty-row):not([selected]) > td:hover { - background-color: #f6f6f6; /* light grey */ - } - - /* Dark row and cell highlight. */ - table > tbody[row-highlight-style="dark"] > tr[selected], - table > tbody[cell-highlight-style="dark"] > tr > td[selected] { - background-color: rgb(103, 199, 165); /* turquoise */ - } - table > tbody[row-highlight-style="dark"] > - tr:not(.empty-row):not([selected]):hover, - table > tbody[cell-highlight-style="dark"] > - tr:not(.empty-row):not([selected]) > td:hover { - background-color: #e6e6e6; /* grey */ - } - table > tbody[row-highlight-style="dark"] > tr:hover[selected], - table > tbody[cell-highlight-style="dark"] > tr[selected] > td:hover { - background-color: rgb(171, 217, 202); /* semi-light turquoise */ - } - - table > tbody > tr.empty-row > td { - color: #666; - font-style: italic; - text-align: center; - } - - table > tbody.has-footer > tr:last-child > td { - border-bottom: 1px solid #aaa; - } - - table > tfoot > tr:first-child > td { - border-top: 1px solid #ffffff; - } - - expand-button { - -webkit-user-select: none; - display: inline-block; - cursor: pointer; - font-size: 9px; - min-width: 8px; - max-width: 8px; - } - - .button-expanded { - transform: rotate(90deg); - } - </style> - <table> - <thead id="head"> - </thead> - <tbody id="body"> - </tbody> - <tfoot id="foot"> - </tfoot> - </table> - </template> - <script> - 'use strict'; - (function() { - var RIGHT_ARROW = String.fromCharCode(0x25b6); - var UNSORTED_ARROW = String.fromCharCode(0x25BF); - var ASCENDING_ARROW = String.fromCharCode(0x25B4); - var DESCENDING_ARROW = String.fromCharCode(0x25BE); - var BASIC_INDENTATION = 8; - - var SelectionMode = tr.ui.b.TableFormat.SelectionMode; - var HighlightStyle = tr.ui.b.TableFormat.HighlightStyle; - var ColumnAlignment = tr.ui.b.TableFormat.ColumnAlignment; - - Polymer({ - created: function() { - this.selectionMode_ = SelectionMode.NONE; - this.rowHighlightStyle_ = HighlightStyle.DEFAULT; - this.cellHighlightStyle_ = HighlightStyle.DEFAULT; - this.selectedTableRowInfo_ = undefined; - this.selectedColumnIndex_ = undefined; - - this.tableColumns_ = []; - this.tableRows_ = []; - this.tableRowsInfo_ = new WeakMap(); - this.tableFooterRows_ = []; - this.tableFooterRowsInfo_ = new WeakMap(); - this.sortColumnIndex_ = undefined; - this.sortDescending_ = false; - this.columnsWithExpandButtons_ = []; - this.headerCells_ = []; - this.showHeader_ = true; - this.emptyValue_ = undefined; - this.subRowsPropertyName_ = 'subRows'; - this.customizeTableRowCallback_ = undefined; - }, - - ready: function() { - this.$.body.addEventListener( - 'keydown', this.onKeyDown_.bind(this), true); - }, - - clear: function() { - this.selectionMode_ = SelectionMode.NONE; - this.rowHighlightStyle_ = HighlightStyle.DEFAULT; - this.cellHighlightStyle_ = HighlightStyle.DEFAULT; - this.selectedTableRowInfo_ = undefined; - this.selectedColumnIndex_ = undefined; - - this.textContent = ''; - this.tableColumns_ = []; - this.tableRows_ = []; - this.tableRowsInfo_ = new WeakMap(); - this.tableFooterRows_ = []; - this.tableFooterRowsInfo_ = new WeakMap(); - this.sortColumnIndex_ = undefined; - this.sortDescending_ = false; - this.columnsWithExpandButtons_ = []; - this.headerCells_ = []; - this.subRowsPropertyName_ = 'subRows'; - this.defaultExpansionStateCallback_ = undefined; - }, - - get showHeader() { - return this.showHeader_; - }, - - set showHeader(showHeader) { - this.showHeader_ = showHeader; - this.scheduleRebuildHeaders_(); - }, - - set subRowsPropertyName(name) { - this.subRowsPropertyName_ = name; - }, - - /** - * This callback will be called whenever a body row is built - * for a userRow that has subRows and does not have an explicit - * isExpanded field. - * The callback should return true if the row should be expanded, - * or false if the row should be collapsed. - * @param {function(userRow, parentUserRow): boolean} cb The callback. - */ - set defaultExpansionStateCallback(cb) { - this.defaultExpansionStateCallback_ = cb; - this.scheduleRebuildBody_(); - }, - - /** - * This callback will be called whenever a body row is built. - * The callback's return value is ignored. - * @param {function(userRow, trElement)} cb The callback. - */ - set customizeTableRowCallback(cb) { - this.customizeTableRowCallback_ = cb; - this.scheduleRebuildBody_(); - }, - - get emptyValue() { - return this.emptyValue_; - }, - - set emptyValue(emptyValue) { - var previousEmptyValue = this.emptyValue_; - this.emptyValue_ = emptyValue; - if (this.tableRows_.length === 0 && emptyValue !== previousEmptyValue) - this.scheduleRebuildBody_(); - }, - - /** - * Data objects should have the following fields: - * mandatory: title, value - * optional: width {string}, cmp {function}, colSpan {number}, - * showExpandButtons {boolean}, - * align {tr.ui.b.TableFormat.ColumnAlignment} - * - * @param {Array} columns An array of data objects. - */ - set tableColumns(columns) { - // Figure out the columns with expand buttons... - var columnsWithExpandButtons = []; - for (var i = 0; i < columns.length; i++) { - if (columns[i].showExpandButtons) - columnsWithExpandButtons.push(i); - } - if (columnsWithExpandButtons.length === 0) { - // First column if none have specified. - columnsWithExpandButtons = [0]; - } - - // Sanity check columns. - for (var i = 0; i < columns.length; i++) { - var colInfo = columns[i]; - if (colInfo.width === undefined) - continue; - - var hasExpandButton = columnsWithExpandButtons.indexOf(i) !== -1; - - var w = colInfo.width; - if (w) { - if (/\d+px/.test(w)) { - continue; - } else if (/\d+%/.test(w)) { - if (hasExpandButton) { - throw new Error('Columns cannot be %-sized and host ' + - ' an expand button'); - } - } else { - throw new Error('Unrecognized width string'); - } - } - } - - // Commit the change. - this.tableColumns_ = columns; - this.headerCells_ = []; - this.columnsWithExpandButtons_ = columnsWithExpandButtons; - this.sortColumnIndex = undefined; - this.scheduleRebuildHeaders_(); - - // Blow away the table rows, too. - this.tableRows = this.tableRows_; - }, - - get tableColumns() { - return this.tableColumns_; - }, - - /** - * @param {Array} rows An array of 'row' objects with the following - * fields: - * optional: subRows An array of objects that have the same 'row' - * structure. Set subRowsPropertyName to use an - * alternative field name. - */ - set tableRows(rows) { - this.selectedTableRowInfo_ = undefined; - this.selectedColumnIndex_ = undefined; - this.maybeUpdateSelectedRow_(); - this.tableRows_ = rows; - this.tableRowsInfo_ = new WeakMap(); - this.scheduleRebuildBody_(); - }, - - get tableRows() { - return this.tableRows_; - }, - - set footerRows(rows) { - this.tableFooterRows_ = rows; - this.tableFooterRowsInfo_ = new WeakMap(); - this.scheduleRebuildFooter_(); - }, - - get footerRows() { - return this.tableFooterRows_; - }, - - set sortColumnIndex(number) { - if (number === this.sortColumnIndex_) - return; - - if (number === undefined) { - this.sortColumnIndex_ = undefined; - this.updateHeaderArrows_(); - this.dispatchSortingChangedEvent_(); - return; - } - - if (this.tableColumns_.length <= number) - throw new Error('Column number ' + number + ' is out of bounds.'); - if (!this.tableColumns_[number].cmp) - throw new Error('Column ' + number + ' does not have a comparator.'); - - this.sortColumnIndex_ = number; - this.updateHeaderArrows_(); - this.scheduleRebuildBody_(); - this.dispatchSortingChangedEvent_(); - }, - - get sortColumnIndex() { - return this.sortColumnIndex_; - }, - - set sortDescending(value) { - var newValue = !!value; - - if (newValue !== this.sortDescending_) { - this.sortDescending_ = newValue; - this.updateHeaderArrows_(); - this.scheduleRebuildBody_(); - this.dispatchSortingChangedEvent_(); - } - }, - - get sortDescending() { - return this.sortDescending_; - }, - - updateHeaderArrows_: function() { - for (var i = 0; i < this.headerCells_.length; i++) { - if (!this.tableColumns_[i].cmp) { - this.headerCells_[i].sideContent = ''; - continue; - } - if (i !== this.sortColumnIndex_) { - this.headerCells_[i].sideContent = UNSORTED_ARROW; - continue; - } - this.headerCells_[i].sideContent = this.sortDescending_ ? - DESCENDING_ARROW : ASCENDING_ARROW; - } - }, - - sortRows_: function(rows) { - rows.sort(function(rowA, rowB) { - if (this.sortDescending_) - return this.tableColumns_[this.sortColumnIndex_].cmp( - rowB.userRow, rowA.userRow); - return this.tableColumns_[this.sortColumnIndex_].cmp( - rowA.userRow, rowB.userRow); - }.bind(this)); - // Sort expanded sub rows recursively. - for (var i = 0; i < rows.length; i++) { - if (this.getExpandedForUserRow_(rows[i])) - this.sortRows_(rows[i][this.subRowsPropertyName_]); - } - }, - - generateHeaderColumns_: function() { - this.headerCells_ = []; - this.$.head.textContent = ''; - if (!this.showHeader_) - return; - - var tr = this.appendNewElement_(this.$.head, 'tr'); - for (var i = 0; i < this.tableColumns_.length; i++) { - var td = this.appendNewElement_(tr, 'td'); - - var headerCell = document.createElement('tr-ui-b-table-header-cell'); - headerCell.cellTitle = this.tableColumns_[i].title; - headerCell.align = this.tableColumns_[i].align; - - // If the table can be sorted by this column, attach a tap callback - // to the column. - if (this.tableColumns_[i].cmp) { - td.classList.add('sensitive'); - headerCell.tapCallback = this.createSortCallback_(i); - // Set arrow position, depending on the sortColumnIndex. - if (this.sortColumnIndex_ === i) - headerCell.sideContent = this.sortDescending_ ? - DESCENDING_ARROW : ASCENDING_ARROW; - else - headerCell.sideContent = UNSORTED_ARROW; - } - - td.appendChild(headerCell); - this.headerCells_.push(headerCell); - } - }, - - applySizes_: function() { - if (this.tableRows_.length === 0 && !this.showHeader) - return; - var rowToRemoveSizing; - var rowToSize; - if (this.showHeader) { - rowToSize = this.$.head.children[0]; - rowToRemoveSizing = this.$.body.children[0]; - } else { - rowToSize = this.$.body.children[0]; - rowToRemoveSizing = this.$.head.children[0]; - } - for (var i = 0; i < this.tableColumns_.length; i++) { - if (rowToRemoveSizing && rowToRemoveSizing.children[i]) { - var tdToRemoveSizing = rowToRemoveSizing.children[i]; - tdToRemoveSizing.style.minWidth = ''; - tdToRemoveSizing.style.width = ''; - } - - // Apply sizing. - var td = rowToSize.children[i]; - - var delta; - if (this.columnsWithExpandButtons_.indexOf(i) !== -1) { - td.style.paddingLeft = BASIC_INDENTATION + 'px'; - delta = BASIC_INDENTATION + 'px'; - } else { - delta = undefined; - } - - function calc(base, delta) { - if (delta) - return 'calc(' + base + ' - ' + delta + ')'; - else - return base; - } - - var w = this.tableColumns_[i].width; - if (w) { - if (/\d+px/.test(w)) { - td.style.minWidth = calc(w, delta); - } else if (/\d+%/.test(w)) { - td.style.width = w; - } else { - throw new Error('Unrecognized width string: ' + w); - } - } - } - }, - - createSortCallback_: function(columnNumber) { - return function() { - var previousIndex = this.sortColumnIndex; - this.sortColumnIndex = columnNumber; - if (previousIndex !== columnNumber) - this.sortDescending = false; - else - this.sortDescending = !this.sortDescending; - }.bind(this); - }, - - generateTableRowNodes_: function(tableSection, userRows, rowInfoMap, - indentation, lastAddedRow, - parentRowInfo) { - if (this.sortColumnIndex_ !== undefined && - tableSection === this.$.body) { - userRows = userRows.slice(); // Don't mess with the input data. - userRows.sort(function(rowA, rowB) { - var c = this.tableColumns_[this.sortColumnIndex_].cmp( - rowA, rowB); - if (this.sortDescending_) - c = -c; - return c; - }.bind(this)); - } - - for (var i = 0; i < userRows.length; i++) { - var userRow = userRows[i]; - var rowInfo = this.getOrCreateRowInfoFor_(rowInfoMap, userRow, - parentRowInfo); - var htmlNode = this.getHTMLNodeForRowInfo_( - tableSection, rowInfo, rowInfoMap, indentation); - - if (lastAddedRow === undefined) { - // Put first into the table. - tableSection.insertBefore(htmlNode, tableSection.firstChild); - } else { - // This is shorthand for insertAfter(htmlNode, lastAdded). - var nextSiblingOfLastAdded = lastAddedRow.nextSibling; - tableSection.insertBefore(htmlNode, nextSiblingOfLastAdded); - } - this.updateTabIndexForTableRowNode_(htmlNode); - - lastAddedRow = htmlNode; - if (!rowInfo.isExpanded) - continue; - - // Append subrows now. - lastAddedRow = this.generateTableRowNodes_( - tableSection, userRow[this.subRowsPropertyName_], rowInfoMap, - indentation + 1, lastAddedRow, rowInfo); - } - return lastAddedRow; - }, - - getOrCreateRowInfoFor_: function(rowInfoMap, userRow, parentRowInfo) { - var rowInfo = undefined; - - if (rowInfoMap.has(userRow)) { - rowInfo = rowInfoMap.get(userRow); - } else { - rowInfo = { - userRow: userRow, - htmlNode: undefined, - parentRowInfo: parentRowInfo - }; - rowInfoMap.set(userRow, rowInfo); - } - - // Recompute isExpanded in case defaultExpansionStateCallback_ has - // changed. - rowInfo.isExpanded = this.getExpandedForUserRow_(userRow); - - return rowInfo; - }, - - customizeTableRow_: function(userRow, trElement) { - if (!this.customizeTableRowCallback_) - return; - this.customizeTableRowCallback_(userRow, trElement); - }, - - getHTMLNodeForRowInfo_: function(tableSection, rowInfo, - rowInfoMap, indentation) { - if (rowInfo.htmlNode) { - this.customizeTableRow_(rowInfo.userRow, rowInfo.htmlNode); - return rowInfo.htmlNode; - } - - var INDENT_SPACE = indentation * 16; - var INDENT_SPACE_NO_BUTTON = indentation * 16 + BASIC_INDENTATION; - var trElement = this.ownerDocument.createElement('tr'); - rowInfo.htmlNode = trElement; - rowInfo.indentation = indentation; - trElement.rowInfo = rowInfo; - this.customizeTableRow_(rowInfo.userRow, trElement); - - for (var i = 0; i < this.tableColumns_.length;) { - var td = this.appendNewElement_(trElement, 'td'); - td.columnIndex = i; - - var column = this.tableColumns_[i]; - var value = column.value(rowInfo.userRow); - var colSpan = column.colSpan ? column.colSpan : 1; - td.style.colSpan = colSpan; - - switch (column.align) { - case undefined: - case ColumnAlignment.LEFT: - break; - - case ColumnAlignment.RIGHT: - td.style.textAlign = 'right'; - break; - - default: - throw new Error('Invalid alignment of column at index=' + i + - ': ' + column.align); - } - - if (this.doesColumnIndexSupportSelection(i)) - td.classList.add('supports-selection'); - - if (this.columnsWithExpandButtons_.indexOf(i) != -1) { - if (rowInfo.userRow[this.subRowsPropertyName_] && - rowInfo.userRow[this.subRowsPropertyName_].length > 0) { - td.style.paddingLeft = INDENT_SPACE + 'px'; - var expandButton = this.appendNewElement_(td, - 'expand-button'); - expandButton.textContent = RIGHT_ARROW; - if (rowInfo.isExpanded) - expandButton.classList.add('button-expanded'); - } else { - td.style.paddingLeft = INDENT_SPACE_NO_BUTTON + 'px'; - } - } - - if (value !== undefined) - td.appendChild(tr.ui.b.asHTMLOrTextNode(value, this.ownerDocument)); - - i += colSpan; - } - - var isSelectable = tableSection === this.$.body; - var isExpandable = rowInfo.userRow[this.subRowsPropertyName_] && - rowInfo.userRow[this.subRowsPropertyName_].length; - - if (isSelectable || isExpandable) { - trElement.addEventListener('click', function(e) { - e.stopPropagation(); - if (e.target.tagName == 'EXPAND-BUTTON') { - this.setExpandedForUserRow_( - tableSection, rowInfoMap, - rowInfo.userRow, !rowInfo.isExpanded); - return; - } - - function getTD(cur) { - if (cur === trElement) - throw new Error('woah'); - if (cur.parentElement === trElement) - return cur; - return getTD(cur.parentElement); - } - - // If the row/cell can be selected and it's not selected yet, - // select it. - if (isSelectable && this.selectionMode_ !== SelectionMode.NONE) { - var shouldSelect = false; - var columnIndex = getTD(e.target).columnIndex; - switch (this.selectionMode_) { - case SelectionMode.ROW: - shouldSelect = this.selectedTableRowInfo_ !== rowInfo; - break; - - case SelectionMode.CELL: - if (this.doesColumnIndexSupportSelection(columnIndex)) { - shouldSelect = this.selectedTableRowInfo_ !== rowInfo || - this.selectedColumnIndex_ !== columnIndex; - } - break; - - default: - throw new Error('Invalid selection mode ' + - this.selectionMode_); - } - if (shouldSelect) { - this.didTableRowInfoGetClicked_(rowInfo, columnIndex); - return; - } - } - - // Otherwise, if the row is expandable, expand/collapse it. - if (isExpandable) { - this.setExpandedForUserRow_(tableSection, rowInfoMap, - rowInfo.userRow, !rowInfo.isExpanded); - } - }.bind(this)); - } - - return rowInfo.htmlNode; - }, - - removeSubNodes_: function(tableSection, rowInfo, rowInfoMap) { - if (rowInfo.userRow[this.subRowsPropertyName_] === undefined) - return; - for (var i = 0; - i < rowInfo.userRow[this.subRowsPropertyName_].length; i++) { - var subRow = rowInfo.userRow[this.subRowsPropertyName_][i]; - var subRowInfo = rowInfoMap.get(subRow); - if (!subRowInfo) - continue; - - var subNode = subRowInfo.htmlNode; - if (subNode && subNode.parentNode === tableSection) { - tableSection.removeChild(subNode); - this.removeSubNodes_(tableSection, subRowInfo, rowInfoMap); - } - } - }, - - scheduleRebuildHeaders_: function() { - this.headerDirty_ = true; - this.scheduleRebuild_(); - }, - - scheduleRebuildBody_: function() { - this.bodyDirty_ = true; - this.scheduleRebuild_(); - }, - - scheduleRebuildFooter_: function() { - this.footerDirty_ = true; - this.scheduleRebuild_(); - }, - - scheduleRebuild_: function() { - if (this.rebuildPending_) - return; - this.rebuildPending_ = true; - setTimeout(function() { - this.rebuildPending_ = false; - this.rebuild(); - }.bind(this), 0); - }, - - rebuildIfNeeded_: function() { - this.rebuild(); - }, - - rebuild: function() { - var wasBodyOrHeaderDirty = this.headerDirty_ || this.bodyDirty_; - - if (this.headerDirty_) { - this.generateHeaderColumns_(); - this.headerDirty_ = false; - } - if (this.bodyDirty_) { - this.$.body.textContent = ''; - this.generateTableRowNodes_( - this.$.body, - this.tableRows_, this.tableRowsInfo_, 0, - undefined, undefined); - if (this.tableRows_.length === 0 && this.emptyValue_ !== undefined) { - var trElement = this.ownerDocument.createElement('tr'); - this.$.body.appendChild(trElement); - trElement.classList.add('empty-row'); - var td = this.ownerDocument.createElement('td'); - trElement.appendChild(td); - td.colSpan = this.tableColumns_.length; - var emptyValue = this.emptyValue_; - td.appendChild( - tr.ui.b.asHTMLOrTextNode(emptyValue, this.ownerDocument)); - } - this.bodyDirty_ = false; - } - - if (wasBodyOrHeaderDirty) - this.applySizes_(); - - if (this.footerDirty_) { - this.$.foot.textContent = ''; - this.generateTableRowNodes_( - this.$.foot, - this.tableFooterRows_, this.tableFooterRowsInfo_, 0, - undefined, undefined); - if (this.tableFooterRowsInfo_.length) { - this.$.body.classList.add('has-footer'); - } else { - this.$.body.classList.remove('has-footer'); - } - this.footerDirty_ = false; - } - }, - - appendNewElement_: function(parent, tagName) { - var element = parent.ownerDocument.createElement(tagName); - parent.appendChild(element); - return element; - }, - - getExpandedForTableRow: function(userRow) { - this.rebuildIfNeeded_(); - var rowInfo = this.tableRowsInfo_.get(userRow); - if (rowInfo === undefined) - throw new Error('Row has not been seen, must expand its parents'); - return rowInfo.isExpanded; - }, - - getExpandedForUserRow_: function(userRow) { - if (userRow[this.subRowsPropertyName_] === undefined) - return false; - if (userRow[this.subRowsPropertyName_].length === 0) - return false; - if (userRow.isExpanded) - return true; - if (userRow.isExpanded === false) - return false; - - var rowInfo = this.tableRowsInfo_.get(userRow); - if (rowInfo && rowInfo.isExpanded) - return true; - - if (this.defaultExpansionStateCallback_ === undefined) - return false; - - var parentUserRow = undefined; - if (rowInfo && rowInfo.parentRowInfo) - parentUserRow = rowInfo.parentRowInfo.userRow; - - return this.defaultExpansionStateCallback_( - userRow, parentUserRow); - }, - - setExpandedForTableRow: function(userRow, expanded) { - this.rebuildIfNeeded_(); - var rowInfo = this.tableRowsInfo_.get(userRow); - if (rowInfo === undefined) - throw new Error('Row has not been seen, must expand its parents'); - return this.setExpandedForUserRow_(this.$.body, this.tableRowsInfo_, - userRow, expanded); - }, - - setExpandedForUserRow_: function(tableSection, rowInfoMap, - userRow, expanded) { - this.rebuildIfNeeded_(); - - var rowInfo = rowInfoMap.get(userRow); - if (rowInfo === undefined) - throw new Error('Row has not been seen, must expand its parents'); - - rowInfo.isExpanded = !!expanded; - // If no node, then nothing further needs doing. - if (rowInfo.htmlNode === undefined) - return; - - // If its detached, then nothing needs doing. - if (rowInfo.htmlNode.parentElement !== tableSection) - return; - - // Otherwise, rebuild. - var expandButton = rowInfo.htmlNode.querySelector('expand-button'); - if (rowInfo.isExpanded) { - expandButton.classList.add('button-expanded'); - var lastAddedRow = rowInfo.htmlNode; - if (rowInfo.userRow[this.subRowsPropertyName_]) { - this.generateTableRowNodes_( - tableSection, - rowInfo.userRow[this.subRowsPropertyName_], rowInfoMap, - rowInfo.indentation + 1, - lastAddedRow, rowInfo); - } - } else { - expandButton.classList.remove('button-expanded'); - this.removeSubNodes_(tableSection, rowInfo, rowInfoMap); - } - - this.maybeUpdateSelectedRow_(); - }, - - get selectionMode() { - return this.selectionMode_; - }, - - set selectionMode(selectionMode) { - if (!tr.b.dictionaryContainsValue(SelectionMode, selectionMode)) - throw new Error('Invalid selection mode ' + selectionMode); - this.rebuildIfNeeded_(); - this.selectionMode_ = selectionMode; - this.didSelectionStateChange_(); - }, - - get rowHighlightStyle() { - return this.rowHighlightStyle_; - }, - - set rowHighlightStyle(rowHighlightStyle) { - if (!tr.b.dictionaryContainsValue(HighlightStyle, rowHighlightStyle)) - throw new Error('Invalid row highlight style ' + rowHighlightStyle); - this.rebuildIfNeeded_(); - this.rowHighlightStyle_ = rowHighlightStyle; - this.didSelectionStateChange_(); - }, - - get resolvedRowHighlightStyle() { - if (this.rowHighlightStyle_ !== HighlightStyle.DEFAULT) - return this.rowHighlightStyle_; - switch (this.selectionMode_) { - case SelectionMode.NONE: - return HighlightStyle.NONE; - case SelectionMode.ROW: - return HighlightStyle.DARK; - case SelectionMode.CELL: - return HighlightStyle.LIGHT; - default: - throw new Error('Invalid selection mode ' + selectionMode); - } - }, - - get cellHighlightStyle() { - return this.cellHighlightStyle_; - }, - - set cellHighlightStyle(cellHighlightStyle) { - if (!tr.b.dictionaryContainsValue(HighlightStyle, cellHighlightStyle)) - throw new Error('Invalid cell highlight style ' + cellHighlightStyle); - this.rebuildIfNeeded_(); - this.cellHighlightStyle_ = cellHighlightStyle; - this.didSelectionStateChange_(); - }, - - get resolvedCellHighlightStyle() { - if (this.cellHighlightStyle_ !== HighlightStyle.DEFAULT) - return this.cellHighlightStyle_; - switch (this.selectionMode_) { - case SelectionMode.NONE: - case SelectionMode.ROW: - return HighlightStyle.NONE; - case SelectionMode.CELL: - return HighlightStyle.DARK; - default: - throw new Error('Invalid selection mode ' + selectionMode); - } - }, - - setHighlightStyle_: function(highlightAttribute, resolvedHighlightStyle) { - switch (resolvedHighlightStyle) { - case HighlightStyle.NONE: - this.$.body.removeAttribute(highlightAttribute); - break; - case HighlightStyle.LIGHT: - this.$.body.setAttribute(highlightAttribute, 'light'); - break; - case HighlightStyle.DARK: - this.$.body.setAttribute(highlightAttribute, 'dark'); - break; - default: - throw new Error('Invalid resolved highlight style ' + - resolvedHighlightStyle); - } - }, - - didSelectionStateChange_: function() { - this.setHighlightStyle_('row-highlight-style', - this.resolvedRowHighlightStyle); - this.setHighlightStyle_('cell-highlight-style', - this.resolvedCellHighlightStyle); - - for (var i = 0; i < this.$.body.children.length; i++) - this.updateTabIndexForTableRowNode_(this.$.body.children[i]); - this.maybeUpdateSelectedRow_(); - }, - - maybeUpdateSelectedRow_: function() { - if (this.selectedTableRowInfo_ === undefined) - return; - - // Selection may be off. - if (this.selectionMode_ === SelectionMode.NONE) { - this.removeSelectedState_(); - this.selectedTableRowInfo_ = undefined; - return; - } - - // selectedUserRow may not be visible - function isVisible(rowInfo) { - if (!rowInfo.htmlNode) - return false; - return !!rowInfo.htmlNode.parentElement; - } - if (isVisible(this.selectedTableRowInfo_)) { - this.updateSelectedState_(); - return; - } - - this.removeSelectedState_(); - var curRowInfo = this.selectedTableRowInfo_; - while (curRowInfo && !isVisible(curRowInfo)) - curRowInfo = curRowInfo.parentRowInfo; - - this.selectedTableRowInfo_ = curRowInfo; - if (this.selectedTableRowInfo_) - this.updateSelectedState_(); - }, - - didTableRowInfoGetClicked_: function(rowInfo, columnIndex) { - switch (this.selectionMode_) { - case SelectionMode.NONE: - return; - - case SelectionMode.CELL: - if (!this.doesColumnIndexSupportSelection(columnIndex)) - return; - if (this.selectedColumnIndex !== columnIndex) - this.selectedColumnIndex = columnIndex; - // Fall through. - - case SelectionMode.ROW: - if (this.selectedTableRowInfo_ !== rowInfo) - this.selectedTableRow = rowInfo.userRow; - } - }, - - get selectedTableRow() { - if (!this.selectedTableRowInfo_) - return undefined; - return this.selectedTableRowInfo_.userRow; - }, - - set selectedTableRow(userRow) { - this.rebuildIfNeeded_(); - if (this.selectionMode_ === SelectionMode.NONE) - throw new Error('Selection is off.'); - - var rowInfo; - if (userRow === undefined) { - rowInfo = undefined; - } else { - rowInfo = this.tableRowsInfo_.get(userRow); - if (!rowInfo) - throw new Error('Row has not been seen, must expand its parents.'); - } - - var e = this.prepareToChangeSelection_(); - this.selectedTableRowInfo_ = rowInfo; - - if (this.selectedTableRowInfo_ === undefined) { - this.selectedColumnIndex_ = undefined; - this.removeSelectedState_(); - } else { - switch (this.selectionMode_) { - case SelectionMode.ROW: - this.selectedColumnIndex_ = undefined; - break; - - case SelectionMode.CELL: - if (this.selectedColumnIndex_ === undefined) { - var i = this.getFirstSelectableColumnIndex_(); - if (i == -1) - throw new Error('Cannot find a selectable column.'); - this.selectedColumnIndex_ = i; - } - break; - - default: - throw new Error('Invalid selection mode ' + this.selectionMode_); - } - this.updateSelectedState_(); - } - - this.dispatchEvent(e); - }, - - updateTabIndexForTableRowNode_: function(row) { - if (this.selectionMode_ === SelectionMode.ROW) - row.tabIndex = 0; - else - row.removeAttribute('tabIndex'); - - var enableCellTab = this.selectionMode_ === SelectionMode.CELL; - for (var i = 0; i < this.tableColumns_.length; i++) { - var cell = row.children[i]; - if (enableCellTab && this.doesColumnIndexSupportSelection(i)) - cell.tabIndex = 0; - else - cell.removeAttribute('tabIndex'); - } - }, - - prepareToChangeSelection_: function() { - var e = new tr.b.Event('selection-changed'); - var previousSelectedRowInfo = this.selectedTableRowInfo_; - if (previousSelectedRowInfo) - e.previousSelectedTableRow = previousSelectedRowInfo.userRow; - else - e.previousSelectedTableRow = undefined; - - this.removeSelectedState_(); - - return e; - }, - - removeSelectedState_: function() { - this.setSelectedState_(false); - }, - - updateSelectedState_: function() { - this.setSelectedState_(true); - }, - - setSelectedState_: function(select) { - if (this.selectedTableRowInfo_ === undefined) - return; - - // Row selection. - var rowNode = this.selectedTableRowInfo_.htmlNode; - if (select) - rowNode.setAttribute('selected', true); - else - rowNode.removeAttribute('selected'); - - // Cell selection (if applicable). - var cellNode = rowNode.children[this.selectedColumnIndex_]; - if (!cellNode) - return; - if (select) - cellNode.setAttribute('selected', true); - else - cellNode.removeAttribute('selected'); - }, - - doesColumnIndexSupportSelection: function(columnIndex) { - var columnInfo = this.tableColumns_[columnIndex]; - var scs = columnInfo.supportsCellSelection; - if (scs === false) - return false; - return true; - }, - - getFirstSelectableColumnIndex_: function() { - for (var i = 0; i < this.tableColumns_.length; i++) { - if (this.doesColumnIndexSupportSelection(i)) - return i; - } - return -1; - }, - - getSelectableNodeGivenTableRowNode_: function(htmlNode) { - switch (this.selectionMode_) { - case SelectionMode.ROW: - return htmlNode; - - case SelectionMode.CELL: - return htmlNode.children[this.selectedColumnIndex_]; - - default: - throw new Error('Invalid selection mode ' + this.selectionMode_); - } - }, - - get selectedColumnIndex() { - if (this.selectionMode_ !== SelectionMode.CELL) - return undefined; - return this.selectedColumnIndex_; - }, - - set selectedColumnIndex(selectedColumnIndex) { - this.rebuildIfNeeded_(); - if (this.selectionMode_ === SelectionMode.NONE) - throw new Error('Selection is off.'); - if (selectedColumnIndex < 0 || - selectedColumnIndex >= this.tableColumns_.length) - throw new Error('Invalid index'); - if (!this.doesColumnIndexSupportSelection(selectedColumnIndex)) - throw new Error('Selection is not supported on this column'); - - var e = this.prepareToChangeSelection_(); - this.selectedColumnIndex_ = selectedColumnIndex; - if (this.selectedColumnIndex_ === undefined) - this.selectedTableRowInfo_ = undefined; - this.updateSelectedState_(); - - this.dispatchEvent(e); - }, - - onKeyDown_: function(e) { - if (this.selectionMode_ === SelectionMode.NONE) - return; - if (this.selectedTableRowInfo_ === undefined) - return; - - var code_to_command_names = { - 13: 'ENTER', - 37: 'ARROW_LEFT', - 38: 'ARROW_UP', - 39: 'ARROW_RIGHT', - 40: 'ARROW_DOWN' - }; - var cmdName = code_to_command_names[e.keyCode]; - if (cmdName === undefined) - return; - - e.stopPropagation(); - e.preventDefault(); - this.performKeyCommand_(cmdName); - }, - - performKeyCommand_: function(cmdName) { - this.rebuildIfNeeded_(); - - var rowInfo = this.selectedTableRowInfo_; - var htmlNode = rowInfo.htmlNode; - if (cmdName === 'ARROW_UP') { - var prev = htmlNode.previousElementSibling; - if (prev) { - tr.ui.b.scrollIntoViewIfNeeded(prev); - this.selectedTableRow = prev.rowInfo.userRow; - this.focusSelected_(); - return; - } - return; - } - - if (cmdName === 'ARROW_DOWN') { - var next = htmlNode.nextElementSibling; - if (next) { - tr.ui.b.scrollIntoViewIfNeeded(next); - this.selectedTableRow = next.rowInfo.userRow; - this.focusSelected_(); - return; - } - return; - } - - if (cmdName === 'ARROW_RIGHT') { - switch (this.selectionMode_) { - case SelectionMode.ROW: - if (rowInfo.userRow[this.subRowsPropertyName_] === undefined) - return; - if (rowInfo.userRow[this.subRowsPropertyName_].length === 0) - return; - - if (!rowInfo.isExpanded) - this.setExpandedForTableRow(rowInfo.userRow, true); - this.selectedTableRow = - htmlNode.nextElementSibling.rowInfo.userRow; - this.focusSelected_(); - return; - - case SelectionMode.CELL: - var newIndex = this.selectedColumnIndex_ + 1; - if (newIndex >= this.tableColumns_.length) - return; - if (!this.doesColumnIndexSupportSelection(newIndex)) - return; - this.selectedColumnIndex = newIndex; - this.focusSelected_(); - return; - - default: - throw new Error('Invalid selection mode ' + this.selectionMode_); - } - } - - if (cmdName === 'ARROW_LEFT') { - switch (this.selectionMode_) { - case SelectionMode.ROW: - if (rowInfo.isExpanded) { - this.setExpandedForTableRow(rowInfo.userRow, false); - this.focusSelected_(); - return; - } - - // Not expanded. Select parent... - var parentRowInfo = rowInfo.parentRowInfo; - if (parentRowInfo) { - this.selectedTableRow = parentRowInfo.userRow; - this.focusSelected_(); - return; - } - return; - - case SelectionMode.CELL: - var newIndex = this.selectedColumnIndex_ - 1; - if (newIndex < 0) - return; - if (!this.doesColumnIndexSupportSelection(newIndex)) - return; - this.selectedColumnIndex = newIndex; - this.focusSelected_(); - return; - - default: - throw new Error('Invalid selection mode ' + this.selectionMode_); - } - } - - if (cmdName === 'ENTER') { - if (rowInfo.userRow[this.subRowsPropertyName_] === undefined) - return; - if (rowInfo.userRow[this.subRowsPropertyName_].length === 0) - return; - this.setExpandedForTableRow(rowInfo.userRow, !rowInfo.isExpanded); - this.focusSelected_(); - return; - } - - throw new Error('Unrecognized command ' + cmdName); - }, - - focusSelected_: function() { - if (!this.selectedTableRowInfo_) - return; - var node = this.getSelectableNodeGivenTableRowNode_( - this.selectedTableRowInfo_.htmlNode); - node.focus(); - }, - - dispatchSortingChangedEvent_: function() { - var e = new tr.b.Event('sort-column-changed'); - e.sortColumnIndex = this.sortColumnIndex_; - e.sortDescending = this.sortDescending_; - this.dispatchEvent(e); - } - }); - })(); - </script> -</polymer-element> -<polymer-element name="tr-ui-b-table-header-cell" on-tap="onTap_"> - <template> - <style> - :host { - -webkit-user-select: none; - display: flex; - } - - span { - flex: 0 1 auto; - } - - side-element { - -webkit-user-select: none; - flex: 0 0 auto; - padding-left: 4px; - vertical-align: top; - font-size: 15px; - font-family: sans-serif; - display: inline; - line-height: 85%; - } - </style> - - <span id="title"></span><side-element id="side"></side-element> - </template> - - <script> - 'use strict'; - - var ColumnAlignment = tr.ui.b.TableFormat.ColumnAlignment; - - Polymer({ - created: function() { - this.tapCallback_ = undefined; - this.cellTitle_ = ''; - this.align_ = undefined; - }, - - set cellTitle(value) { - this.cellTitle_ = value; - - var titleNode = tr.ui.b.asHTMLOrTextNode( - this.cellTitle_, this.ownerDocument); - - this.$.title.innerText = ''; - this.$.title.appendChild(titleNode); - }, - - get cellTitle() { - return this.cellTitle_; - }, - - set align(align) { - switch (align) { - case undefined: - case ColumnAlignment.LEFT: - this.style.justifyContent = ''; - break; - - case ColumnAlignment.RIGHT: - this.style.justifyContent = 'flex-end'; - break; - - default: - throw new Error('Invalid alignment of column (title=\'' + - this.cellTitle_ + '\'): ' + align); - } - this.align_ = align; - }, - - get align() { - return this.align_; - }, - - clearSideContent: function() { - this.$.side.textContent = ''; - }, - - set sideContent(content) { - this.$.side.textContent = content; - }, - - get sideContent() { - return this.$.side.textContent; - }, - - set tapCallback(callback) { - this.style.cursor = 'pointer'; - this.tapCallback_ = callback; - }, - - get tapCallback() { - return this.tapCallback_; - }, - - onTap_: function() { - if (this.tapCallback_) - this.tapCallback_(); - } - }); -</script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/table_header_cell.html b/chromium/third_party/catapult/tracing/tracing/ui/base/table_header_cell.html deleted file mode 100644 index f6ba5eb35dd..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/table_header_cell.html +++ /dev/null @@ -1,89 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/utils.html"> -<link rel="import" href="/tracing/ui/base/dom_helpers.html"> - -<polymer-element name="tr-ui-b-table-header-cell" - on-tap="onTap_"> - <template> - <style> - :host { - -webkit-user-select: none; - display: flex; - } - - span { - flex: 0 1 auto; - } - - side-element { - -webkit-user-select: none; - flex: 1 0 auto; - padding-left: 4px; - vertical-align: top; - font-size: 15px; - font-family: sans-serif; - display: inline; - line-height: 85%; - } - </style> - - <span id="title"></span><side-element id="side"></side-element> - </template> - - <script> - 'use strict'; - - Polymer({ - created: function() { - this.tapCallback_ = undefined; - this.cellTitle_ = ''; - }, - - set cellTitle(value) { - this.cellTitle_ = value; - - var titleNode = - tr.ui.b.asHTMLOrTextNode(this.cellTitle_, this.ownerDocument); - - this.$.title.innerText = ''; - this.$.title.appendChild(titleNode); - }, - - get cellTitle() { - return this.cellTitle_; - }, - - clearSideContent: function() { - this.$.side.textContent = ''; - }, - - set sideContent(content) { - this.$.side.textContent = content; - }, - - get sideContent() { - return this.$.side.textContent; - }, - - set tapCallback(callback) { - this.style.cursor = 'pointer'; - this.tapCallback_ = callback; - }, - - get tapCallback() { - return this.tapCallback_; - }, - - onTap_: function() { - if (this.tapCallback_) - this.tapCallback_(); - } - }); -</script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/table_test.html b/chromium/third_party/catapult/tracing/tracing/ui/base/table_test.html deleted file mode 100644 index 0c3504fc318..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/table_test.html +++ /dev/null @@ -1,1461 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/base/deep_utils.html"> -<link rel="import" href="/tracing/ui/base/table.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var THIS_DOC = document._currentScript.ownerDocument; - var SelectionMode = tr.ui.b.TableFormat.SelectionMode; - var HighlightStyle = tr.ui.b.TableFormat.HighlightStyle; - var ColumnAlignment = tr.ui.b.TableFormat.ColumnAlignment; - - function isSelected(element) { - if (!element.hasAttribute('selected')) - return false; - return element.getAttribute('selected') === 'true'; - } - - test('instantiateEmptyTable_withoutEmptyValue', function() { - var columns = [ - { - title: 'First Column', - value: function(row) { return row.firstData; }, - width: '300px' - }, - { - title: 'Second Column', - value: function(row) { return row.secondData; } - } - ]; - - var table = document.createElement('tr-ui-b-table'); - table.tableColumns = columns; - table.tableRows = []; - table.rebuild(); - - this.addHTMLOutput(table); - - // Check that the width of the first column was set correctly (despite no - // body rows). - var firstColumnHeader = table.$.head.children[0].children[0]; - assert.closeTo(firstColumnHeader.offsetWidth, 300, 20); - - // Check that the first column has a non-empty header. - var firstColumnTitle = tr.b.findDeepElementMatchingPredicate( - firstColumnHeader, function(element) { - return element.textContent === 'First Column'; - }); - assert.isDefined(firstColumnTitle); - - // Check that empty value was not appended. - assert.lengthOf(table.$.body.children, 0); - }); - - test('instantiateEmptyTable_withEmptyValue', function() { - var columns = [ - { - title: 'First Column', - value: function(row) { return row.firstData; }, - width: '300px' - }, - { - title: 'Second Column', - value: function(row) { return row.secondData; } - } - ]; - - var table = document.createElement('tr-ui-b-table'); - table.tableColumns = columns; - table.tableRows = []; - table.emptyValue = 'This table is left intentionally empty'; - table.rebuild(); - - this.addHTMLOutput(table); - - // Check that the width of the first column was set correctly (despite no - // body rows). - var firstColumnHeader = table.$.head.children[0].children[0]; - assert.closeTo(firstColumnHeader.offsetWidth, 300, 20); - - // Check that empty value was appended. - assert.lengthOf(table.$.body.children, 1); - }); - - test('instantiateNestedTableNoNests', function() { - var columns = [ - { - title: 'First Column', - value: function(row) { return row.firstData; }, - width: '200px' - }, - { - title: 'Second Column', - value: function(row) { return row.secondData; } - } - ]; - - var rows = [ - { - firstData: 'A1', - secondData: 'A2' - }, - { - firstData: 'B1', - secondData: 'B2' - } - ]; - - var table = document.createElement('tr-ui-b-table'); - table.tableColumns = columns; - table.tableRows = rows; - table.emptyValue = 'THIS SHOULD NOT BE VISIBLE!!!'; - table.rebuild(); - - this.addHTMLOutput(table); - - // Check that empty value was not appended. - assert.lengthOf(table.$.body.children, 2); - }); - - test('sequentialRebuildsBehaveSanely', function() { - var columns = [ - { - title: 'First Column', - value: function(row) { return row.firstData; }, - width: '200px' - }, - { - title: 'Second Column', - value: function(row) { return row.secondData; } - } - ]; - - var rows = [ - { - firstData: 'A1', - secondData: 'A2' - }, - { - firstData: 'B1', - secondData: 'B2' - } - ]; - var footerRows = [ - { - firstData: 'A1', - secondData: 'A2' - }, - { - firstData: 'B1', - secondData: 'B2' - } - ]; - - var table = document.createElement('tr-ui-b-table'); - table.tableColumns = columns; - table.tableRows = rows; - table.footerRows = footerRows; - table.rebuild(); - table.rebuild(); - assert.equal(table.$.body.children.length, 2); - assert.equal(table.$.foot.children.length, 2); - - this.addHTMLOutput(table); - }); - - test('instantiateNestedTableWithNests', function() { - var columns = [ - { - title: 'First Column', - value: function(row) { return row.firstData; }, - width: '250px' - }, - { - title: 'Second Column', - value: function(row) { return row.secondData; }, - width: '50%' - } - ]; - - var rows = [ - { - firstData: 'A1', - secondData: 'A2', - subRows: [ - { - firstData: 'Sub1 A1', - secondData: 'Sub1 A2' - }, - { - firstData: 'Sub2 A1', - secondData: 'Sub2 A2', - subRows: [ - { - firstData: 'SubSub1 A1', - secondData: 'SubSub1 A2' - }, - { - firstData: 'SubSub2 A1', - secondData: 'SubSub2 A2' - } - ] - }, - { - firstData: 'Sub3 A1', - secondData: 'Sub3 A2' - } - ] - }, - { - firstData: 'B1', - secondData: 'B2' - } - ]; - - var table = document.createElement('tr-ui-b-table'); - table.tableColumns = columns; - table.tableRows = rows; - table.rebuild(); - - this.addHTMLOutput(table); - }); - - test('instantiateSortingCallbacksWithNests', function() { - var table = document.createElement('tr-ui-b-table'); - - var columns = [ - { - title: 'First Column', - value: function(row) { return row.firstData; }, - width: '50%' - }, - { - title: 'Second Column', - value: function(row) { return row.secondData; }, - width: '250px', - cmp: function(rowA, rowB) { - return rowA.secondData.toString().localeCompare( - rowB.secondData.toString()); - }, - showExpandButtons: true - } - ]; - - var rows = [ - { - firstData: 'A1', - secondData: 'A2', - subRows: [ - { - firstData: 'Sub1 A1', - secondData: 'Sub1 A2' - }, - { - firstData: 'Sub2 A1', - secondData: 'Sub2 A2', - subRows: [ - { - firstData: 'SubSub1 A1', - secondData: 'SubSub1 A2' - }, - { - firstData: 'SubSub2 A1', - secondData: 'SubSub2 A2' - } - ] - }, - { - firstData: 'Sub3 A1', - secondData: 'Sub3 A2' - } - ] - }, - { - firstData: 'B1', - secondData: 'B2' - } - ]; - - var footerRows = [ - { - firstData: 'F1', - secondData: 'F2', - subRows: [ - { - firstData: 'Sub1F1', - secondData: 'Sub1F2' - }, - { - firstData: 'Sub2F1', - secondData: 'Sub2F2', - subRows: [ - { - firstData: 'SubSub1F1', - secondData: 'SubSub1F2' - }, - { - firstData: 'SubSub2F1', - secondData: 'SubSub2F2' - } - ] - }, - { - firstData: 'Sub3F1', - secondData: 'Sub3F2' - } - ] - }, - { - firstData: 'F\'1', - secondData: 'F\'2' - } - - ]; - - table.tableColumns = columns; - table.tableRows = rows; - table.footerRows = footerRows; - table.rebuild(); - - this.addHTMLOutput(table); - - var button = THIS_DOC.createElement('button'); - button.textContent = 'Sort By Col 0'; - button.addEventListener('click', function() { - table.sortDescending = !table.sortDescending; - table.sortColumnIndex = 0; - }); - table.rebuild(); - - this.addHTMLOutput(button); - }); - - - test('instantiateNestedTableAlreadyExpanded', function() { - var columns = [ - { - title: 'a', - value: function(row) { return row.a; }, - width: '150px' - }, - { - title: 'a', - value: function(row) { return row.b; }, - width: '50%' - } - ]; - - var rows = [ - { - a: 'aToplevel', - b: 'bToplevel', - isExpanded: true, - subRows: [ - { - a: 'a1', - b: 'b1' - } - ] - } - ]; - - var table = document.createElement('tr-ui-b-table'); - table.tableColumns = columns; - table.tableRows = rows; - table.rebuild(); - this.addHTMLOutput(table); - - var a1El = tr.b.findDeepElementMatchingPredicate(table, function(element) { - return element.textContent == 'a1'; - }); - assert.isDefined(a1El); - - var bToplevelEl = tr.b.findDeepElementMatchingPredicate( - table, - function(element) { - return element.textContent == 'bToplevel'; - }); - assert.isDefined(bToplevelEl); - var expandButton = bToplevelEl.parentElement.querySelector('expand-button'); - assert.isTrue(expandButton.classList.contains('button-expanded')); - }); - - - test('subRowsThatAreRetrievedOnDemand', function() { - var columns = [ - { - title: 'a', - value: function(row) { return row.a; }, - width: '150px' - } - ]; - - var rows = [ - { - a: 'row1', - subRows: [ - { - b: 'row1.1', - get subRows() { - throw new Error('Shold not be called'); - } - } - ] - } - ]; - - var table = document.createElement('tr-ui-b-table'); - table.tableColumns = columns; - table.tableRows = rows; - table.rebuild(); - this.addHTMLOutput(table); - }); - - - test('instantiateTableWithHiddenHeader', function() { - var columns = [ - { - title: 'a', - value: function(row) { return row.a; }, - width: '150px' - }, - { - title: 'a', - value: function(row) { return row.b; }, - width: '50%' - } - ]; - - var rows = [ - { - a: 'aToplevel', - b: 'bToplevel' - } - ]; - - var table = document.createElement('tr-ui-b-table'); - table.showHeader = false; - table.tableColumns = columns; - table.tableRows = rows; - table.rebuild(); - this.addHTMLOutput(table); - - var tHead = table.$.head; - assert.equal(table.$.head.children.length, 0); - assert.equal(0, tHead.getBoundingClientRect().height); - - table.showHeader = true; - table.rebuild(); - table.showHeader = false; - table.rebuild(); - assert.equal(table.$.head.children.length, 0); - }); - - - test('sortColumnsNotPossibleOnPercentSizedColumns', function() { - var columns = [ - { - title: 'Title', - value: function(row) { return row.a; }, - width: '150px' - }, - { - title: 'Value', - value: function(row) { return row.b; }, - width: '100%', - showExpandButtons: true - } - ]; - - var table1 = document.createElement('tr-ui-b-table'); - table1.showHeader = true; - - assert.throws(function() { - table1.tableColumns = columns; - }); - }); - - test('twoTablesFirstColumnMatching', function() { - var columns = [ - { - title: 'Title', - value: function(row) { return row.a; }, - width: '150px' - }, - { - title: 'Value', - value: function(row) { return row.b; }, - width: '100%' - } - ]; - - var table1 = document.createElement('tr-ui-b-table'); - table1.showHeader = true; - table1.tableColumns = columns; - table1.tableRows = [ - { - a: 'first', - b: 'row' - } - ]; - table1.rebuild(); - this.addHTMLOutput(table1); - - var table2 = document.createElement('tr-ui-b-table'); - table2.showHeader = false; - table2.tableColumns = columns; - table2.tableRows = [ - { - a: 'second', - b: 'row' - } - ]; - table2.rebuild(); - this.addHTMLOutput(table2); - - var h1FirstCol = table1.$.head.children[0].children[0]; - var h2FirstCol = table2.$.body.children[0].children[0]; - assert.equal(h1FirstCol.getBoundingClientRect().width, - h2FirstCol.getBoundingClientRect().width); - }); - - test('programmaticSorting', function() { - var table = document.createElement('tr-ui-b-table'); - - var columns = [ - { - title: 'Column', - value: function(row) { return row.value; }, - cmp: function(rowA, rowB) { - return rowA.value.toString().localeCompare( - rowB.value.toString()); - } - } - ]; - - var rows = [ - { - value: 'A1', - subRows: [ - { - value: 'A1.1' - }, - { - value: 'A1.2', - subRows: [ - { - value: 'A1.2.1' - }, - { - value: 'A1.2.2' - } - ] - }, - { - value: 'A1.3' - } - ] - }, - { - value: 'A2' - } - ]; - - table.tableColumns = columns; - table.tableRows = rows; - table.rebuild(); - - this.addHTMLOutput(table); - - table.sortDescending = true; - table.sortColumnIndex = 0; - table.rebuild(); - var r0 = table.$.body.children[0]; - assert.equal(r0.rowInfo.userRow, rows[1]); - - var r1 = table.$.body.children[1]; - assert.equal(r1.rowInfo.userRow, rows[0]); - }); - - test('sortDispatchesEvent', function() { - var table = document.createElement('tr-ui-b-table'); - var columns = [ - { - title: 'Column 0', - value: function(row) { return row.value0; }, - cmp: function(rowA, rowB) { return rowA.value0 - rowB.value0; } - }, - { - title: 'Column 1', - value: function(row) { return row.value1; }, - cmp: function(rowA, rowB) { return rowA.value1 - rowB.value1; } - } - ]; - - var sortColumnIndex = undefined; - var sortDescending = undefined; - var numListenerCalls = 0; - table.tableColumns = columns; - table.addEventListener('sort-column-changed', function(e) { - sortColumnIndex = e.sortColumnIndex; - sortDescending = e.sortDescending; - numListenerCalls++; - }); - table.rebuild(); - - table.sortColumnIndex = 0; - assert.equal(sortColumnIndex, 0); - assert.equal(numListenerCalls, 1); - - table.sortDescending = true; - assert.equal(sortColumnIndex, 0); - assert.isTrue(sortDescending); - assert.equal(numListenerCalls, 2); - - table.sortColumnIndex = 1; - table.sortDescending = false; - assert.equal(sortColumnIndex, 1); - assert.isFalse(sortDescending); - assert.equal(numListenerCalls, 4); - - table.sortColumnIndex = undefined; - assert.equal(sortColumnIndex, undefined); - assert.equal(numListenerCalls, 5); - }); - - test('sortingAfterExpand', function() { - var table = document.createElement('tr-ui-b-table'); - - var columns = [ - { - title: 'Column', - value: function(row) { return row.value; }, - cmp: function(rowA, rowB) { - return rowA.value.toString().localeCompare( - rowB.value.toString()); - } - } - ]; - - var rows = [ - { - value: 'A1', - isExpanded: true, - subRows: [ - { - value: 'A1.1' - }, - { - value: 'A1.2', - subRows: [ - { - value: 'A1.2.1' - }, - { - value: 'A1.2.2' - } - ] - }, - { - value: 'A1.3' - } - ] - }, - { - value: 'A2' - } - ]; - - table.tableColumns = columns; - table.tableRows = rows; - table.rebuild(); - - this.addHTMLOutput(table); - - table.sortDescending = true; - table.sortColumnIndex = 0; - table.rebuild(); - var r0 = table.$.body.children[0]; - assert.equal(r0.rowInfo.userRow, rows[1]); - - var r1 = table.$.body.children[1]; - assert.equal(r1.rowInfo.userRow, rows[0]); - - var r2 = table.$.body.children[2]; - assert.equal(r2.rowInfo.userRow, rows[0].subRows[2]); - - assert.isFalse(r0.hasAttribute('tabIndex')); - }); - - function createSimpleOneColumnNestedTable() { - var table = document.createElement('tr-ui-b-table'); - - var columns = [ - { - title: 'Column', - value: function(row) { return row.value; }, - cmp: function(rowA, rowB) { - return rowA.value.toString().localeCompare( - rowB.value.toString()); - } - } - ]; - - var rows = [ - { - value: 'A1', - subRows: [ - { - value: 'A1.1' - }, - { - value: 'A1.2', - subRows: [ - { - value: 'A1.2.1' - }, - { - value: 'A1.2.2' - } - ] - }, - { - value: 'A1.3' - } - ] - }, - { - value: 'A2' - } - ]; - - table.tableColumns = columns; - table.tableRows = rows; - return table; - } - - test('expandAfterRebuild', function() { - var table = createSimpleOneColumnNestedTable(); - table.rebuild(); - var rows = table.tableRows; - - this.addHTMLOutput(table); - - table.rebuild(); - assert.isFalse(table.getExpandedForTableRow(rows[0])); - table.setExpandedForTableRow(rows[0], true); - assert.isTrue(table.getExpandedForTableRow(rows[0])); - - var r1 = table.$.body.children[1]; - assert.equal(r1.rowInfo.userRow, rows[0].subRows[0]); - }); - - test('tableSelection', function() { - var table = createSimpleOneColumnNestedTable(); - var rows = table.tableRows; - - table.selectionMode = SelectionMode.ROW; - table.selectedTableRow = rows[0]; - - table.setExpandedForTableRow(rows[0], true); - table.selectedTableRow = rows[0].subRows[1]; - assert.equal(table.selectedTableRow, rows[0].subRows[1]); - - table.setExpandedForTableRow(rows[0], false); - assert.equal(table.selectedTableRow, rows[0]); - - table.selectionMode = SelectionMode.NONE; - assert.equal(table.selectedTableRow, undefined); - - table.selectionMode = SelectionMode.ROW; - table.setExpandedForTableRow(rows[0].subRows[1], true); - this.addHTMLOutput(table); - - var r0 = table.$.body.children[0]; - assert.isTrue(r0.hasAttribute('tabIndex')); - }); - - - test('keyMovement', function() { - var table = createSimpleOneColumnNestedTable(); - table.selectionMode = SelectionMode.ROW; - this.addHTMLOutput(table); - - var rows = table.tableRows; - table.selectedTableRow = rows[0]; - - table.performKeyCommand_('ARROW_DOWN'); - assert.equal(table.selectedTableRow, rows[1]); - - table.performKeyCommand_('ARROW_UP'); - assert.equal(table.selectedTableRow, rows[0]); - - // Enter on collapsed row should expand. - table.selectedTableRow = rows[0]; - table.performKeyCommand_('ENTER'); - assert.equal(table.selectedTableRow, rows[0]); - assert.isTrue(table.getExpandedForTableRow(rows[0])); - - table.performKeyCommand_('ENTER'); - assert.isFalse(table.getExpandedForTableRow(rows[0])); - - // Arrow right on collapsed row should expand. - table.selectedTableRow = rows[0]; - table.performKeyCommand_('ARROW_RIGHT'); - assert.equal(table.selectedTableRow, rows[0].subRows[0]); - assert.isTrue(table.getExpandedForTableRow(rows[0])); - - table.performKeyCommand_('ARROW_DOWN'); - assert.equal(table.selectedTableRow, rows[0].subRows[1]); - - // Arrow left on collapsed item should select parent. - table.performKeyCommand_('ARROW_LEFT'); - assert.equal(table.selectedTableRow, rows[0]); - assert.isTrue(table.getExpandedForTableRow(rows[0])); - // Arrow left on parent should collapse its children. - table.performKeyCommand_('ARROW_LEFT'); - assert.isFalse(table.getExpandedForTableRow(rows[0])); - - // Arrow right on expanded row should select first child. - table.selectedTableRow = rows[0]; - table.setExpandedForTableRow(rows[0], true); - table.performKeyCommand_('ARROW_RIGHT'); - assert.equal(table.selectedTableRow, rows[0].subRows[0]); - - // Arrow right on a non-expandable row should do nothing. - table.selectedTableRow = rows[1]; - assert.equal(table.selectedTableRow, rows[1]); - table.performKeyCommand_('ARROW_RIGHT'); - assert.equal(table.selectedTableRow, rows[1]); - assert.isFalse(table.getExpandedForTableRow(rows[1])); - }); - - test('RightArrowKeyWhenTableSorted', function() { - var table = createSimpleOneColumnNestedTable(); - table.selectionMode = SelectionMode.ROW; - this.addHTMLOutput(table); - table.sortDescending = true; - table.sortColumnIndex = 0; - table.rebuild(); - var rows = table.tableRows; - - // Arrow right should select the first child showing up on the viewer, - // rather than first child in sub rows since sorted. - table.selectedTableRow = rows[0]; - table.performKeyCommand_('ARROW_RIGHT'); - assert.equal(table.selectedTableRow, rows[0].subRows[2]); - }); - - test('reduceNumberOfColumnsAfterRebuild', function() { - // Create a table with two columns. - var table = document.createElement('tr-ui-b-table'); - table.tableColumns = [ - { - title: 'First Column', - value: function(row) { return row.firstData; }, - width: '100px' - }, - { - title: 'Second Column', - value: function(row) { return row.secondData; }, - width: '100px' - } - ]; - - // Build the table. - table.rebuild(); - - // Check that reducing the number of columns doesn't throw an exception. - table.tableColumns = [ - { - title: 'First Column', - value: function(row) { return row.firstData; }, - width: '200px' - } - ]; - }); - - test('rowHighlightDark', function() { - var columns = [ - { - title: 'Title', - value: function(row) { return row.a; }, - width: '150px', - supportsCellSelection: false - }, - { - title: 'Col1', - value: function(row) { return row.b; }, - width: '33%' - }, - { - title: 'Col2', - value: function(row) { return row.b * 2; }, - width: '33%' - }, - { - title: 'Col3', - value: function(row) { return row.b * 3; }, - width: '33%' - } - ]; - - var table = document.createElement('tr-ui-b-table'); - table.showHeader = true; - table.rowHighlightStyle = HighlightStyle.DARK; - table.tableColumns = columns; - table.tableRows = [ - { - a: 'first', - b: '1' - }, - { - a: 'second', - b: '2' - } - ]; - table.rebuild(); - this.addHTMLOutput(table); - }); - - test('cellHighlightLight', function() { - var columns = [ - { - title: 'Title', - value: function(row) { return row.a; }, - width: '150px', - supportsCellSelection: false - }, - { - title: 'Col1', - value: function(row) { return row.b; }, - width: '33%' - }, - { - title: 'Col2', - value: function(row) { return row.b * 2; }, - width: '33%' - }, - { - title: 'Col3', - value: function(row) { return row.b * 3; }, - width: '33%' - } - ]; - - var table = document.createElement('tr-ui-b-table'); - table.showHeader = true; - table.cellHighlightStyle = HighlightStyle.LIGHT; - table.tableColumns = columns; - table.tableRows = [ - { - a: 'first', - b: '1' - }, - { - a: 'second', - b: '2' - } - ]; - table.rebuild(); - this.addHTMLOutput(table); - }); - - test('cellSelectionBasic', function() { - var columns = [ - { - title: 'Title', - value: function(row) { return row.a; }, - width: '150px', - supportsCellSelection: false - }, - { - title: 'Col1', - value: function(row) { return row.b; }, - width: '33%' - }, - { - title: 'Col2', - value: function(row) { return row.b * 2; }, - width: '33%' - }, - { - title: 'Col3', - value: function(row) { return row.b * 3; }, - width: '33%' - } - ]; - - var table = document.createElement('tr-ui-b-table'); - table.showHeader = true; - table.selectionMode = SelectionMode.CELL; - table.rowHighlightStyle = HighlightStyle.NONE; - table.tableColumns = columns; - table.tableRows = [ - { - a: 'first', - b: '1' - }, - { - a: 'second', - b: '2' - } - ]; - table.rebuild(); - this.addHTMLOutput(table); - - table.selectedTableRow = table.tableRows[0]; - assert.equal(table.selectedColumnIndex, 1); - - table.performKeyCommand_('ARROW_DOWN'); - table.performKeyCommand_('ARROW_RIGHT'); - table.performKeyCommand_('ARROW_RIGHT'); - table.performKeyCommand_('ARROW_LEFT'); - assert.equal(table.selectedTableRow, table.tableRows[1]); - assert.equal(table.selectedColumnIndex, 2); - - table.selectedTableRow = undefined; - assert.equal(table.selectedTableRow, undefined); - assert.equal(table.selectedColumnIndex, undefined); - assert.equal(table.selectedColumnIndex, undefined); - }); - - test('cellSelectionNested', function() { - var columns = [ - { - title: 'Title', - value: function(row) { return row.a; }, - width: '150px', - supportsCellSelection: false - }, - { - title: 'Value', - value: function(row) { return row.b; }, - width: '150px' - } - ]; - - var rows = [ - { - a: 'parent', - b: '1', - subRows: [ - { - a: 'child', - b: '2' - } - ] - } - ]; - - var table = document.createElement('tr-ui-b-table'); - table.showHeader = true; - table.selectionMode = SelectionMode.CELL; - table.tableColumns = columns; - table.tableRows = rows; - table.rebuild(); - this.addHTMLOutput(table); - - // Expand the parent row. - table.setExpandedForTableRow(rows[0], true); - - // Select the second cell in the child row. - table.selectedTableRow = rows[0].subRows[0]; - assert.isFalse(isSelected(table.$.body.children[0])); - assert.isFalse(isSelected(table.$.body.children[0].children[1])); - assert.isTrue(isSelected(table.$.body.children[1])); - assert.isTrue(isSelected(table.$.body.children[1].children[1])); - - // Fold the parent row. The second cell in the parent row should be - // automatically selected. - table.setExpandedForTableRow(rows[0], false); - assert.isTrue(isSelected(table.$.body.children[0])); - assert.isTrue(isSelected(table.$.body.children[0].children[1])); - - // Expand the parent row again. Only the second cell of the parent row - // should still be selected. - table.setExpandedForTableRow(rows[0], true); - assert.isTrue(isSelected(table.$.body.children[0])); - assert.isTrue(isSelected(table.$.body.children[0].children[1])); - assert.isFalse(isSelected(table.$.body.children[1])); - assert.isFalse(isSelected(table.$.body.children[1].children[1])); - }); - - test('resolvedHighlightStyle', function() { - var table = document.createElement('tr-ui-b-table'); - - // Undefined selection mode. - assert.strictEqual(table.resolvedRowHighlightStyle, HighlightStyle.NONE); - assert.strictEqual(table.resolvedCellHighlightStyle, HighlightStyle.NONE); - - // Row selection mode. - table.selectionMode = SelectionMode.ROW; - assert.strictEqual(table.resolvedRowHighlightStyle, HighlightStyle.DARK); - assert.strictEqual(table.resolvedCellHighlightStyle, HighlightStyle.NONE); - - // Cell selection mode. - table.selectionMode = SelectionMode.CELL; - assert.strictEqual(table.resolvedRowHighlightStyle, HighlightStyle.LIGHT); - assert.strictEqual(table.resolvedCellHighlightStyle, HighlightStyle.DARK); - - // Explicit row highlight style. - table.rowHighlightStyle = HighlightStyle.NONE; - assert.strictEqual(table.resolvedRowHighlightStyle, HighlightStyle.NONE); - assert.strictEqual(table.resolvedCellHighlightStyle, HighlightStyle.DARK); - - // Explicit row and cell highlight styles. - table.cellHighlightStyle = HighlightStyle.LIGHT; - assert.strictEqual(table.resolvedRowHighlightStyle, HighlightStyle.NONE); - assert.strictEqual(table.resolvedCellHighlightStyle, HighlightStyle.LIGHT); - - // Back to default highlight styles. - table.cellHighlightStyle = HighlightStyle.DEFAULT; - table.rowHighlightStyle = HighlightStyle.DEFAULT; - assert.strictEqual(table.resolvedRowHighlightStyle, HighlightStyle.LIGHT); - assert.strictEqual(table.resolvedCellHighlightStyle, HighlightStyle.DARK); - }); - - test('headersWithHtmlElements', function() { - var firstColumnTitle = document.createTextNode('First Column'); - var secondColumnTitle = document.createElement('span'); - secondColumnTitle.innerText = 'Second Column'; - secondColumnTitle.style.color = 'blue'; - - var columns = [ - { - title: firstColumnTitle, - value: function(row) { return row.firstData; }, - width: '200px' - }, - { - title: secondColumnTitle, - value: function(row) { return row.secondData; } - } - ]; - - var rows = [ - { - firstData: 'A1', - secondData: 'A2' - }, - { - firstData: 'B1', - secondData: 'B2' - } - ]; - - var table = document.createElement('tr-ui-b-table'); - table.tableColumns = columns; - table.tableRows = rows; - table.rebuild(); - - this.addHTMLOutput(table); - - var firstColumnHeader = table.$.head.children[0].children[0].children[0]; - var secondColumnHeader = table.$.head.children[0].children[1].children[0]; - assert.equal(firstColumnHeader.cellTitle.textContent, 'First Column'); - assert.equal(secondColumnHeader.cellTitle.textContent, 'Second Column'); - }); - - test('align', function() { - var columns = [ - { - title: 'a', - align: ColumnAlignment.RIGHT, - value: function(row) { - return row.a; - } - } - ]; - var rows = [{a: 1}, {a: 'long-row-so-that-alignment-would-be-visible'}]; - - var table = document.createElement('tr-ui-b-table'); - table.tableColumns = columns; - table.tableRows = rows; - table.rebuild(); - - this.addHTMLOutput(table); - - assert.strictEqual( - table.$.body.children[0].children[0].style.textAlign, 'right'); - }); - - test('subRowsPropertyName', function() { - var columns = [ - { - title: 'a', - value: function(row) { - return row.a; - } - } - ]; - var rows = [ - { - a: 1, - isExpanded: true, - children: [ - {a: 2} - ] - } - ]; - - var table = document.createElement('tr-ui-b-table'); - table.subRowsPropertyName = 'children'; - table.tableColumns = columns; - table.tableRows = rows; - table.rebuild(); - - this.addHTMLOutput(table); - - assert.equal(2, table.$.body.children[1].children[0].textContent); - }); - - test('shouldNotRenderUndefined', function() { - var columns = [ - { - title: 'Column', - value: function(row) { return row.firstData; } - } - ]; - - var rows = [ - { - firstData: undefined, - secondData: 'A2' - } - ]; - - var table = document.createElement('tr-ui-b-table'); - table.tableColumns = columns; - table.tableRows = rows; - table.rebuild(); - - this.addHTMLOutput(table); - - // check that we don't have 'undefined' anywhere - assert.isTrue(table.$.body.innerHTML.indexOf('undefined') < 0); - }); - - test('customizeTableRowCallback', function() { - var columns = [ - { - title: 'Column', - value: function(row) { return row.data; } - } - ]; - - var rows = [ - { - data: 'data' - } - ]; - - var table = document.createElement('tr-ui-b-table'); - var callbackCalled = false; - table.tableColumns = columns; - table.tableRows = rows; - table.customizeTableRowCallback = function(userRow, trElement) { - callbackCalled = (userRow === rows[0]); - }; - table.rebuild(); - assert.isTrue(callbackCalled); - - this.addHTMLOutput(table); - - // The callback can also be set after the table is first built. - table.customizeTableRowCallback = function(userRow, trElement) { - callbackCalled = (userRow === rows[0]); - }; - - // Setting the customize callback should set the body dirty. - assert.isTrue(table.bodyDirty_); - - callbackCalled = false; - - // Don't bother waiting for the timeout. - table.rebuild(); - - assert.isTrue(callbackCalled); - }); - - test('selectionEdgeCases', function() { - var table = document.createElement('tr-ui-b-table'); - table.tableColumns = [ - { - title: 'Column', - value: function(row) { return row.data; }, - supportsCellSelection: false - } - ]; - table.tableRows = [{ data: 'body row' }]; - table.footerRows = [{ data: 'footer row' }]; - table.selectionMode = SelectionMode.ROW; - this.addHTMLOutput(table); - - // Clicking on the body row should *not* throw an exception (despite the - // column not supporting cell selection). - table.$.body.children[0].children[0].click(); - - // Clicking on the footer row should *not* throw an exception (despite - // footer rows not being selectable in general). - table.$.foot.children[0].children[0].click(); - }); - - test('defaultExpansionStateCallback', function() { - var columns = [ - { - title: 'Name', - value: function(row) { return row.name; } - }, - { - title: 'Value', - value: function(row) { return row.value; } - } - ]; - - var rows = [ - { - name: 'A', - value: 10, - subRows: [ - { - name: 'B', - value: 8, - subRows: [ - { - name: 'C', - value: 4 - }, - { - name: 'D', - value: 4 - } - ] - }, - { - name: 'E', - value: 2, - subRows: [ - { - name: 'F', - value: 1 - }, - { - name: 'G', - value: 1 - } - ] - } - ] - } - ]; - - var table = document.createElement('tr-ui-b-table'); - table.tableColumns = columns; - table.tableRows = rows; - table.rebuild(); - - this.addHTMLOutput(table); - - var cRow = tr.b.findDeepElementMatchingPredicate( - table, function(element) { - return element.textContent === 'C'; - }); - assert.equal(cRow, undefined); - - var callbackCalled = false; - table.defaultExpansionStateCallback = function(row, parentRow) { - callbackCalled = true; - - if (parentRow === undefined) - return true; - - if (row.value >= (parentRow.value * 0.8)) - return true; - - return false; - }; - - // Setting the callback should set the body dirty. - assert.isTrue(table.bodyDirty_); - assert.isFalse(callbackCalled); - - table.rebuild(); - - assert.isTrue(callbackCalled); - cRow = tr.b.findDeepElementMatchingPredicate(table, function(element) { - return element.textContent === 'C'; - }); - assert.isDefined(cRow); - }); - - test('sortExpanded', function() { - var columns = [ - { - title: 'Name', - value: function(row) { return row.name; } - }, - { - title: 'Value', - value: function(row) { return row.value; }, - cmp: function(x, y) { return x.value - y.value; } - } - ]; - - var rows = [ - { - name: 'A', - value: 10, - subRows: [ - { - name: 'B', - value: 8 - }, - { - name: 'C', - value: 4 - }, - ] - } - ]; - - var table = document.createElement('tr-ui-b-table'); - table.tableColumns = columns; - table.tableRows = rows; - table.rebuild(); - - this.addHTMLOutput(table); - - function isB(row) { - return row.textContent === 'B'; - } - - // Check that 'A' row is not expanded. - assert.isUndefined(tr.b.findDeepElementMatchingPredicate(table, isB)); - - // Expand 'A' row. - table.setExpandedForTableRow(rows[0], true); - - // Check that 'A' is expanded. - assert.isDefined(tr.b.findDeepElementMatchingPredicate(table, isB)); - - // Sort by value. - table.sortColumnIndex = 1; - - // Rebuild the table synchronously instead of waiting for scheduleRebuild_'s - // setTimeout(0). - table.rebuild(); - - // Check that 'A' is still expanded. - assert.isDefined(tr.b.findDeepElementMatchingPredicate(table, isB)); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/timing_tool.html b/chromium/third_party/catapult/tracing/tracing/ui/base/timing_tool.html deleted file mode 100644 index 5fe8c74e86b..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/timing_tool.html +++ /dev/null @@ -1,322 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/range.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/model/slice.html"> -<link rel="import" href="/tracing/ui/base/ui.html"> - -<script> -'use strict'; - -/** - * @fileoverview Provides the TimingTool class. - */ -tr.exportTo('tr.ui.b', function() { - - /** - * Tool for taking time measurements in the TimelineTrackView using - * Viewportmarkers. - * @constructor - */ - function TimingTool(viewport, targetElement) { - this.viewport_ = viewport; - - // Prepare the event handlers to be added and removed repeatedly. - this.onMouseMove_ = this.onMouseMove_.bind(this); - this.onDblClick_ = this.onDblClick_.bind(this); - this.targetElement_ = targetElement; - - // Valid only during mousedown. - this.isMovingLeftEdge_ = false; - }; - - TimingTool.prototype = { - - onEnterTiming: function(e) { - this.targetElement_.addEventListener('mousemove', this.onMouseMove_); - this.targetElement_.addEventListener('dblclick', this.onDblClick_); - }, - - onBeginTiming: function(e) { - if (!this.isTouchPointInsideTrackBounds_(e.clientX, e.clientY)) - return; - - var pt = this.getSnappedToEventPosition_(e); - this.mouseDownAt_(pt.x, pt.y); - - this.updateSnapIndicators_(pt); - }, - - updateSnapIndicators_: function(pt) { - if (!pt.snapped) - return; - var ir = this.viewport_.interestRange; - if (ir.min === pt.x) - ir.leftSnapIndicator = new tr.ui.SnapIndicator(pt.y, pt.height); - if (ir.max === pt.x) - ir.rightSnapIndicator = new tr.ui.SnapIndicator(pt.y, pt.height); - }, - - onUpdateTiming: function(e) { - var pt = this.getSnappedToEventPosition_(e); - this.mouseMoveAt_(pt.x, pt.y, true); - this.updateSnapIndicators_(pt); - }, - - onEndTiming: function(e) { - this.mouseUp_(); - }, - - onExitTiming: function(e) { - this.targetElement_.removeEventListener('mousemove', this.onMouseMove_); - this.targetElement_.removeEventListener('dblclick', this.onDblClick_); - }, - - onMouseMove_: function(e) { - if (e.button) - return; - var worldX = this.getWorldXFromEvent_(e); - this.mouseMoveAt_(worldX, e.clientY, false); - }, - - onDblClick_: function(e) { - // TODO(nduca): Implement dobuleclicking. - console.error('not implemented'); - }, - - //////////////////////////////////////////////////////////////////////////// - - isTouchPointInsideTrackBounds_: function(clientX, clientY) { - if (!this.viewport_ || - !this.viewport_.modelTrackContainer || - !this.viewport_.modelTrackContainer.canvas) - return false; - - var canvas = this.viewport_.modelTrackContainer.canvas; - var canvasRect = canvas.getBoundingClientRect(); - if (clientX >= canvasRect.left && clientX <= canvasRect.right && - clientY >= canvasRect.top && clientY <= canvasRect.bottom) - return true; - - return false; - }, - - mouseDownAt_: function(worldX, y) { - var ir = this.viewport_.interestRange; - var dt = this.viewport_.currentDisplayTransform; - - var pixelRatio = window.devicePixelRatio || 1; - var nearnessThresholdWorld = dt.xViewVectorToWorld(6 * pixelRatio); - - if (ir.isEmpty) { - ir.setMinAndMax(worldX, worldX); - ir.rightSelected = true; - this.isMovingLeftEdge_ = false; - return; - } - - - // Left edge test. - if (Math.abs(worldX - ir.min) < nearnessThresholdWorld) { - ir.leftSelected = true; - ir.min = worldX; - this.isMovingLeftEdge_ = true; - return; - } - - // Right edge test. - if (Math.abs(worldX - ir.max) < nearnessThresholdWorld) { - ir.rightSelected = true; - ir.max = worldX; - this.isMovingLeftEdge_ = false; - return; - } - - ir.setMinAndMax(worldX, worldX); - ir.rightSelected = true; - this.isMovingLeftEdge_ = false; - }, - - mouseMoveAt_: function(worldX, y, mouseDown) { - var ir = this.viewport_.interestRange; - - if (mouseDown) { - this.updateMovingEdge_(worldX); - return; - } - - var ir = this.viewport_.interestRange; - var dt = this.viewport_.currentDisplayTransform; - - var pixelRatio = window.devicePixelRatio || 1; - var nearnessThresholdWorld = dt.xViewVectorToWorld(6 * pixelRatio); - - // Left edge test. - if (Math.abs(worldX - ir.min) < nearnessThresholdWorld) { - ir.leftSelected = true; - ir.rightSelected = false; - return; - } - - // Right edge test. - if (Math.abs(worldX - ir.max) < nearnessThresholdWorld) { - ir.leftSelected = false; - ir.rightSelected = true; - return; - } - - ir.leftSelected = false; - ir.rightSelected = false; - return; - }, - - updateMovingEdge_: function(newWorldX) { - var ir = this.viewport_.interestRange; - var a = ir.min; - var b = ir.max; - if (this.isMovingLeftEdge_) - a = newWorldX; - else - b = newWorldX; - - if (a <= b) - ir.setMinAndMax(a, b); - else - ir.setMinAndMax(b, a); - - if (ir.min == newWorldX) { - this.isMovingLeftEdge_ = true; - ir.leftSelected = true; - ir.rightSelected = false; - } else { - this.isMovingLeftEdge_ = false; - ir.leftSelected = false; - ir.rightSelected = true; - } - }, - - mouseUp_: function() { - var dt = this.viewport_.currentDisplayTransform; - var ir = this.viewport_.interestRange; - - ir.leftSelected = false; - ir.rightSelected = false; - - var pixelRatio = window.devicePixelRatio || 1; - var minWidthValue = dt.xViewVectorToWorld(2 * pixelRatio); - if (ir.range < minWidthValue) - ir.reset(); - }, - - getWorldXFromEvent_: function(e) { - var pixelRatio = window.devicePixelRatio || 1; - var canvas = this.viewport_.modelTrackContainer.canvas; - var worldOffset = canvas.getBoundingClientRect().left; - var viewX = (e.clientX - worldOffset) * pixelRatio; - return this.viewport_.currentDisplayTransform.xViewToWorld(viewX); - }, - - - /** - * Get the closest position of an event within a vertical range of the mouse - * position if possible, otherwise use the position of the mouse pointer. - * @param {MouseEvent} e Mouse event with the current mouse coordinates. - * @return { - * {Number} x, The x coordinate in world space. - * {Number} y, The y coordinate in world space. - * {Number} height, The height of the event. - * {boolean} snapped Whether the coordinates are from a snapped event or - * the mouse position. - * } - */ - getSnappedToEventPosition_: function(e) { - var pixelRatio = window.devicePixelRatio || 1; - var EVENT_SNAP_RANGE = 16 * pixelRatio; - - var modelTrackContainer = this.viewport_.modelTrackContainer; - var modelTrackContainerRect = modelTrackContainer.getBoundingClientRect(); - - var viewport = this.viewport_; - var dt = viewport.currentDisplayTransform; - var worldMaxDist = dt.xViewVectorToWorld(EVENT_SNAP_RANGE); - - var worldX = this.getWorldXFromEvent_(e); - var mouseY = e.clientY; - - var selection = new tr.model.EventSet(); - - // Look at the track under mouse position first for better performance. - modelTrackContainer.addClosestEventToSelection( - worldX, worldMaxDist, mouseY, mouseY, selection); - - // Look at all tracks visible on screen. - if (!selection.length) { - modelTrackContainer.addClosestEventToSelection( - worldX, worldMaxDist, - modelTrackContainerRect.top, modelTrackContainerRect.bottom, - selection); - } - - var minDistX = worldMaxDist; - var minDistY = Infinity; - var pixWidth = dt.xViewVectorToWorld(1); - - // Create result object with the mouse coordinates. - var result = { - x: worldX, - y: mouseY - modelTrackContainerRect.top, - height: 0, - snapped: false - }; - - var eventBounds = new tr.b.Range(); - for (var event of selection) { - var track = viewport.trackForEvent(event); - var trackRect = track.getBoundingClientRect(); - - eventBounds.reset(); - event.addBoundsToRange(eventBounds); - var eventX; - if (Math.abs(eventBounds.min - worldX) < - Math.abs(eventBounds.max - worldX)) { - eventX = eventBounds.min; - } else { - eventX = eventBounds.max; - } - - var distX = eventX - worldX; - - var eventY = trackRect.top; - var eventHeight = trackRect.height; - var distY = Math.abs(eventY + eventHeight / 2 - mouseY); - - // Prefer events with a closer y position if their x difference is below - // the width of a pixel. - if ((distX <= minDistX || Math.abs(distX - minDistX) < pixWidth) && - distY < minDistY) { - minDistX = distX; - minDistY = distY; - - // Retrieve the event position from the hit. - result.x = eventX; - result.y = eventY + - modelTrackContainer.scrollTop - modelTrackContainerRect.top; - result.height = eventHeight; - result.snapped = true; - } - } - - return result; - } - }; - - return { - TimingTool: TimingTool - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/timing_tool_test.html b/chromium/third_party/catapult/tracing/tracing/ui/base/timing_tool_test.html deleted file mode 100644 index 91e630b945a..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/timing_tool_test.html +++ /dev/null @@ -1,78 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/timeline_viewport.html"> -<link rel="import" href="/tracing/ui/base/timing_tool.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - function create100PxWideViewportInto10WideWorld() { - var vp = new tr.ui.TimelineViewport(document.createElement('div')); - var tempDisplayTransform = new tr.ui.TimelineDisplayTransform(); - tempDisplayTransform.xSetWorldBounds(0, 10, 100); - vp.setDisplayTransformImmediately(tempDisplayTransform); - - assert.equal(vp.currentDisplayTransform.xViewToWorld(0), 0); - assert.equal(vp.currentDisplayTransform.xViewToWorld(100), 10); - - return vp; - } - - test('dragLeftInterestRegion', function() { - var vp = create100PxWideViewportInto10WideWorld(); - vp.interestRange.min = 1; - vp.interestRange.max = 9; - var tool = new tr.ui.b.TimingTool(vp); - - tool.mouseDownAt_(1.1, 0); - assert.isTrue(vp.interestRange.leftSelected); - tool.mouseMoveAt_(1.5, 0, true); - assert.equal(vp.interestRange.min, 1.5); - tool.mouseUp_(); - assert.equal(vp.interestRange.min, 1.5); - assert.isFalse(vp.interestRange.leftSelected); - }); - - test('dragRightInterestRegion', function() { - var vp = create100PxWideViewportInto10WideWorld(); - vp.interestRange.min = 1; - vp.interestRange.max = 9; - var tool = new tr.ui.b.TimingTool(vp); - - tool.mouseDownAt_(9.1, 0); - assert.isTrue(vp.interestRange.rightSelected); - tool.mouseMoveAt_(8, 0, true); - assert.equal(vp.interestRange.max, 8); - tool.mouseUp_(); - assert.equal(vp.interestRange.max, 8); - assert.isFalse(vp.interestRange.leftSelected); - }); - - test('dragInNewSpace', function() { - var vp = create100PxWideViewportInto10WideWorld(); - vp.interestRange.min = 1; - vp.interestRange.max = 9; - var tool = new tr.ui.b.TimingTool(vp); - - tool.mouseDownAt_(5, 0); - assert.isTrue(vp.interestRange.rightSelected); - assert.equal(vp.interestRange.min, 5); - assert.equal(vp.interestRange.max, 5); - tool.mouseMoveAt_(4, 0, true); - assert.equal(vp.interestRange.min, 4); - assert.equal(vp.interestRange.max, 5); - assert.isTrue(vp.interestRange.leftSelected); - tool.mouseUp_(); - assert.equal(vp.interestRange.min, 4); - assert.isFalse(vp.interestRange.leftSelected); - assert.isFalse(vp.interestRange.rightSelected); - }); -}); -</script> - diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/tool_button.css b/chromium/third_party/catapult/tracing/tracing/ui/base/tool_button.css deleted file mode 100644 index 1c5ae4170c0..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/tool_button.css +++ /dev/null @@ -1,17 +0,0 @@ -/* Copyright (c) 2013 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -* /deep/ .tool-button { - background-position: center center; - background-repeat: no-repeat; - border-bottom: 1px solid #BCBCBC; - border-top: 1px solid #F1F1F1; - cursor: pointer; - height: 30px; -} - -* /deep/ .tool-button.active { - cursor: auto; -} diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/toolbar_button.html b/chromium/third_party/catapult/tracing/tracing/ui/base/toolbar_button.html deleted file mode 100644 index 9d2405d8480..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/toolbar_button.html +++ /dev/null @@ -1,41 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/base.html"> - -</script> -<polymer-element name='tr-ui-b-toolbar-button' noscript> - <template> - <style> - :host { - display: flex; - background-color: #f8f8f8; - border: 1px solid rgba(0, 0, 0, 0.5); - color: rgba(0,0,0,0.8); - justify-content: center; - align-self: stretch; - min-width: 23px; - } - - :host(:hover) { - background-color: rgba(255, 255, 255, 1.0); - border-color: rgba(0, 0, 0, 0.8); - box-shadow: 0 0 .05em rgba(0, 0, 0, 0.4); - color: rgba(0, 0, 0, 1); - } - - #aligner { - display: flex; - flex: 0 0 auto; - align-self: center; - } - </style> - <div id="aligner"> - <content></content> - </div> - </template> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/toolbar_button_test.html b/chromium/third_party/catapult/tracing/tracing/ui/base/toolbar_button_test.html deleted file mode 100644 index 78f94081163..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/toolbar_button_test.html +++ /dev/null @@ -1,39 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> -<link rel="import" href="/tracing/ui/base/toolbar_button.html"> -<link rel="import" href="/tracing/ui/base/dom_helpers.html"> -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - test('tallWithTextContent', function() { - var el = document.createElement('tr-ui-b-toolbar-button'); - el.style.width = '100px'; - el.style.height = '40px'; - - el.textContent = 'blahblah'; - - this.addHTMLOutput(el); - }); - - test('tallWithInnerSpan', function() { - var el = document.createElement('tr-ui-b-toolbar-button'); - el.style.width = '100px'; - el.style.height = '40px'; - - el.appendChild(tr.ui.b.createSpan({textContent: 'blahblah'})); - - this.addHTMLOutput(el); - }); - - test('puny', function() { - var el = document.createElement('tr-ui-b-toolbar-button'); - el.textContent = 'M'; - this.addHTMLOutput(el); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/ui.html b/chromium/third_party/catapult/tracing/tracing/ui/base/ui.html deleted file mode 100644 index 20c1bd4471d..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/ui.html +++ /dev/null @@ -1,169 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> -<link rel="import" href="/tracing/base/base.html"> -<script> -'use strict'; - -tr.exportTo('tr.ui.b', function() { - - /** - * Decorates elements as an instance of a class. - * @param {string|!Element} source The way to find the element(s) to decorate. - * If this is a string then {@code querySeletorAll} is used to find the - * elements to decorate. - * @param {!Function} constr The constructor to decorate with. The constr - * needs to have a {@code decorate} function. - */ - function decorate(source, constr) { - var elements; - if (typeof source == 'string') - elements = tr.doc.querySelectorAll(source); - else - elements = [source]; - - for (var i = 0, el; el = elements[i]; i++) { - if (!(el instanceof constr)) - constr.decorate(el); - } - } - - /** - * Defines a tracing UI component, a function that can be called to construct - * the component. - * - * tr class: - * var List = tr.ui.b.define('list'); - * List.prototype = { - * __proto__: HTMLUListElement.prototype, - * decorate: function() { - * ... - * }, - * ... - * }; - * - * Derived class: - * var CustomList = tr.ui.b.define('custom-list', List); - * CustomList.prototype = { - * __proto__: List.prototype, - * decorate: function() { - * ... - * }, - * ... - * }; - * - * @param {string} className The className of the newly created subtype. If - * subclassing by passing in opt_parentConstructor, this is used for - * debugging. If not subclassing, then it is the tag name that will be - * created by the component. - - * @param {function=} opt_parentConstructor The parent class for this new - * element, if subclassing is desired. If provided, the parent class must - * be also a function created by tr.ui.b.define. - * - * @param {string=} opt_tagNS The namespace in which to create the base - * element. Has no meaning when opt_parentConstructor is passed and must - * either be undefined or the same namespace as the parent class. - * - * @return {function(Object=):Element} The newly created component - * constructor. - */ - function define(className, opt_parentConstructor, opt_tagNS) { - if (typeof className == 'function') { - throw new Error('Passing functions as className is deprecated. Please ' + - 'use (className, opt_parentConstructor) to subclass'); - } - - var className = className.toLowerCase(); - if (opt_parentConstructor && !opt_parentConstructor.tagName) - throw new Error('opt_parentConstructor was not ' + - 'created by tr.ui.b.define'); - - // Walk up the parent constructors until we can find the type of tag - // to create. - var tagName = className; - var tagNS = undefined; - if (opt_parentConstructor) { - if (opt_tagNS) - throw new Error('Must not specify tagNS if parentConstructor is given'); - var parent = opt_parentConstructor; - while (parent && parent.tagName) { - tagName = parent.tagName; - tagNS = parent.tagNS; - parent = parent.parentConstructor; - } - } else { - tagNS = opt_tagNS; - } - - /** - * Creates a new UI element constructor. - * Arguments passed to the constuctor are provided to the decorate method. - * You will need to call the parent elements decorate method from within - * your decorate method and pass any required parameters. - * @constructor - */ - function f() { - if (opt_parentConstructor && - f.prototype.__proto__ != opt_parentConstructor.prototype) { - throw new Error( - className + ' prototye\'s __proto__ field is messed up. ' + - 'It MUST be the prototype of ' + opt_parentConstructor.tagName); - } - - var el; - if (tagNS === undefined) - el = tr.doc.createElement(tagName); - else - el = tr.doc.createElementNS(tagNS, tagName); - f.decorate.call(this, el, arguments); - return el; - } - - /** - * Decorates an element as a UI element class. - * @param {!Element} el The element to decorate. - */ - f.decorate = function(el) { - el.__proto__ = f.prototype; - el.decorate.apply(el, arguments[1]); - el.constructor = f; - }; - - f.className = className; - f.tagName = tagName; - f.tagNS = tagNS; - f.parentConstructor = (opt_parentConstructor ? opt_parentConstructor : - undefined); - f.toString = function() { - if (!f.parentConstructor) - return f.tagName; - return f.parentConstructor.toString() + '::' + f.className; - }; - - return f; - } - - function elementIsChildOf(el, potentialParent) { - if (el == potentialParent) - return false; - - var cur = el; - while (cur.parentNode) { - if (cur == potentialParent) - return true; - cur = cur.parentNode; - } - return false; - }; - - return { - decorate: decorate, - define: define, - elementIsChildOf: elementIsChildOf - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/ui_state.html b/chromium/third_party/catapult/tracing/tracing/ui/base/ui_state.html deleted file mode 100644 index eb515ddf15c..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/ui_state.html +++ /dev/null @@ -1,85 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/model/location.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.b', function() { - var Location = tr.model.Location; - - /** - * UIState is a class that represents the current state of the timeline by - * the Location of the point of interest and the current scaleX of the - * timeline. - * - * @constructor - */ - function UIState(location, scaleX) { - this.location_ = location; - this.scaleX_ = scaleX; - }; - - /** - * Accepts a UIState string in the format of (timestamp)@(stableID)x(scaleX) - * Returns undefined if string is not in this format, or throws an Error if - * variables in a syntactically-correct stateString does not produce a valid - * UIState. Otherwise returns a constructed UIState instance. - */ - UIState.fromUserFriendlyString = function(model, viewport, stateString) { - var navByFinderPattern = /^(-?\d+(\.\d+)?)@(.+)x(\d+(\.\d+)?)$/g; - var match = navByFinderPattern.exec(stateString); - if (!match) - return; - - var timestamp = parseFloat(match[1]); - var stableId = match[3]; - var scaleX = parseFloat(match[4]); - - if (scaleX <= 0) - throw new Error('Invalid ScaleX value in UI State string.'); - - if (!viewport.containerToTrackMap.getTrackByStableId(stableId)) - throw new Error('Invalid StableID given in UI State String.'); - - var loc = tr.model.Location.fromStableIdAndTimestamp( - viewport, stableId, timestamp); - return new UIState(loc, scaleX); - } - - UIState.prototype = { - - get location() { - return this.location_; - }, - - get scaleX() { - return this.scaleX_; - }, - - toUserFriendlyString: function(viewport) { - var timestamp = this.location_.xWorld; - var stableId = - this.location_.getContainingTrack(viewport).eventContainer.stableId; - var scaleX = this.scaleX_; - return timestamp.toFixed(5) + '@' + stableId + 'x' + scaleX.toFixed(5); - }, - - toDict: function() { - return { - location: this.location_.toDict(), - scaleX: this.scaleX_ - }; - } - }; - - return { - UIState: UIState - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/ui_state_test.html b/chromium/third_party/catapult/tracing/tracing/ui/base/ui_state_test.html deleted file mode 100644 index 91ee74eda1a..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/ui_state_test.html +++ /dev/null @@ -1,99 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/ui/tracks/track.html"> -<link rel="import" href="/tracing/ui/base/ui_state.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var UIState = tr.ui.b.UIState; - - function FakeModel() { - this.processes = { 1: { threads: { 2: { stableId: '1.2' } } } }; - } - - // FakeTrack needs to be an instance of tr.ui.tracks.Track because a - // location is constructed in terms of Track instances. - function FakeTrack() { } - FakeTrack.prototype = { - __proto__: tr.ui.tracks.Track.prototype, - - get eventContainer() { - return { stableId: '1.2' }; - }, - - getBoundingClientRect: function() { - return { top: 5, height: 2 }; - }, - - get parentElement() { - return null; - } - }; - - function FakeViewPort() { - this.containerToTrackMap = { - // "1.2" is the only valid stableId this test function accepts. - getTrackByStableId: function(stableId) { - if (stableId === '1.2') - return new FakeTrack; - return undefined; - } - }; - } - - test('invalidStableId', function() { - var model = new FakeModel; - var vp = new FakeViewPort; - assert.throws(function() { - UIState.fromUserFriendlyString(model, vp, '15@1.3x6'); - }); - assert.throws(function() { - UIState.fromUserFriendlyString(model, vp, '15@2.2x6'); - }); - assert.throws(function() { - UIState.fromUserFriendlyString(model, vp, '505@1.x5'); - }); - }); - - test('invalidScaleX', function() { - var model = new FakeModel; - var vp = new FakeViewPort; - assert.isUndefined(UIState.fromUserFriendlyString(model, vp, '1@1.2x-1')); - assert.throws(function() { - UIState.fromUserFriendlyString(model, vp, '1@1.2x0'); - }); - }); - - test('invalidSyntax', function() { - var model = new FakeModel; - var vp = new FakeViewPort; - assert.isUndefined(UIState.fromUserFriendlyString(model, vp, '5')); - assert.isUndefined(UIState.fromUserFriendlyString(model, vp, '5@x5')); - assert.isUndefined(UIState.fromUserFriendlyString(model, vp, 'ab@1.2x5')); - }); - - test('validString', function() { - var model = new FakeModel; - var vp = new FakeViewPort; - var str = '-50125.51231@1.2x1.12345'; - var uiState = UIState.fromUserFriendlyString(model, vp, str); - - assert.isDefined(uiState); - assert.equal(uiState.location.xWorld, -50125.51231); - assert.equal( - uiState.location.getContainingTrack(vp).eventContainer.stableId, - '1.2'); - assert.equal(uiState.scaleX, 1.12345); - - assert.equal(uiState.toUserFriendlyString(vp), str); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/ui_test.html b/chromium/third_party/catapult/tracing/tracing/ui/base/ui_test.html deleted file mode 100644 index 9db0b9f396f..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/ui_test.html +++ /dev/null @@ -1,245 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/base/ui.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var TestElement = tr.ui.b.define('div'); - TestElement.prototype = { - __proto__: HTMLDivElement.prototype, - - decorate: function() { - if (!this.decorateCallCount) - this.decorateCallCount = 0; - this.decorateCallCount++; - } - }; - - var Base = tr.ui.b.define('div'); - Base.prototype = { - __proto__: HTMLDivElement.prototype, - decorate: function() { - this.decoratedAsBase = true; - }, - set baseProperty(v) { - this.basePropertySet = v; - } - }; - - test('decorateOnceViaNew', function() { - var testElement = new TestElement(); - assert.equal(testElement.decorateCallCount, 1); - }); - - test('decorateOnceDirectly', function() { - var testElement = document.createElement('div'); - tr.ui.b.decorate(testElement, TestElement); - assert.equal(testElement.decorateCallCount, 1); - }); - - test('componentToString', function() { - assert.equal(Base.toString(), 'div'); - - var Sub = tr.ui.b.define('Sub', Base); - assert.equal(Sub.toString(), 'div::sub'); - - var SubSub = tr.ui.b.define('Marine', Sub); - assert.equal(SubSub.toString(), 'div::sub::marine'); - }); - - test('basicDefines', function() { - var baseInstance = new Base(); - assert.instanceOf(baseInstance, Base); - assert.isTrue(baseInstance.decoratedAsBase); - - assert.equal(baseInstance.constructor, Base); - assert.equal(baseInstance.constructor.toString(), 'div'); - - baseInstance.basePropertySet = 7; - assert.equal(baseInstance.basePropertySet, 7); - }); - - test('subclassing', function() { - var Sub = tr.ui.b.define('sub', Base); - Sub.prototype = { - __proto__: Base.prototype, - decorate: function() { - this.decoratedAsSub = true; - } - }; - - var subInstance = new Sub(); - assert.instanceOf(subInstance, Sub); - assert.isTrue(subInstance.decoratedAsSub); - - assert.instanceOf(subInstance, Base); - assert.isUndefined(subInstance.decoratedAsBase); - - assert.equal(subInstance.constructor, Sub); - assert.equal(subInstance.constructor.toString(), 'div::sub'); - - subInstance.baseProperty = true; - assert.isTrue(subInstance.basePropertySet); - }); - - var NoArgs = tr.ui.b.define('div'); - NoArgs.prototype = { - __proto__: HTMLDivElement.prototype, - decorate: function() { - this.noArgsDecorated_ = true; - }, - get noArgsDecorated() { - return this.noArgsDecorated_; - } - }; - - var Args = tr.ui.b.define('args', NoArgs); - Args.prototype = { - __proto__: NoArgs.prototype, - decorate: function(first) { - this.first_ = first; - this.argsDecorated_ = true; - }, - get first() { - return this.first_; - }, - get argsDecorated() { - return this.argsDecorated_; - } - }; - - var ArgsChild = tr.ui.b.define('args-child', Args); - ArgsChild.prototype = { - __proto__: Args.prototype, - decorate: function(_, second) { - this.second_ = second; - this.argsChildDecorated_ = true; - }, - get second() { - return this.second_; - }, - get decorated() { - return this.decorated_; - }, - get argsChildDecorated() { - return this.argsChildDecorated_ = true; - } - }; - - var ArgsDecoratingChild = tr.ui.b.define('args-decorating-child', Args); - ArgsDecoratingChild.prototype = { - __proto__: Args.prototype, - decorate: function(first, second) { - Args.prototype.decorate.call(this, first); - this.second_ = second; - this.argsDecoratingChildDecorated_ = true; - }, - get second() { - return this.second_; - }, - get decorated() { - return this.decorated_; - }, - get argsDecoratingChildDecorated() { - return this.argsChildDecorated_ = true; - } - }; - - test('decorate_noArguments', function() { - var noArgs; - assert.doesNotThrow(function() { - noArgs = new NoArgs(); - }); - assert.isTrue(noArgs.noArgsDecorated); - }); - - test('decorate_arguments', function() { - var args = new Args('this is first'); - assert.equal(args.first, 'this is first'); - assert.isTrue(args.argsDecorated); - assert.isUndefined(args.noArgsDecorated); - }); - - test('decorate_subclassArguments', function() { - var argsChild = new ArgsChild('this is first', 'and second'); - assert.isUndefined(argsChild.first); - assert.equal(argsChild.second, 'and second'); - - assert.isTrue(argsChild.argsChildDecorated); - assert.isUndefined(argsChild.argsDecorated); - assert.isUndefined(argsChild.noArgsDecorated); - }); - - test('decorate_subClassCallsParentDecorate', function() { - var argsDecoratingChild = new ArgsDecoratingChild( - 'this is first', 'and second'); - assert.equal(argsDecoratingChild.first, 'this is first'); - assert.equal(argsDecoratingChild.second, 'and second'); - assert.isTrue(argsDecoratingChild.argsDecoratingChildDecorated); - assert.isTrue(argsDecoratingChild.argsDecorated); - assert.isUndefined(argsDecoratingChild.noArgsDecorated); - }); - - test('defineWithNamespace', function() { - var svgNS = 'http://www.w3.org/2000/svg'; - var cls = tr.ui.b.define('svg', undefined, svgNS); - cls.prototype = { - __proto__: HTMLUnknownElement.prototype, - - decorate: function() { - this.setAttribute('width', 200); - this.setAttribute('height', 200); - this.setAttribute('viewPort', '0 0 200 200'); - var rectEl = document.createElementNS(svgNS, 'rect'); - rectEl.setAttribute('x', 10); - rectEl.setAttribute('y', 10); - rectEl.setAttribute('width', 180); - rectEl.setAttribute('height', 180); - this.appendChild(rectEl); - } - }; - var el = new cls(); - assert.equal(el.tagName, 'svg'); - assert.equal(el.namespaceURI, svgNS); - this.addHTMLOutput(el); - }); - - test('defineSubclassWithNamespace', function() { - var svgNS = 'http://www.w3.org/2000/svg'; - var cls = tr.ui.b.define('svg', undefined, svgNS); - cls.prototype = { - __proto__: HTMLUnknownElement.prototype, - - decorate: function() { - this.setAttribute('width', 200); - this.setAttribute('height', 200); - this.setAttribute('viewPort', '0 0 200 200'); - var rectEl = document.createElementNS(svgNS, 'rect'); - rectEl.setAttribute('x', 10); - rectEl.setAttribute('y', 10); - rectEl.setAttribute('width', 180); - rectEl.setAttribute('height', 180); - this.appendChild(rectEl); - } - }; - - var subCls = tr.ui.b.define('sub', cls); - subCls.prototype = { - __proto__: cls.prototype - }; - assert.equal(subCls.toString(), 'svg::sub'); - - var el = new subCls(); - this.addHTMLOutput(el); - assert.equal(el.tagName, 'svg'); - assert.equal(el.namespaceURI, svgNS); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/utils.html b/chromium/third_party/catapult/tracing/tracing/ui/base/utils.html deleted file mode 100644 index a205d1db1b7..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/utils.html +++ /dev/null @@ -1,68 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/rect.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.b', function() { - function instantiateTemplate(selector, doc) { - doc = doc || document; - var el = doc.querySelector(selector); - if (!el) - throw new Error('Element not found'); - return el.createInstance(); - } - - function windowRectForElement(element) { - var position = [element.offsetLeft, element.offsetTop]; - var size = [element.offsetWidth, element.offsetHeight]; - var node = element.offsetParent; - while (node) { - position[0] += node.offsetLeft; - position[1] += node.offsetTop; - node = node.offsetParent; - } - return tr.b.Rect.fromXYWH(position[0], position[1], size[0], size[1]); - } - - function scrollIntoViewIfNeeded(el) { - var pr = el.parentElement.getBoundingClientRect(); - var cr = el.getBoundingClientRect(); - if (cr.top < pr.top) { - el.scrollIntoView(true); - } else if (cr.bottom > pr.bottom) { - el.scrollIntoView(false); - } - } - - function extractUrlString(url) { - var extracted = url.replace(/url\((.*)\)/, '$1'); - - // In newer versions of chrome, the contents of url() will be quoted. Remove - // these quotes as well. If quotes are not present, match will fail and this - // becomes a no-op. - extracted = extracted.replace(/\"(.*)\"/, '$1'); - - return extracted; - } - - function toThreeDigitLocaleString(value) { - return value.toLocaleString( - undefined, {minimumFractionDigits: 3, maximumFractionDigits: 3}); - } - - return { - toThreeDigitLocaleString: toThreeDigitLocaleString, - instantiateTemplate: instantiateTemplate, - windowRectForElement: windowRectForElement, - scrollIntoViewIfNeeded: scrollIntoViewIfNeeded, - extractUrlString: extractUrlString - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/utils_test.html b/chromium/third_party/catapult/tracing/tracing/ui/base/utils_test.html deleted file mode 100644 index 7e82132fe8d..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/utils_test.html +++ /dev/null @@ -1,76 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/base/utils.html"> - -<polymer-element name="instantiate-template-polymer-element-test"> - <template></template> - <script> - 'use strict'; - Polymer({ - testProperty: 'Test' - }); - </script> -</polymer-element> - -<template id="instantiate-template-polymer-test"> - <instantiate-template-polymer-element-test> - </instantiate-template-polymer-element-test> -</template> - -<template id="multiple-template-test"> - <template> - <instantiate-template-polymer-element-test> - </instantiate-template-polymer-element-test> - <span test-attribute='TestAttribute'>Foo</span> - </template> - <instantiate-template-polymer-element-test> - </instantiate-template-polymer-element-test> -</template> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var THIS_DOC = document._currentScript.ownerDocument; - - test('instantiateTemplatePolymer', function() { - var e = tr.ui.b.instantiateTemplate( - '#instantiate-template-polymer-test', - THIS_DOC); - assert.equal(e.children.length, 1); - assert.equal(e.children[0].testProperty, 'Test'); - }); - - test('instantiateTemplateMultipleTemplates', function() { - var outerElement = tr.ui.b.instantiateTemplate( - '#multiple-template-test', - THIS_DOC); - assert.equal(outerElement.children.length, 2); - assert.equal(outerElement.children[1].testProperty, 'Test'); - - // Make sure we can still instantiate inner templates, if we need them. - var innerElement = outerElement.children[0].createInstance(); - assert.equal(innerElement.children.length, 2); - assert.equal(innerElement.children[0].testProperty, 'Test'); - assert.equal( - innerElement.children[1].getAttribute('test-attribute'), - 'TestAttribute'); - assert.equal(innerElement.children[1].textContent, 'Foo'); - }); - - test('extractUrlStringAcceptsBothVersions', function() { - var oldStyleUrl = 'url(content)'; - var newStyleUrl = 'url("content")'; - var expectedResult = 'content'; - - assert.equal(tr.ui.b.extractUrlString(oldStyleUrl), expectedResult); - assert.equal(tr.ui.b.extractUrlString(newStyleUrl), expectedResult); - }); -}); -</script> - diff --git a/chromium/third_party/catapult/tracing/tracing/ui/brushing_state.html b/chromium/third_party/catapult/tracing/tracing/ui/brushing_state.html deleted file mode 100644 index 9996e4db952..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/brushing_state.html +++ /dev/null @@ -1,218 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/guid.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/model/selection_state.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.b', function() { - var EventSet = tr.model.EventSet; - var SelectionState = tr.model.SelectionState; - - function BrushingState() { - this.guid_ = tr.b.GUID.allocateSimple(); - this.selection_ = new EventSet(); - this.findMatches_ = new EventSet(); - this.analysisViewRelatedEvents_ = new EventSet(); - this.analysisLinkHoveredEvents_ = new EventSet(); - this.appliedToModel_ = undefined; - this.viewSpecificBrushingStates_ = {}; - } - BrushingState.prototype = { - get guid() { - return this.guid_; - }, - - clone: function() { - var that = new BrushingState(); - that.selection_ = this.selection_; - that.findMatches_ = this.findMatches_; - that.analysisViewRelatedEvents_ = this.analysisViewRelatedEvents_; - that.analysisLinkHoveredEvents_ = this.analysisLinkHoveredEvents_; - that.viewSpecificBrushingStates_ = this.viewSpecificBrushingStates_; - - return that; - }, - - equals: function(that) { - if (!this.selection_.equals(that.selection_)) - return false; - if (!this.findMatches_.equals(that.findMatches_)) - return false; - if (!this.analysisViewRelatedEvents_.equals( - that.analysisViewRelatedEvents_)) { - return false; - } - if (!this.analysisLinkHoveredEvents_.equals( - that.analysisLinkHoveredEvents_)) { - return false; - } - // We currently do not take the view-specific brushing states into - // account. If we did, every change of the view-specific brushing state - // of any view would cause a redraw of the whole UI (see the - // BrushingStateController.currentBrushingState setter). - return true; - }, - - get selectionOfInterest() { - if (this.selection_.length) - return this.selection_; - - if (this.highlight_.length) - return this.highlight_; - - if (this.analysisViewRelatedEvents_.length) - return this.analysisViewRelatedEvents_; - - if (this.analysisLinkHoveredEvents_.length) - return this.analysisLinkHoveredEvents_; - - return this.selection_; - }, - - get selection() { - return this.selection_; - }, - - set selection(selection) { - if (this.appliedToModel_) - throw new Error('Cannot mutate this state right now'); - if (selection === undefined) - selection = new EventSet(); - this.selection_ = selection; - }, - - get findMatches() { - return this.findMatches_; - }, - - set findMatches(findMatches) { - if (this.appliedToModel_) - throw new Error('Cannot mutate this state right now'); - if (findMatches === undefined) - findMatches = new EventSet(); - this.findMatches_ = findMatches; - }, - - get analysisViewRelatedEvents() { - return this.analysisViewRelatedEvents_; - }, - - set analysisViewRelatedEvents(analysisViewRelatedEvents) { - if (this.appliedToModel_) - throw new Error('Cannot mutate this state right now'); - if (analysisViewRelatedEvents === undefined) - analysisViewRelatedEvents = new EventSet(); - this.analysisViewRelatedEvents_ = analysisViewRelatedEvents; - }, - - get analysisLinkHoveredEvents() { - return this.analysisLinkHoveredEvents_; - }, - - set analysisLinkHoveredEvents(analysisLinkHoveredEvents) { - if (this.appliedToModel_) - throw new Error('Cannot mutate this state right now'); - if (analysisLinkHoveredEvents === undefined) - analysisLinkHoveredEvents = new EventSet(); - this.analysisLinkHoveredEvents_ = analysisLinkHoveredEvents; - }, - - get isAppliedToModel() { - return this.appliedToModel_ !== undefined; - }, - - get viewSpecificBrushingStates() { - return this.viewSpecificBrushingStates_; - }, - - set viewSpecificBrushingStates(viewSpecificBrushingStates) { - this.viewSpecificBrushingStates_ = viewSpecificBrushingStates; - }, - - get causesDimming_() { - return this.findMatches_.length > 0 || - this.analysisViewRelatedEvents_.length > 0; - }, - - get brightenedEvents_() { - var brightenedEvents = new EventSet(); - brightenedEvents.addEventSet(this.selection_); - brightenedEvents.addEventSet(this.analysisLinkHoveredEvents_); - return brightenedEvents; - }, - - applyToModelSelectionState: function(model) { - this.appliedToModel_ = model; - - if (!this.causesDimming_) { - this.brightenedEvents_.forEach(function(e) { - var score; - score = 0; - if (this.selection_.contains(e)) - score++; - if (this.analysisLinkHoveredEvents_.contains(e)) - score++; - e.selectionState = SelectionState.getFromBrighteningLevel(score); - }, this); - return; - } - - var brightenedEvents = this.brightenedEvents_; - for (var e of model.getDescendantEvents()) { - var score; - if (brightenedEvents.contains(e)) { - score = 0; - if (this.selection_.contains(e)) - score++; - if (this.analysisLinkHoveredEvents_.contains(e)) - score++; - e.selectionState = SelectionState.getFromBrighteningLevel(score); - } else { - score = 0; - if (this.findMatches_.contains(e)) - score++; - if (this.analysisViewRelatedEvents_.contains(e)) - score++; - e.selectionState = SelectionState.getFromDimmingLevel(score); - } - } - }, - - transferModelOwnershipToClone: function(that) { - if (!this.appliedToModel_) - throw new Error('Not applied'); - // Assumes this.equals(that). - that.appliedToModel_ = this.appliedToModel_; - this.appliedToModel_ = undefined; - }, - - unapplyFromModelSelectionState: function() { - if (!this.appliedToModel_) - throw new Error('Not applied'); - var model = this.appliedToModel_; - this.appliedToModel_ = undefined; - - if (!this.causesDimming_) { - for (var e of this.brightenedEvents_) - e.selectionState = SelectionState.NONE; - return; - } - - for (var e of model.getDescendantEvents()) - e.selectionState = SelectionState.NONE; - } - }; - - return { - BrushingState: BrushingState - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/brushing_state_controller.html b/chromium/third_party/catapult/tracing/tracing/ui/brushing_state_controller.html deleted file mode 100644 index c3b9e83952b..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/brushing_state_controller.html +++ /dev/null @@ -1,305 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/event_target.html"> -<link rel="import" href="/tracing/base/task.html"> -<link rel="import" href="/tracing/ui/brushing_state.html"> -<link rel="import" href="/tracing/ui/timeline_viewport.html"> -<link rel="import" href="/tracing/ui/base/ui_state.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/model/selection_state.html"> - -<script> -'use strict'; - -tr.exportTo('tr.c', function() { - var BrushingState = tr.ui.b.BrushingState; - var EventSet = tr.model.EventSet; - var SelectionState = tr.model.SelectionState; - var Viewport = tr.ui.TimelineViewport; - - function BrushingStateController(timelineView) { - tr.b.EventTarget.call(this); - - this.timelineView_ = timelineView; - this.currentBrushingState_ = new BrushingState(); - - this.onPopState_ = this.onPopState_.bind(this); - this.historyEnabled_ = false; - this.selections_ = {}; - } - - BrushingStateController.prototype = { - __proto__: tr.b.EventTarget.prototype, - - dispatchChangeEvent_: function() { - var e = new tr.b.Event('change', false, false); - this.dispatchEvent(e); - }, - - get model() { - if (!this.timelineView_) - return undefined; - return this.timelineView_.model; - }, - - get trackView() { - if (!this.timelineView_) - return undefined; - return this.timelineView_.trackView; - }, - - get viewport() { - if (!this.timelineView_) - return undefined; - if (!this.timelineView_.trackView) - return undefined; - return this.timelineView_.trackView.viewport; - }, - - /* History system */ - get historyEnabled() { - return this.historyEnabled_; - }, - - set historyEnabled(historyEnabled) { - this.historyEnabled_ = !!historyEnabled; - if (historyEnabled) - window.addEventListener('popstate', this.onPopState_); - else - window.removeEventListener('popstate', this.onPopState_); - }, - - modelWillChange: function() { - if (this.currentBrushingState_.isAppliedToModel) - this.currentBrushingState_.unapplyFromModelSelectionState(); - }, - - modelDidChange: function() { - this.selections_ = {}; - - this.currentBrushingState_ = new BrushingState(); - this.currentBrushingState_.applyToModelSelectionState(this.model); - - var e = new tr.b.Event('model-changed', false, false); - this.dispatchEvent(e); - - this.dispatchChangeEvent_(); - }, - - onUserInitiatedSelectionChange_: function() { - var selection = this.selection; - if (this.historyEnabled) { - // Save the selection so that when back button is pressed, - // it could be retrieved. - this.selections_[selection.guid] = selection; - var state = { - selection_guid: selection.guid - }; - - window.history.pushState(state, document.title); - } - }, - - onPopState_: function(e) { - if (e.state === null) - return; - - var selection = this.selections_[e.state.selection_guid]; - if (selection) { - var newState = this.currentBrushingState_.clone(); - newState.selection = selection; - this.currentBrushingState = newState; - } - e.stopPropagation(); - }, - - get selection() { - return this.currentBrushingState_.selection; - }, - get findMatches() { - return this.currentBrushingState_.findMatches; - }, - - get selectionOfInterest() { - return this.currentBrushingState_.selectionOfInterest; - }, - - get currentBrushingState() { - return this.currentBrushingState_; - }, - - set currentBrushingState(newBrushingState) { - if (newBrushingState.isAppliedToModel) - throw new Error('Cannot apply this state, it is applied'); - - // This function uses value-equality on the states so that state can - // changed to a clone of itself without causing a change event, while - // still having the actual state object change to the new clone. - var hasValueChanged = !this.currentBrushingState_.equals( - newBrushingState); - - if (newBrushingState !== this.currentBrushingState_ && !hasValueChanged) { - if (this.currentBrushingState_.isAppliedToModel) { - this.currentBrushingState_.transferModelOwnershipToClone( - newBrushingState); - } - this.currentBrushingState_ = newBrushingState; - return; - } - - if (this.currentBrushingState_.isAppliedToModel) - this.currentBrushingState_.unapplyFromModelSelectionState(); - - this.currentBrushingState_ = newBrushingState; - - if (this.model) - this.currentBrushingState_.applyToModelSelectionState(this.model); - - this.dispatchChangeEvent_(); - }, - - /** - * @param {Filter} filter The filter to use for finding matches. - * @param {Selection} selection The selection to add matches to. - * @return {Task} which performs the filtering. - */ - addAllEventsMatchingFilterToSelectionAsTask: function(filter, selection) { - var timelineView = this.timelineView_.trackView; - if (!timelineView) - return new tr.b.Task(); - return timelineView.addAllEventsMatchingFilterToSelectionAsTask( - filter, selection); - }, - - findTextChangedTo: function(allPossibleMatches) { - var newBrushingState = this.currentBrushingState_.clone(); - newBrushingState.findMatches = allPossibleMatches; - this.currentBrushingState = newBrushingState; - }, - - findFocusChangedTo: function(currentFocus) { - var newBrushingState = this.currentBrushingState_.clone(); - newBrushingState.selection = currentFocus; - this.currentBrushingState = newBrushingState; - - this.onUserInitiatedSelectionChange_(); - }, - - findTextCleared: function() { - if (this.xNavStringMarker_ !== undefined) { - this.model.removeAnnotation(this.xNavStringMarker_); - this.xNavStringMarker_ = undefined; - } - - if (this.guideLineAnnotation_ !== undefined) { - this.model.removeAnnotation(this.guideLineAnnotation_); - this.guideLineAnnotation_ = undefined; - } - - var newBrushingState = this.currentBrushingState_.clone(); - newBrushingState.selection = new EventSet(); - newBrushingState.findMatches = new EventSet(); - this.currentBrushingState = newBrushingState; - - this.onUserInitiatedSelectionChange_(); - }, - - uiStateFromString: function(string) { - return tr.ui.b.UIState.fromUserFriendlyString( - this.model, this.viewport, string); - }, - - navToPosition: function(uiState, showNavLine) { - this.trackView.navToPosition(uiState, showNavLine); - }, - - changeSelectionFromTimeline: function(selection) { - var newBrushingState = this.currentBrushingState_.clone(); - newBrushingState.selection = selection; - newBrushingState.findMatches = new EventSet(); - this.currentBrushingState = newBrushingState; - - this.onUserInitiatedSelectionChange_(); - }, - - showScriptControlSelection: function(selection) { - var newBrushingState = this.currentBrushingState_.clone(); - newBrushingState.selection = selection; - newBrushingState.findMatches = new EventSet(); - this.currentBrushingState = newBrushingState; - }, - - changeSelectionFromRequestSelectionChangeEvent: function(selection) { - var newBrushingState = this.currentBrushingState_.clone(); - newBrushingState.selection = selection; - newBrushingState.findMatches = new EventSet(); - this.currentBrushingState = newBrushingState; - - this.onUserInitiatedSelectionChange_(); - }, - - changeAnalysisViewRelatedEvents: function(eventSet) { - var newBrushingState = this.currentBrushingState_.clone(); - newBrushingState.analysisViewRelatedEvents = eventSet; - this.currentBrushingState = newBrushingState; - }, - - changeAnalysisLinkHoveredEvents: function(eventSet) { - var newBrushingState = this.currentBrushingState_.clone(); - newBrushingState.analysisLinkHoveredEvents = eventSet; - this.currentBrushingState = newBrushingState; - }, - - getViewSpecificBrushingState: function(viewId) { - return this.currentBrushingState.viewSpecificBrushingStates[viewId]; - }, - - changeViewSpecificBrushingState: function(viewId, newState) { - var oldStates = this.currentBrushingState_.viewSpecificBrushingStates; - var newStates = {}; - for (var id in oldStates) - newStates[id] = oldStates[id]; - if (newState === undefined) - delete newStates[viewId]; - else - newStates[viewId] = newState; - - var newBrushingState = this.currentBrushingState_.clone(); - newBrushingState.viewSpecificBrushingStates = newStates; - this.currentBrushingState = newBrushingState; - } - }; - - BrushingStateController.getControllerForElement = function(element) { - if (tr.isHeadless) - throw new Error('Unsupported'); - var currentElement = element; - while (currentElement) { - if (currentElement.brushingStateController) - return currentElement.brushingStateController; - - // Walk up the DOM. - if (currentElement.parentElement) { - currentElement = currentElement.parentElement; - continue; - } - - // Possibly inside a shadow DOM. - var currentNode = currentElement; - while (currentNode.parentNode) - currentNode = currentNode.parentNode; - currentElement = currentNode.host; - } - return undefined; - }; - - return { - BrushingStateController: BrushingStateController - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/brushing_state_controller_test.html b/chromium/third_party/catapult/tracing/tracing/ui/brushing_state_controller_test.html deleted file mode 100644 index 1f44f5962b6..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/brushing_state_controller_test.html +++ /dev/null @@ -1,204 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/task.html"> -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/extras/importer/trace_event_importer.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/ui/brushing_state_controller.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var newSliceEx = tr.c.TestUtils.newSliceEx; - - var EventSet = tr.model.EventSet; - var SelectionState = tr.model.SelectionState; - var Task = tr.b.Task; - - function newSimpleFakeTimelineView() { - var m = tr.c.TestUtils.newModel(function(m) { - m.p1 = m.getOrCreateProcess(1); - m.t2 = m.p1.getOrCreateThread(2); - - m.sA = m.t2.sliceGroup.pushSlice( - newSliceEx({title: 'a', start: 0, end: 5})); - m.sB = m.t2.sliceGroup.pushSlice( - newSliceEx({title: 'b', start: 10, end: 15})); - m.sC = m.t2.sliceGroup.pushSlice( - newSliceEx({title: 'c', start: 20, end: 20})); - }); - - // Fake timeline view. So fake its ... just wow. - var timelineView = { - model: m - }; - return timelineView; - } - - function doesCauseChangeToFire(brushingStateController, cb, opt_this) { - var didFire = false; - function didFireCb() { - didFire = true; - }; - brushingStateController.addEventListener('change', didFireCb); - cb.call(opt_this); - brushingStateController.removeEventListener('change', didFireCb); - return didFire; - } - - test('simpleStateChanges', function() { - var timelineView = newSimpleFakeTimelineView(); - var brushingStateController = - new tr.c.BrushingStateController(timelineView); - var m = timelineView.model; - - // Setting empty brushing state doesn't cause change event. This behavior - // is triggered when the user tries to search for something when no trace - // has been loaded yet in chrome://tracing. - var bs0 = new tr.ui.b.BrushingState(); - assert.isFalse(doesCauseChangeToFire( - brushingStateController, - function() { - brushingStateController.currentBrushingState = bs0; - })); - assert.isFalse(bs0.isAppliedToModel); - assert.strictEqual(brushingStateController.currentBrushingState, bs0); - - // Setting causes change. - var bs1 = new tr.ui.b.BrushingState(); - bs1.selection = new EventSet([m.sA]); - assert.isTrue(doesCauseChangeToFire( - brushingStateController, - function() { - brushingStateController.currentBrushingState = bs1; - })); - assert.isTrue(bs1.isAppliedToModel); - - // Setting value equivalent doesn't cause change event. - var bs2 = bs1.clone(); - assert.isFalse(doesCauseChangeToFire( - brushingStateController, - function() { - brushingStateController.currentBrushingState = bs2; - })); - assert.equal(brushingStateController.currentBrushingState, bs2); - assert.isTrue( - brushingStateController.currentBrushingState.isAppliedToModel); - - // Setting to something different unapplies the old bs. - var bs3 = new tr.ui.b.BrushingState(); - bs3.findMatches = new EventSet([m.sA, m.sB]); - brushingStateController.currentBrushingState = bs3; - assert.isTrue(bs3.isAppliedToModel); - assert.isFalse(bs2.isAppliedToModel); - }); - - test('modelCausesStateChange', function() { - var timelineView = newSimpleFakeTimelineView(); - var brushingStateController = - new tr.c.BrushingStateController(timelineView); - - var m1 = timelineView.model; - - var bs1 = new tr.ui.b.BrushingState(); - bs1.selection = new EventSet([m1.sA]); - - // Change the model. - var m2 = tr.c.TestUtils.newModel(function(m) { - m.p1 = m.getOrCreateProcess(1); - m.t2 = m.p1.getOrCreateThread(2); - - m.sA = m.t2.sliceGroup.pushSlice( - newSliceEx({title: 'a', start: 0, end: 5})); - }); - assert.isTrue(doesCauseChangeToFire( - brushingStateController, - function() { - brushingStateController.modelWillChange(); - timelineView.model = m2; - brushingStateController.modelDidChange(); - })); - assert.equal( - brushingStateController.currentBrushingState.selection.length, 0); - }); - - function addChildDiv(element) { - var child = element.ownerDocument.createElement('div'); - element.appendChild(child); - return child; - } - - function addShadowChildDiv(element) { - var shadowRoot = element.createShadowRoot(); - return addChildDiv(shadowRoot); - } - - if (!tr.isHeadless) { - test('getControllerForElement_none', function() { - var element = document.createElement('div'); - - assert.isUndefined( - tr.c.BrushingStateController.getControllerForElement(element)); - }); - - test('getControllerForElement_self', function() { - var controller = new tr.c.BrushingStateController(undefined); - var element = document.createElement('div'); - element.brushingStateController = controller; - - assert.strictEqual( - tr.c.BrushingStateController.getControllerForElement(element), - controller); - }); - - test('getControllerForElement_ancestor', function() { - var controller = new tr.c.BrushingStateController(undefined); - var ancestor = document.createElement('div'); - ancestor.brushingStateController = controller; - - var element = addChildDiv(addChildDiv(addChildDiv(ancestor))); - assert.strictEqual( - tr.c.BrushingStateController.getControllerForElement(element), - controller); - }); - - test('getControllerForElement_host', function() { - var controller = new tr.c.BrushingStateController(undefined); - var host = document.createElement('div'); - host.brushingStateController = controller; - - var element = addShadowChildDiv(host); - assert.strictEqual( - tr.c.BrushingStateController.getControllerForElement(element), - controller); - }); - - test('getControllerForElement_hierarchy', function() { - var controller1 = new tr.c.BrushingStateController(undefined); - var root = document.createElement('div'); - root.brushingStateController = controller1; - - var controller2 = new tr.c.BrushingStateController(undefined); - var child = addChildDiv(root); - child.brushingStateController = controller2; - - var controller3 = new tr.c.BrushingStateController(undefined); - var shadowChild = addShadowChildDiv(child); - shadowChild.brushingStateController = controller3; - - var element = addChildDiv(addChildDiv(addShadowChildDiv( - addChildDiv(addChildDiv(addShadowChildDiv( - addChildDiv(shadowChild))))))); - assert.strictEqual( - tr.c.BrushingStateController.getControllerForElement(element), - controller3); - }); - } -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/brushing_state_test.html b/chromium/third_party/catapult/tracing/tracing/ui/brushing_state_test.html deleted file mode 100644 index d0480738bd7..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/brushing_state_test.html +++ /dev/null @@ -1,123 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/task.html"> -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/extras/importer/trace_event_importer.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/ui/timeline_view.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var newSliceEx = tr.c.TestUtils.newSliceEx; - - var EventSet = tr.model.EventSet; - var SelectionState = tr.model.SelectionState; - - function newSimpleModel() { - return tr.c.TestUtils.newModel(function(m) { - m.p1 = m.getOrCreateProcess(1); - m.t2 = m.p1.getOrCreateThread(2); - - m.sA = m.t2.sliceGroup.pushSlice( - newSliceEx({title: 'a', start: 0, end: 5})); - m.sB = m.t2.sliceGroup.pushSlice( - newSliceEx({title: 'b', start: 10, end: 15})); - m.sC = m.t2.sliceGroup.pushSlice( - newSliceEx({title: 'c', start: 20, end: 20})); - }); - } - - test('brushingStateSimple', function() { - var m = newSimpleModel(); - - var bs = new tr.ui.b.BrushingState(); - bs.selection = new EventSet([m.sA]); - - bs.applyToModelSelectionState(m); - assert.equal(m.sA.selectionState, SelectionState.SELECTED); - bs.unapplyFromModelSelectionState(); - assert.equal(m.sA.selectionState, SelectionState.NONE); - }); - - - test('selectionAndAnalysisHover', function() { - var m = newSimpleModel(); - - var bs = new tr.ui.b.BrushingState(); - bs.selection = new EventSet([m.sA]); - bs.analysisLinkHoveredEvents = new EventSet([m.sA, m.sB]); - - bs.applyToModelSelectionState(m); - assert.equal(m.sA.selectionState, SelectionState.BRIGHTENED1); - assert.equal(m.sB.selectionState, SelectionState.BRIGHTENED0); - bs.unapplyFromModelSelectionState(); - assert.equal(m.sA.selectionState, SelectionState.NONE); - }); - - test('brushingStateWithFindMatches', function() { - var m = newSimpleModel(); - - var bs = new tr.ui.b.BrushingState(); - bs.selection = new EventSet([m.sA]); - bs.findMatches = new EventSet([m.sA, m.sB]); - - bs.applyToModelSelectionState(m); - assert.equal(m.sA.selectionState, SelectionState.BRIGHTENED0); - assert.equal(m.sB.selectionState, SelectionState.DIMMED1); - assert.equal(m.sC.selectionState, SelectionState.DIMMED0); - bs.unapplyFromModelSelectionState(); - assert.equal(m.sA.selectionState, SelectionState.NONE); - assert.equal(m.sB.selectionState, SelectionState.NONE); - assert.equal(m.sC.selectionState, SelectionState.NONE); - }); - - test('brushingTransfer', function() { - var m = newSimpleModel(); - - var bs = new tr.ui.b.BrushingState(); - bs.selection = new EventSet([m.sA]); - - var bs2 = bs.clone(); - - bs.applyToModelSelectionState(m); - assert.equal(m.sA.selectionState, SelectionState.SELECTED); - bs.transferModelOwnershipToClone(bs2); - assert.isFalse(bs.isAppliedToModel); - assert.isTrue(bs2.isAppliedToModel); - - bs2.unapplyFromModelSelectionState(); - assert.equal(m.sA.selectionState, SelectionState.NONE); - assert.equal(m.sB.selectionState, SelectionState.NONE); - assert.equal(m.sC.selectionState, SelectionState.NONE); - }); - - test('equality', function() { - var m = newSimpleModel(); - - var bs = new tr.ui.b.BrushingState(); - bs.selection = new EventSet([m.sA]); - bs.findMatches = new EventSet([m.sB]); - bs.applyToModelSelectionState = new EventSet([m.sC]); - - // Clone equality, but with shared refs. - var bs2 = bs.clone(); - assert.isTrue(bs.equals(bs2)); - - // Same value, different refs. - bs2.selection = new EventSet([m.sA]); - assert.isTrue(bs.equals(bs2)); - - // Different actual values. - bs2.selection = new EventSet([m.sB]); - assert.isFalse(bs.equals(bs2)); - }); - -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/about_tracing/about_tracing.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/about_tracing/about_tracing.html deleted file mode 100644 index 1df923b4d42..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/about_tracing/about_tracing.html +++ /dev/null @@ -1,24 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> -<link rel="stylesheet" href="/tracing/ui/extras/about_tracing/common.css"> -<link rel="import" href="/tracing/ui/extras/about_tracing/profiling_view.html"> -<link rel="import" href="/tracing/ui/extras/full_config.html"> -<script> -'use strict'; - -tr.exportTo('tr.ui.e.about_tracing', function() { - window.profilingView = undefined; // Made global for debugging purposes only. - - document.addEventListener('DOMContentLoaded', function() { - window.profilingView = new tr.ui.e.about_tracing.ProfilingView(); - profilingView.timelineView.globalMode = true; - document.body.appendChild(profilingView); - }); - - return {}; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/about_tracing/common.css b/chromium/third_party/catapult/tracing/tracing/ui/extras/about_tracing/common.css deleted file mode 100644 index 1ffb5f72e74..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/about_tracing/common.css +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright (c) 2012 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ -html, -body { - height: 100%; -} - -body { - -webkit-flex-direction: column; - display: -webkit-flex; - margin: 0; - padding: 0; -} - -body > x-profiling-view { - -webkit-flex: 1 1 auto; - min-height: 0; -} - -body > x-profiling-view > x-timeline-view:focus { - outline: 0 -} - diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/about_tracing/inspector_connection.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/about_tracing/inspector_connection.html deleted file mode 100644 index bc2ba6e472c..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/about_tracing/inspector_connection.html +++ /dev/null @@ -1,125 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> -<link rel="import" href="/tracing/base/base.html"> -<script> - -'use strict'; - -/** - * Contains connection code that inspector's embedding framework calls on - * tracing, and that tracing can use to talk to inspector. - */ -tr.exportTo('tr.ui.e.about_tracing', function() { - // Interface used by inspector when it hands data to us from the backend. - window.DevToolsAPI = { - setToolbarColors: function() { }, - addExtensions: function() { }, - setInspectedPageId: function() { }, - - dispatchMessage: function(payload) { - throw new Error('Should have been patched by InspectorConnection'); - } - }; - // Temporary until inspector backend switches to DevToolsAPI. - window.InspectorFrontendAPI = window.DevToolsAPI; - - /** - * @constructor - */ - function InspectorConnection() { - if (InspectorConnection.instance) - throw new Error('Singleton'); - - this.nextRequestId_ = 1; - this.pendingRequestResolversId_ = {}; - - this.notificationListenersByMethodName_ = {}; - DevToolsAPI.dispatchMessage = this.dispatchMessage_.bind(this); - } - - InspectorConnection.prototype = { - req: function(method, params) { - var id = this.nextRequestId_++; - var msg = JSON.stringify({ - id: id, - method: method, - params: params - }); - var devtoolsMessageStr = JSON.stringify( - {'id': id, 'method': 'dispatchProtocolMessage', 'params': [msg]}); - DevToolsHost.sendMessageToEmbedder(devtoolsMessageStr); - - return new Promise(function(resolve, reject) { - this.pendingRequestResolversId_[id] = { - resolve: resolve, - reject: reject - }; - }.bind(this)); - }, - - setNotificationListener: function(method, listener) { - this.notificationListenersByMethodName_[method] = listener; - }, - - dispatchMessage_: function(payload) { - var isStringPayload = typeof payload === 'string'; - // Special handling for Tracing.dataCollected because it is high - // bandwidth. - var isDataCollectedMessage = isStringPayload ? - payload.indexOf('"method": "Tracing.dataCollected"') !== -1 : - payload.method === 'Tracing.dataCollected'; - if (isDataCollectedMessage) { - var listener = this.notificationListenersByMethodName_[ - 'Tracing.dataCollected']; - if (listener) { - // FIXME(loislo): trace viewer should be able to process - // raw message object because string based version a few times - // slower on the browser side. - // see https://codereview.chromium.org/784513002. - listener(isStringPayload ? payload : JSON.stringify(payload)); - return; - } - } - - var message = isStringPayload ? JSON.parse(payload) : payload; - if (message.id) { - var resolver = this.pendingRequestResolversId_[message.id]; - if (resolver === undefined) { - console.log('Unrecognized ack', message); - return; - } - if (message.error) { - resolver.reject(message.error); - return; - } - resolver.resolve(message.result); - return; - } - - if (message['method']) { - var listener = this.notificationListenersByMethodName_[message.method]; - if (listener === undefined) { - console.log('Unhandled ', message.method); - return; - } - listener(message.params); - return; - } - console.log('Unknown dispatchMessage: ', payload); - } - }; - - if (window.DevToolsHost) - InspectorConnection.instance = new InspectorConnection(); - else - InspectorConnection.instance = undefined; - - return { - InspectorConnection: InspectorConnection - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/about_tracing/inspector_tracing_controller_client.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/about_tracing/inspector_tracing_controller_client.html deleted file mode 100644 index 86c3e596054..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/about_tracing/inspector_tracing_controller_client.html +++ /dev/null @@ -1,187 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" - href="/tracing/ui/extras/about_tracing/tracing_controller_client.html"> -<link rel="import" href="/tracing/ui/extras/about_tracing/inspector_connection.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.e.about_tracing', function() { - function createResolvedPromise(data) { - var promise = new Promise(function(resolve, reject) { - if (data) - resolve(data); - else - resolve(); - }); - return promise; - } - - function appendTraceChunksTo(chunks, messageString) { - if (typeof messageString !== 'string') - throw new Error('Invalid data'); - var re = /"params":\s*\{\s*"value":\s*\[([^]+)\]\s*\}\s*\}/; - var m = re.exec(messageString); - if (!m) - throw new Error('Malformed response'); - - if (chunks.length > 1) - chunks.push(','); - chunks.push(m[1]); - } - - /** - * Controls tracing using the inspector's FrontendAgentHost APIs. - * - * @constructor - */ - function InspectorTracingControllerClient() { - this.recording_ = false; - this.bufferUsage_ = 0; - this.conn_ = tr.ui.e.about_tracing.InspectorConnection.instance; - this.currentTraceTextChunks_ = undefined; - } - - InspectorTracingControllerClient.prototype = { - __proto__: tr.ui.e.about_tracing.TracingControllerClient.prototype, - - beginMonitoring: function(monitoringOptions) { - throw new Error('Not implemented'); - }, - - endMonitoring: function() { - throw new Error('Not implemented'); - }, - - captureMonitoring: function() { - throw new Error('Not implemented'); - }, - - getMonitoringStatus: function() { - return createResolvedPromise({ - isMonitoring: false, - categoryFilter: '', - useSystemTracing: false, - useContinuousTracing: false, - useSampling: false - }); - }, - - getCategories: function() { - var res = this.conn_.req('Tracing.getCategories', {}); - return res.then(function(result) { - return result.categories; - }, function(err) { - return []; - }); - }, - - beginRecording: function(recordingOptions) { - if (this.recording_) - throw new Error('Already recording'); - this.recording_ = 'starting'; - var res = this.conn_.req( - 'Tracing.start', - { - categories: recordingOptions.categoryFilter, - options: - [recordingOptions.tracingRecordMode, - (recordingOptions.useSampling ? 'enable-sampling' : '') - ].join(','), - bufferUsageReportingInterval: 1000 - }); - res = res.then( - function ok() { - this.conn_.setNotificationListener( - 'Tracing.bufferUsage', - this.onBufferUsageUpdateFromInspector_.bind(this)); - this.recording_ = true; - }.bind(this), - function error() { - this.recording_ = false; - }.bind(this)); - return res; - }, - - onBufferUsageUpdateFromInspector_: function(params) { - this.bufferUsage_ = params.value || params.percentFull; - }, - - beginGetBufferPercentFull: function() { - var that = this; - return new Promise(function(resolve, reject) { - setTimeout(function() { - resolve(that.bufferUsage_); - }, 100); - }); - }, - - onDataCollected_: function(messageString) { - appendTraceChunksTo(this.currentTraceTextChunks_, messageString); - }, - - endRecording: function() { - if (this.recording_ === false) - return createResolvedPromise(); - - if (this.recording_ !== true) - throw new Error('Cannot end'); - - this.currentTraceTextChunks_ = ['[']; - this.conn_.setNotificationListener( - 'Tracing.dataCollected', this.onDataCollected_.bind(this)); - - var clearListeners = function() { - this.conn_.setNotificationListener( - 'Tracing.bufferUsage', undefined); - this.conn_.setNotificationListener( - 'Tracing.tracingComplete', undefined); - this.conn_.setNotificationListener( - 'Tracing.dataCollected', undefined); - }.bind(this); - - this.recording_ = 'stopping'; - return new Promise(function(resolve, reject) { - function tracingComplete() { - clearListeners(); - this.recording_ = false; - this.currentTraceTextChunks_.push(']'); - var traceText = this.currentTraceTextChunks_.join(''); - this.currentTraceTextChunks_ = undefined; - resolve(traceText); - } - - function tracingFailed(err) { - clearListeners(); - this.recording_ = false; - reject(err); - } - - this.conn_.setNotificationListener( - 'Tracing.tracingComplete', tracingComplete.bind(this)); - this.conn_.req('Tracing.end', {}).then( - function end() { - // Nothing happens here. We're really waiting for - // Tracing.tracingComplete. - }.bind(this), - tracingFailed.bind(this)); - }.bind(this)); - }, - - defaultTraceName: function() { - return 'trace.json'; - } - }; - - return { - InspectorTracingControllerClient: InspectorTracingControllerClient, - appendTraceChunksTo: appendTraceChunksTo - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/about_tracing/inspector_tracing_controller_client_test.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/about_tracing/inspector_tracing_controller_client_test.html deleted file mode 100644 index bbff78a9855..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/about_tracing/inspector_tracing_controller_client_test.html +++ /dev/null @@ -1,83 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" - href="/tracing/ui/extras/about_tracing/inspector_tracing_controller_client.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - test('beginRecording_sendCategoriesAndOptions', function() { - var controller = - new tr.ui.e.about_tracing.InspectorTracingControllerClient(); - controller.conn_ = new (function() { - this.req = function(method, params) { - var msg = JSON.stringify({ - id: 1, - method: method, - params: params - }); - return new (function() { - this.msg = msg; - this.then = function(m1, m2) { - return this; - }; - })(); - }; - this.setNotificationListener = function(method, listener) { - }; - })(); - - var recordingOptions = { - categoryFilter: JSON.stringify(['a', 'b', 'c']), - useSystemTracing: false, - tracingRecordMode: 'test-mode', - useSampling: true - }; - - var result = JSON.parse(controller.beginRecording(recordingOptions).msg); - assert.equal(result.params.categories, JSON.stringify(['a', 'b', 'c'])); - var options = result.params.options.split(','); - var tracingRecordTestMode = false; - var sampleFlag = false; - for (var s in options) { - if (options[s] === 'test-mode') tracingRecordTestMode = true; - else if (options[s] === 'enable-sampling') sampleFlag = true; - else assert.equal(options[s], ''); - } - assert.isTrue(tracingRecordTestMode); - assert.isTrue(sampleFlag); - }); - - test('oldFormat', function() { - var chunks = []; - tr.ui.e.about_tracing.appendTraceChunksTo(chunks, '"{ "method": "Tracing.dataCollected", "params": { "value": [ {"cat":"__metadata","pid":28871,"tid":0,"ts":0,"ph":"M","name":"num_cpus","args":{"number":4}},{"cat":"__metadata","pid":28871,"tid":28911,"ts":0,"ph":"M","name":"process_sort_index","args":{"sort_index":-5}},{"cat":"__metadata","pid":28871,"tid":28911,"ts":0,"ph":"M","name":"process_name","args":{"name":"Renderer"}},{"cat":"__metadata","pid":28871,"tid":28911,"ts":0,"ph":"M","name":"process_labels","args":{"labels":"JS Bin"}},{"cat":"__metadata","pid":28871,"tid":28908,"ts":0,"ph":"M","name":"thread_sort_index","args":{"sort_index":-1}},{"cat":"__metadata","pid":28871,"tid":28917,"ts":0,"ph":"M","name":"thread_name","args":{"name":"Compositor"}},{"cat":"__metadata","pid":28871,"tid":28911,"ts":0,"ph":"M","name":"thread_name","args":{"name":"Chrome_ChildIOThread"}},{"cat":"__metadata","pid":28871,"tid":28919,"ts":0,"ph":"M","name":"thread_name","args":{"name":"CompositorRasterWorker1/28919"}},{"cat":"__metadata","pid":28871,"tid":28908,"ts":0,"ph":"M","name":"thread_name","args":{"name":"CrRendererMain"}},{"cat":"ipc,toplevel","pid":28871,"tid":28911,"ts":22000084746,"ph":"X","name":"ChannelReader::DispatchInputData","args":{"class":64,"line":25},"tdur":0,"tts":1853064},{"cat":"__metadata","pid":28871,"tid":28911,"ts":0,"ph":"M","name":"overhead","args":{"average_overhead":0.015}} ] } }"'); // @suppress longLineCheck - assert.equal(chunks.length, 1); - JSON.parse('[' + chunks.join('') + ']'); - }); - - test('newFormat', function() { - var chunks = []; - tr.ui.e.about_tracing.appendTraceChunksTo(chunks, '"{ "method": "Tracing.dataCollected", "params": { "value": [{"cat":"__metadata","pid":28871,"tid":0,"ts":0,"ph":"M","name":"num_cpus","args":{"number":4}},{"cat":"__metadata","pid":28871,"tid":28911,"ts":0,"ph":"M","name":"process_sort_index","args":{"sort_index":-5}},{"cat":"__metadata","pid":28871,"tid":28911,"ts":0,"ph":"M","name":"process_name","args":{"name":"Renderer"}},{"cat":"__metadata","pid":28871,"tid":28911,"ts":0,"ph":"M","name":"process_labels","args":{"labels":"JS Bin"}},{"cat":"__metadata","pid":28871,"tid":28908,"ts":0,"ph":"M","name":"thread_sort_index","args":{"sort_index":-1}},{"cat":"__metadata","pid":28871,"tid":28917,"ts":0,"ph":"M","name":"thread_name","args":{"name":"Compositor"}},{"cat":"__metadata","pid":28871,"tid":28911,"ts":0,"ph":"M","name":"thread_name","args":{"name":"Chrome_ChildIOThread"}},{"cat":"__metadata","pid":28871,"tid":28919,"ts":0,"ph":"M","name":"thread_name","args":{"name":"CompositorRasterWorker1/28919"}},{"cat":"__metadata","pid":28871,"tid":28908,"ts":0,"ph":"M","name":"thread_name","args":{"name":"CrRendererMain"}},{"cat":"ipc,toplevel","pid":28871,"tid":28911,"ts":22000084746,"ph":"X","name":"ChannelReader::DispatchInputData","args":{"class":64,"line":25},"tdur":0,"tts":1853064},{"cat":"__metadata","pid":28871,"tid":28911,"ts":0,"ph":"M","name":"overhead","args":{"average_overhead":0.015}}] } }"'); // @suppress longLineCheck - assert.equal(chunks.length, 1); - JSON.parse('[' + chunks.join('') + ']'); - }); - - test('stringAndObjectPayload', function() { - var connection = new tr.ui.e.about_tracing.InspectorConnection(); - connection.setNotificationListener('Tracing.dataCollected', - function(message) { - assert.typeOf(message, 'string'); - JSON.parse(message); - } - ); - connection.dispatchMessage_('{ "method": "Tracing.dataCollected", "params": { "value": [] } }'); // @suppress longLineCheck - connection.dispatchMessage_({'method': 'Tracing.dataCollected', 'params': {'value': [] } }); // @suppress longLineCheck - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/about_tracing/mock_tracing_controller_client.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/about_tracing/mock_tracing_controller_client.html deleted file mode 100644 index a88122ff636..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/about_tracing/mock_tracing_controller_client.html +++ /dev/null @@ -1,86 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" - href="/tracing/ui/extras/about_tracing/tracing_controller_client.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.e.about_tracing', function() { - function MockTracingControllerClient() { - this.requests = []; - this.nextRequestIndex = 0; - this.allowLooping = false; - } - - MockTracingControllerClient.prototype = { - __proto__: tr.ui.e.about_tracing.TracingControllerClient.prototype, - - expectRequest: function(method, generateResponse) { - var generateResponseCb; - if (typeof generateResponse === 'function') { - generateResponseCb = generateResponse; - } else { - generateResponseCb = function() { - return generateResponse; - }; - } - - this.requests.push({ - method: method, - generateResponseCb: generateResponseCb}); - }, - - _request: function(method, args) { - return new Promise(function(resolve) { - var requestIndex = this.nextRequestIndex; - if (requestIndex >= this.requests.length) - throw new Error('Unhandled request'); - if (!this.allowLooping) { - this.nextRequestIndex++; - } else { - this.nextRequestIndex = (this.nextRequestIndex + 1) % - this.requests.length; - } - - var req = this.requests[requestIndex]; - assert.equal(method, req.method); - var resp = req.generateResponseCb(args); - resolve(resp); - }.bind(this)); - }, - - assertAllRequestsHandled: function() { - if (this.allowLooping) - throw new Error('Incompatible with allowLooping'); - assert.equal(this.requests.length, this.nextRequestIndex); - }, - - getCategories: function() { - return this._request('getCategories'); - }, - - beginRecording: function(recordingOptions) { - return this._request('beginRecording', recordingOptions); - }, - - beginGetBufferPercentFull: function() { - return this._request('beginGetBufferPercentFull'); - }, - - endRecording: function() { - return this._request('endRecording'); - } - }; - - return { - MockTracingControllerClient: MockTracingControllerClient - }; -}); -</script> - diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/about_tracing/profiling_view.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/about_tracing/profiling_view.html deleted file mode 100644 index accff574c54..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/about_tracing/profiling_view.html +++ /dev/null @@ -1,369 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/base64.html"> -<link rel="import" href="/tracing/importer/import.html"> -<link rel="import" href="/tracing/ui/base/file.html"> -<link rel="import" href="/tracing/ui/base/hotkey_controller.html"> -<link rel="import" href="/tracing/ui/base/info_bar_group.html"> -<link rel="import" href="/tracing/ui/base/overlay.html"> -<link rel="import" href="/tracing/ui/base/utils.html"> -<link rel="import" - href="/tracing/ui/extras/about_tracing/inspector_tracing_controller_client.html"> -<link rel="import" - href="/tracing/ui/extras/about_tracing/record_controller.html"> -<link rel="import" - href="/tracing/ui/extras/about_tracing/xhr_based_tracing_controller_client.html"> -<link rel="import" href="/tracing/ui/timeline_view.html"> - -<style> -x-profiling-view { - -webkit-flex-direction: column; - display: -webkit-flex; - padding: 0; -} - -x-profiling-view .controls #save-button { - margin-left: 64px !important; -} - -x-profiling-view > tr-ui-timeline-view { - -webkit-flex: 1 1 auto; - min-height: 0; -} - -.report-id-message { - -webkit-user-select: text; -} - -x-timeline-view-buttons { - display: flex; - align-items: center; -} -</style> - -<template id="profiling-view-template"> - <tr-ui-b-info-bar-group></tr-ui-b-info-bar-group> - <x-timeline-view-buttons> - <button id="record-button">Record</button> - <button id="save-button">Save</button> - <button id="load-button">Load</button> - </x-timeline-view-buttons> - <tr-ui-timeline-view> - <track-view-container id='track_view_container'></track-view-container> - </tr-ui-timeline-view> -</template> - -<script> -'use strict'; - -/** - * @fileoverview ProfilingView glues the View control to - * TracingController. - */ -tr.exportTo('tr.ui.e.about_tracing', function() { - /** - * ProfilingView - * @constructor - * @extends {HTMLUnknownElement} - */ - var ProfilingView = tr.ui.b.define('x-profiling-view'); - var THIS_DOC = document.currentScript.ownerDocument; - - ProfilingView.prototype = { - __proto__: HTMLUnknownElement.prototype, - - decorate: function(tracingControllerClient) { - this.appendChild(tr.ui.b.instantiateTemplate('#profiling-view-template', - THIS_DOC)); - - this.timelineView_ = this.querySelector('tr-ui-timeline-view'); - this.infoBarGroup_ = this.querySelector('tr-ui-b-info-bar-group'); - - // Detach the buttons. We will reattach them to the timeline view. - // TODO(nduca): Make timeline-view have a content select="x-buttons" - // that pulls in any buttons. - this.recordButton_ = this.querySelector('#record-button'); - this.loadButton_ = this.querySelector('#load-button'); - this.saveButton_ = this.querySelector('#save-button'); - - var buttons = this.querySelector('x-timeline-view-buttons'); - buttons.parentElement.removeChild(buttons); - this.timelineView_.leftControls.appendChild(buttons); - this.initButtons_(); - - this.timelineView_.hotkeyController.addHotKey(new tr.ui.b.HotKey({ - eventType: 'keypress', - keyCode: 'r'.charCodeAt(0), - callback: function(e) { - this.beginRecording(); - event.stopPropagation(); - }, - thisArg: this - })); - - this.initDragAndDrop_(); - - if (tracingControllerClient) { - this.tracingControllerClient_ = tracingControllerClient; - } else if (window.DevToolsHost !== undefined) { - this.tracingControllerClient_ = - new tr.ui.e.about_tracing.InspectorTracingControllerClient(); - } else { - this.tracingControllerClient_ = - new tr.ui.e.about_tracing.XhrBasedTracingControllerClient(); - } - - this.isRecording_ = false; - this.activeTrace_ = undefined; - - this.updateTracingControllerSpecificState_(); - }, - - // Detach all document event listeners. Without this the tests can get - // confused as the element may still be listening when the next test runs. - detach_: function() { - this.detachDragAndDrop_(); - }, - - get isRecording() { - return this.isRecording_; - }, - - set tracingControllerClient(tracingControllerClient) { - this.tracingControllerClient_ = tracingControllerClient; - this.updateTracingControllerSpecificState_(); - }, - - updateTracingControllerSpecificState_: function() { - var isInspector = this.tracingControllerClient_ instanceof - tr.ui.e.about_tracing.InspectorTracingControllerClient; - - if (isInspector) { - this.infoBarGroup_.addMessage( - 'This about:tracing is connected to a remote device...', - [{buttonText: 'Wow!', onClick: function() {}}]); - } - }, - - beginRecording: function() { - if (this.isRecording_) - throw new Error('Already recording'); - this.isRecording_ = true; - var resultPromise = tr.ui.e.about_tracing.beginRecording( - this.tracingControllerClient_); - resultPromise.then( - function(data) { - this.isRecording_ = false; - var traceName = tr.ui.e.about_tracing.defaultTraceName( - this.tracingControllerClient_); - this.setActiveTrace(traceName, data, false); - }.bind(this), - function(err) { - this.isRecording_ = false; - if (err instanceof tr.ui.e.about_tracing.UserCancelledError) - return; - tr.ui.b.Overlay.showError('Error while recording', err); - }.bind(this)); - return resultPromise; - }, - - get timelineView() { - return this.timelineView_; - }, - - /////////////////////////////////////////////////////////////////////////// - - clearActiveTrace: function() { - this.saveButton_.disabled = true; - this.activeTrace_ = undefined; - }, - - setActiveTrace: function(filename, data) { - this.activeTrace_ = { - filename: filename, - data: data - }; - - this.infoBarGroup_.clearMessages(); - this.updateTracingControllerSpecificState_(); - this.saveButton_.disabled = false; - this.timelineView_.viewTitle = filename; - - var m = new tr.Model(); - var i = new tr.importer.Import(m); - var p = i.importTracesWithProgressDialog([data]); - p.then( - function() { - this.timelineView_.model = m; - this.timelineView_.updateDocumentFavicon(); - }.bind(this), - function(err) { - tr.ui.b.Overlay.showError('While importing: ', err); - }.bind(this)); - }, - - /////////////////////////////////////////////////////////////////////////// - - initButtons_: function() { - this.recordButton_.addEventListener( - 'click', function(event) { - event.stopPropagation(); - this.beginRecording(); - }.bind(this)); - - this.loadButton_.addEventListener( - 'click', function(event) { - event.stopPropagation(); - this.onLoadClicked_(); - }.bind(this)); - - this.saveButton_.addEventListener('click', - this.onSaveClicked_.bind(this)); - this.saveButton_.disabled = true; - }, - - requestFilename_: function() { - - // unsafe filename patterns: - var illegalRe = /[\/\?<>\\:\*\|":]/g; - var controlRe = /[\x00-\x1f\x80-\x9f]/g; - var reservedRe = /^\.+$/; - - var filename; - var defaultName = this.activeTrace_.filename; - var fileExtension = '.json'; - var fileRegex = /\.json$/; - if (/[.]gz$/.test(defaultName)) { - fileExtension += '.gz'; - fileRegex = /\.json\.gz$/; - } else if (/[.]zip$/.test(defaultName)) { - fileExtension = '.zip'; - fileRegex = /\.zip$/; - } - - var custom = prompt('Filename? (' + fileExtension + - ' appended) Or leave blank:'); - if (custom === null) - return undefined; - - var name; - if (custom) { - name = ' ' + custom; - } else { - var date = new Date(); - var dateText = ' ' + date.toDateString() + - ' ' + date.toLocaleTimeString(); - name = dateText; - } - - filename = defaultName.replace(fileRegex, name) + fileExtension; - - return filename - .replace(illegalRe, '.') - .replace(controlRe, '\u2022') - .replace(reservedRe, '') - .replace(/\s+/g, '_'); - }, - - onSaveClicked_: function() { - // Create a blob URL from the binary array. - var blob = new Blob([this.activeTrace_.data], - {type: 'application/octet-binary'}); - var blobUrl = window.webkitURL.createObjectURL(blob); - - // Create a link and click on it. BEST API EVAR! - var link = document.createElementNS('http://www.w3.org/1999/xhtml', 'a'); - link.href = blobUrl; - var filename = this.requestFilename_(); - if (filename) { - link.download = filename; - link.click(); - } - }, - - onLoadClicked_: function() { - var inputElement = document.createElement('input'); - inputElement.type = 'file'; - inputElement.multiple = false; - - var changeFired = false; - inputElement.addEventListener( - 'change', - function(e) { - if (changeFired) - return; - changeFired = true; - - var file = inputElement.files[0]; - tr.ui.b.readFile(file).then( - function(data) { - this.setActiveTrace(file.name, data); - }.bind(this), - function(err) { - tr.ui.b.Overlay.showError('Error while loading file: ' + err); - }); - }.bind(this), false); - inputElement.click(); - }, - - /////////////////////////////////////////////////////////////////////////// - - initDragAndDrop_: function() { - this.dropHandler_ = this.dropHandler_.bind(this); - this.ignoreDragEvent_ = this.ignoreDragEvent_.bind(this); - document.addEventListener('dragstart', this.ignoreDragEvent_, false); - document.addEventListener('dragend', this.ignoreDragEvent_, false); - document.addEventListener('dragenter', this.ignoreDragEvent_, false); - document.addEventListener('dragleave', this.ignoreDragEvent_, false); - document.addEventListener('dragover', this.ignoreDragEvent_, false); - document.addEventListener('drop', this.dropHandler_, false); - }, - - detachDragAndDrop_: function() { - document.removeEventListener('dragstart', this.ignoreDragEvent_); - document.removeEventListener('dragend', this.ignoreDragEvent_); - document.removeEventListener('dragenter', this.ignoreDragEvent_); - document.removeEventListener('dragleave', this.ignoreDragEvent_); - document.removeEventListener('dragover', this.ignoreDragEvent_); - document.removeEventListener('drop', this.dropHandler_); - }, - - ignoreDragEvent_: function(e) { - e.preventDefault(); - return false; - }, - - dropHandler_: function(e) { - if (this.isAnyDialogUp_) - return; - - e.stopPropagation(); - e.preventDefault(); - - var files = e.dataTransfer.files; - if (files.length !== 1) { - tr.ui.b.Overlay.showError('1 file supported at a time.'); - return; - } - - tr.ui.b.readFile(files[0]).then( - function(data) { - this.setActiveTrace(files[0].name, data); - }.bind(this), - function(err) { - tr.ui.b.Overlay.showError('Error while loading file: ' + err); - }); - return false; - } - }; - - return { - ProfilingView: ProfilingView - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/about_tracing/profiling_view_test.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/about_tracing/profiling_view_test.html deleted file mode 100644 index 457d074fe24..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/about_tracing/profiling_view_test.html +++ /dev/null @@ -1,84 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/base.html"> -<link rel="import" href="/tracing/base/base64.html"> -<link rel="import" - href="/tracing/ui/extras/about_tracing/mock_tracing_controller_client.html"> -<link rel="import" href="/tracing/extras/importer/trace_event_importer.html"> -<link rel="import" href="/tracing/ui/extras/about_tracing/profiling_view.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var Base64 = tr.b.Base64; - var testData = [ - {name: 'a', args: {}, pid: 52, ts: 15000, cat: 'foo', tid: 53, ph: 'B'}, - {name: 'a', args: {}, pid: 52, ts: 19000, cat: 'foo', tid: 53, ph: 'E'}, - {name: 'b', args: {}, pid: 52, ts: 32000, cat: 'foo', tid: 53, ph: 'B'}, - {name: 'b', args: {}, pid: 52, ts: 54000, cat: 'foo', tid: 53, ph: 'E'} - ]; - - var monitoringOptions = { - isMonitoring: false, - categoryFilter: '*', - useSystemTracing: false, - useContinuousTracing: false, - useSampling: false - }; - - var ProfilingView = tr.ui.e.about_tracing.ProfilingView; - - test('recording', function() { - var mock = new tr.ui.e.about_tracing.MockTracingControllerClient(); - mock.allowLooping = true; - mock.expectRequest('endRecording', function() { - return ''; - }); - mock.expectRequest('getCategories', function() { - return ['a', 'b', 'c']; - }); - mock.expectRequest('beginRecording', function(data) { - return ''; - }); - mock.expectRequest('endRecording', function(data) { - return JSON.stringify(testData); - }); - - var view = new ProfilingView(mock); - view.style.height = '400px'; - view.style.border = '1px solid black'; - this.addHTMLOutput(view); - - return new Promise(function(resolve, reject) { - var recordingPromise = view.beginRecording(); - - var didAbort = false; - function pressRecord() { - if (didAbort) - return; - recordingPromise.selectionDlg.clickRecordButton(); - setTimeout(pressStop, 60); - } - function pressStop() { - recordingPromise.progressDlg.clickStopButton(); - } - setTimeout(pressRecord, 60); - recordingPromise.then( - function() { - resolve(); - }, - function(err) { - didAbort = true; - reject(err); - }); - }); - }); -}); -</script> - diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/about_tracing/record_controller.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/about_tracing/record_controller.html deleted file mode 100644 index 2284b0fa3e7..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/about_tracing/record_controller.html +++ /dev/null @@ -1,181 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/extras/about_tracing/record_selection_dialog.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.e.about_tracing', function() { - function beginRecording(tracingControllerClient) { - var finalPromiseResolver; - var finalPromise = new Promise(function(resolve, reject) { - finalPromiseResolver = { - resolve: resolve, - reject: reject - }; - }); - finalPromise.selectionDlg = undefined; - finalPromise.progressDlg = undefined; - - function beginRecordingError(err) { - finalPromiseResolver.reject(err); - } - - // Step 0: End recording. This is necessary when the user reloads the - // about:tracing page when we are recording. Window.onbeforeunload is not - // reliable to end recording on reload. - endRecording(tracingControllerClient).then( - getCategories, - getCategories); // Ignore error. - - // But just in case, bind onbeforeunload anyway. - window.onbeforeunload = function(e) { - endRecording(tracingControllerClient); - }; - - // Step 1: Get categories. - function getCategories() { - var p = tracingControllerClient.getCategories().then( - showTracingDialog, - beginRecordingError); - p.catch(function(err) { - beginRecordingError(err); - }); - } - - // Step 2: Show tracing dialog. - var selectionDlg; - function showTracingDialog(categories) { - selectionDlg = new tr.ui.e.about_tracing.RecordSelectionDialog(); - selectionDlg.categories = categories; - selectionDlg.settings_key = - 'tr.ui.e.about_tracing.record_selection_dialog'; - selectionDlg.addEventListener('recordclick', startTracing); - selectionDlg.addEventListener('closeclick', cancelRecording); - selectionDlg.visible = true; - - finalPromise.selectionDlg = selectionDlg; - } - - function cancelRecording() { - finalPromise.selectionDlg = undefined; - finalPromiseResolver.reject(new UserCancelledError()); - } - - // Step 2: Do the actual tracing dialog. - var progressDlg; - var bufferPercentFullDiv; - function startTracing() { - progressDlg = new tr.ui.b.Overlay(); - progressDlg.textContent = 'Recording...'; - progressDlg.userCanClose = false; - - bufferPercentFullDiv = document.createElement('div'); - progressDlg.appendChild(bufferPercentFullDiv); - - var stopButton = document.createElement('button'); - stopButton.textContent = 'Stop'; - progressDlg.clickStopButton = function() { - stopButton.click(); - }; - progressDlg.appendChild(stopButton); - - var recordingOptions = { - categoryFilter: selectionDlg.categoryFilter(), - useSystemTracing: selectionDlg.useSystemTracing, - tracingRecordMode: selectionDlg.tracingRecordMode, - useSampling: selectionDlg.useSampling - }; - - - var requestPromise = tracingControllerClient.beginRecording( - recordingOptions); - requestPromise.then( - function() { - progressDlg.visible = true; - stopButton.focus(); - updateBufferPercentFull('0'); - }, - recordFailed); - - stopButton.addEventListener('click', function() { - // TODO(chrishenry): Currently, this only dismiss the progress - // dialog when tracingComplete event is received. When performing - // remote debugging, the tracingComplete event may be delayed - // considerable. We should indicate to user that we are waiting - // for tracingComplete event instead of being unresponsive. (For - // now, I disable the "stop" button, since clicking on the button - // again now cause exception.) - var recordingPromise = endRecording(tracingControllerClient); - recordingPromise.then( - recordFinished, - recordFailed); - stopButton.disabled = true; - bufferPercentFullDiv = undefined; - }); - finalPromise.progressDlg = progressDlg; - } - - function recordFinished(tracedData) { - progressDlg.visible = false; - finalPromise.progressDlg = undefined; - finalPromiseResolver.resolve(tracedData); - } - - function recordFailed(err) { - progressDlg.visible = false; - finalPromise.progressDlg = undefined; - finalPromiseResolver.reject(err); - } - - function getBufferPercentFull() { - if (!bufferPercentFullDiv) - return; - - tracingControllerClient.beginGetBufferPercentFull().then( - updateBufferPercentFull); - } - - function updateBufferPercentFull(percent_full) { - if (!bufferPercentFullDiv) - return; - - percent_full = Math.round(100 * parseFloat(percent_full)); - var newText = 'Buffer usage: ' + percent_full + '%'; - if (bufferPercentFullDiv.textContent != newText) - bufferPercentFullDiv.textContent = newText; - - window.setTimeout(getBufferPercentFull, 500); - } - - // Thats it! We're done. - return finalPromise; - }; - - function endRecording(tracingControllerClient) { - return tracingControllerClient.endRecording(); - } - - function defaultTraceName(tracingControllerClient) { - return tracingControllerClient.defaultTraceName(); - } - - function UserCancelledError() { - Error.apply(this, arguments); - } - UserCancelledError.prototype = { - __proto__: Error.prototype - }; - - return { - beginRecording: beginRecording, - UserCancelledError: UserCancelledError, - defaultTraceName: defaultTraceName - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/about_tracing/record_controller_test.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/about_tracing/record_controller_test.html deleted file mode 100644 index 69c9cc8173d..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/about_tracing/record_controller_test.html +++ /dev/null @@ -1,65 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" - href="/tracing/ui/extras/about_tracing/mock_tracing_controller_client.html"> -<link rel="import" - href="/tracing/ui/extras/about_tracing/record_controller.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var testData = [ - {name: 'a', args: {}, pid: 52, ts: 15000, cat: 'foo', tid: 53, ph: 'B'}, - {name: 'a', args: {}, pid: 52, ts: 19000, cat: 'foo', tid: 53, ph: 'E'}, - {name: 'b', args: {}, pid: 52, ts: 32000, cat: 'foo', tid: 53, ph: 'B'}, - {name: 'b', args: {}, pid: 52, ts: 54000, cat: 'foo', tid: 53, ph: 'E'} - ]; - - test('fullRecording', function() { - return new Promise(function(resolve, reject) { - var mock = new tr.ui.e.about_tracing.MockTracingControllerClient(); - mock.expectRequest('endRecording', function() { - return ''; - }); - mock.expectRequest('getCategories', function() { - setTimeout(function() { - recordingPromise.selectionDlg.clickRecordButton(); - }, 20); - return ['a', 'b', 'c']; - }); - mock.expectRequest('beginRecording', function(recordingOptions) { - assert.typeOf(recordingOptions.categoryFilter, 'string'); - assert.typeOf(recordingOptions.useSystemTracing, 'boolean'); - assert.typeOf(recordingOptions.useSampling, 'boolean'); - assert.typeOf(recordingOptions.tracingRecordMode, 'string'); - setTimeout(function() { - recordingPromise.progressDlg.clickStopButton(); - }, 10); - return ''; - }); - mock.expectRequest('endRecording', function(data) { - return JSON.stringify(testData); - }); - - var recordingPromise = tr.ui.e.about_tracing.beginRecording(mock); - - return recordingPromise.then( - function(data) { - mock.assertAllRequestsHandled(); - var testDataString = JSON.stringify(testData); - assert.equal(data, testDataString); - resolve(); - }, - function(error) { - reject('This should never be reached'); - }); - }); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/about_tracing/record_selection_dialog.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/about_tracing/record_selection_dialog.html deleted file mode 100644 index 79ce154dba8..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/about_tracing/record_selection_dialog.html +++ /dev/null @@ -1,672 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> -<link rel="import" href="/tracing/core/filter.html"> -<link rel="import" href="/tracing/ui/base/dom_helpers.html"> -<link rel="import" href="/tracing/ui/base/info_bar_group.html"> -<link rel="import" href="/tracing/ui/base/overlay.html"> -<link rel="import" href="/tracing/ui/base/utils.html"> - -<template id="record-selection-dialog-template"> - <style> - .categories-column-view { - display: -webkit-flex; - -webkit-flex-direction: column; - font-family: sans-serif; - max-width: 640px; - min-height: 0; - min-width: 0; - opacity: 1; - transition: max-height 1s ease, max-width 1s ease, opacity 1s ease; - will-change: opacity; - } - - .categories-column-view-hidden { - max-height: 0; - max-width: 0; - opacity: 0; - overflow: hidden; - } - - .categories-selection { - display: -webkit-flex; - -webkit-flex-direction: row; - } - - .category-presets { - padding: 4px; - } - - .category-description { - color: #aaa; - font-size: small; - max-height: 1em; - opacity: 1; - padding-left: 4px; - padding-right: 4px; - text-align: right; - transition: max-height 1s ease, opacity 1s ease; - will-change: opacity; - } - - .category-description-hidden { - max-height: 0; - opacity: 0; - } - - .default-enabled-categories, - .default-disabled-categories { - -webkit-flex: 1 1 auto; - display: -webkit-flex; - -webkit-flex-direction: column; - padding: 4px; - width: 300px; - } - - .default-enabled-categories > div, - .default-disabled-categories > div { - padding: 4px; - } - - .tracing-modes { - -webkit-flex: 1 0 auto; - display: -webkit-flex; - -webkit-flex-direction: reverse; - padding: 4px; - border-bottom: 2px solid #ddd; - border-top: 2px solid #ddd; - } - - .default-disabled-categories { - border-left: 2px solid #ddd; - } - - .warning-default-disabled-categories { - display: inline-block; - font-weight: bold; - text-align: center; - color: #BD2E2E; - width: 2.0ex; - height: 2.0ex; - border-radius: 2.0ex; - border: 1px solid #BD2E2E; - } - - .categories { - font-size: 80%; - padding: 10px; - -webkit-flex: 1 1 auto; - } - - .group-selectors { - font-size: 80%; - border-bottom: 1px solid #ddd; - padding-bottom: 6px; - -webkit-flex: 0 0 auto; - } - - .group-selectors button { - padding: 1px; - } - - .record-selection-dialog .labeled-option-group { - -webkit-flex: 0 0 auto; - -webkit-flex-direction: column; - display: -webkit-flex; - } - - .record-selection-dialog .labeled-option { - border-top: 5px solid white; - border-bottom: 5px solid white; - } - - .record-selection-dialog .edit-categories { - padding-left: 6px; - } - - .record-selection-dialog .edit-categories:after { - padding-left: 15px; - font-size: 125%; - } - - .record-selection-dialog .labeled-option-group:not(.categories-expanded) - .edit-categories:after { - content: '\25B8'; /* Right triangle */ - } - - .record-selection-dialog .labeled-option-group.categories-expanded - .edit-categories:after { - content: '\25BE'; /* Down triangle */ - } - - </style> - - <div class="record-selection-dialog"> - <tr-ui-b-info-bar-group></tr-ui-b-info-bar-group> - <div class="category-presets"> - </div> - <div class="category-description"></div> - <div class="categories-column-view"> - <div class="tracing-modes"></div> - <div class="categories-selection"> - <div class="default-enabled-categories"> - <div>Record Categories</div> - <div class="group-selectors"> - Select - <button class="all-btn">All</button> - <button class="none-btn">None</button> - </div> - <div class="categories"></div> - </div> - <div class="default-disabled-categories"> - <div>Disabled by Default Categories - <a class="warning-default-disabled-categories">!</a> - </div> - <div class="group-selectors"> - Select - <button class="all-btn">All</button> - <button class="none-btn">None</button> - </div> - <div class="categories"></div> - </div> - </div> - </div> - </div> -</template> - -<script> -'use strict'; - -/** - * @fileoverview RecordSelectionDialog presents the available categories - * to be enabled/disabled during tr.c. - */ -tr.exportTo('tr.ui.e.about_tracing', function() { - var THIS_DOC = document.currentScript.ownerDocument; - var RecordSelectionDialog = tr.ui.b.define('div'); - - var DEFAULT_PRESETS = [ - {title: 'Web developer', - categoryFilter: ['blink', 'cc', 'netlog', 'renderer.scheduler', - 'toplevel', 'v8']}, - {title: 'Input latency', - categoryFilter: ['benchmark', 'input', 'evdev', 'renderer.scheduler', - 'toplevel']}, - {title: 'Rendering', - categoryFilter: ['blink', 'cc', 'gpu', 'toplevel']}, - {title: 'Javascript and rendering', - categoryFilter: ['blink', 'cc', 'gpu', 'renderer.scheduler', 'v8', - 'toplevel']}, - {title: 'Frame Viewer', - categoryFilter: ['blink', 'cc', 'gpu', 'renderer.scheduler', 'v8', - 'toplevel', - 'disabled-by-default-cc.debug', - 'disabled-by-default-cc.debug.picture', - 'disabled-by-default-cc.debug.display_items']}, - {title: 'Manually select settings', - categoryFilter: []} - ]; - var RECORDING_MODES = [ - {'label': 'Record until full', - 'value': 'record-until-full'}, - {'label': 'Record continuously', - 'value': 'record-continuously'}, - {'label': 'Record as much as possible', - 'value': 'record-as-much-as-possible'}]; - var DEFAULT_RECORD_MODE = 'record-until-full'; - var DEFAULT_CONTINUOUS_TRACING = true; - var DEFAULT_SYSTEM_TRACING = true; - var DEFAULT_SAMPLING_TRACING = false; - - RecordSelectionDialog.prototype = { - __proto__: tr.ui.b.Overlay.prototype, - - decorate: function() { - tr.ui.b.Overlay.prototype.decorate.call(this); - this.title = 'Record a new trace...'; - - this.classList.add('record-dialog-overlay'); - - var node = - tr.ui.b.instantiateTemplate('#record-selection-dialog-template', - THIS_DOC); - this.appendChild(node); - - this.recordButtonEl_ = document.createElement('button'); - this.recordButtonEl_.textContent = 'Record'; - this.recordButtonEl_.addEventListener( - 'click', - this.onRecordButtonClicked_.bind(this)); - this.recordButtonEl_.style.fontSize = '110%'; - this.buttons.appendChild(this.recordButtonEl_); - - this.categoriesView_ = this.querySelector('.categories-column-view'); - this.presetsEl_ = this.querySelector('.category-presets'); - this.presetsEl_.appendChild(tr.ui.b.createOptionGroup( - this, 'currentlyChosenPreset', - 'about_tracing.record_selection_dialog_preset', - DEFAULT_PRESETS[0].categoryFilter, - DEFAULT_PRESETS.map(function(p) { - return { label: p.title, value: p.categoryFilter }; - }))); - - this.tracingRecordModeSltr_ = tr.ui.b.createSelector( - this, 'tracingRecordMode', - 'recordSelectionDialog.tracingRecordMode', - DEFAULT_RECORD_MODE, RECORDING_MODES); - - this.systemTracingBn_ = tr.ui.b.createCheckBox( - undefined, undefined, - 'recordSelectionDialog.useSystemTracing', DEFAULT_SYSTEM_TRACING, - 'System tracing'); - this.samplingTracingBn_ = tr.ui.b.createCheckBox( - undefined, undefined, - 'recordSelectionDialog.useSampling', DEFAULT_SAMPLING_TRACING, - 'State sampling'); - this.tracingModesContainerEl_ = this.querySelector('.tracing-modes'); - this.tracingModesContainerEl_.appendChild(this.tracingRecordModeSltr_); - this.tracingModesContainerEl_.appendChild(this.systemTracingBn_); - this.tracingModesContainerEl_.appendChild(this.samplingTracingBn_); - - - this.enabledCategoriesContainerEl_ = - this.querySelector('.default-enabled-categories .categories'); - - this.disabledCategoriesContainerEl_ = - this.querySelector('.default-disabled-categories .categories'); - - this.createGroupSelectButtons_( - this.querySelector('.default-enabled-categories')); - this.createGroupSelectButtons_( - this.querySelector('.default-disabled-categories')); - this.createDefaultDisabledWarningDialog_( - this.querySelector('.warning-default-disabled-categories')); - this.editCategoriesOpened_ = false; - - // TODO(chrishenry): When used with tr.ui.b.Overlay (such as in - // chrome://tracing, this does not yet look quite right due to - // the 10px overlay content padding (but it's good enough). - this.infoBarGroup_ = this.querySelector('tr-ui-b-info-bar-group'); - - this.addEventListener('visible-change', this.onVisibleChange_.bind(this)); - }, - - set supportsSystemTracing(s) { - if (s) { - this.systemTracingBn_.style.display = undefined; - } else { - this.systemTracingBn_.style.display = 'none'; - this.useSystemTracing = false; - } - }, - - get tracingRecordMode() { - return this.tracingRecordModeSltr_.selectedValue; - }, - set tracingRecordMode(value) { - this.tracingRecordMode_ = value; - }, - - get useSystemTracing() { - return this.systemTracingBn_.checked; - }, - set useSystemTracing(value) { - this.systemTracingBn_.checked = !!value; - }, - - get useSampling() { - return this.samplingTracingBn_.checked; - }, - set useSampling(value) { - this.samplingTracingBn_.checked = !!value; - }, - - set categories(c) { - if (!(c instanceof Array)) - throw new Error('categories must be an array'); - this.categories_ = c; - - for (var i = 0; i < this.categories_.length; i++) { - var split = this.categories_[i].split(','); - this.categories_[i] = split.shift(); - if (split.length > 0) - this.categories_ = this.categories_.concat(split); - } - }, - - set settings_key(k) { - this.settings_key_ = k; - }, - - set settings(s) { - throw new Error('Dont use this!'); - }, - - usingPreset_: function() { - return this.currentlyChosenPreset_.length > 0; - }, - - get currentlyChosenPreset() { - return this.currentlyChosenPreset_; - }, - - set currentlyChosenPreset(preset) { - if (!(preset instanceof Array)) - throw new Error('RecordSelectionDialog.currentlyChosenPreset:' + - ' preset must be an array.'); - this.currentlyChosenPreset_ = preset; - - if (this.usingPreset_()) { - this.changeEditCategoriesState_(false); - } else { - this.updateCategoryColumnView_(true); - this.changeEditCategoriesState_(true); - } - this.updateManualSelectionView_(); - this.updatePresetDescription_(); - }, - - updateManualSelectionView_: function() { - var classList = this.categoriesView_.classList; - if (!this.usingPreset_()) { - classList.remove('categories-column-view-hidden'); - } else { - if (this.editCategoriesOpened_) - classList.remove('categories-column-view-hidden'); - else - classList.add('categories-column-view-hidden'); - } - }, - - updateCategoryColumnView_: function(shouldReadFromSettings) { - var categorySet = this.querySelectorAll('.categories'); - for (var i = 0; i < categorySet.length; ++i) { - var categoryGroup = categorySet[i].children; - for (var j = 0; j < categoryGroup.length; ++j) { - var categoryEl = categoryGroup[j].children[0]; - categoryEl.checked = shouldReadFromSettings ? - tr.b.Settings.get(categoryEl.value, false, this.settings_key_) : - false; - } - } - }, - - onClickEditCategories: function() { - if (!this.usingPreset_()) - return; - - if (!this.editCategoriesOpened_) { - this.updateCategoryColumnView_(false); - for (var i = 0; i < this.currentlyChosenPreset_.length; ++i) { - var categoryEl = this.querySelector('#' + - this.currentlyChosenPreset_[i]); - if (!categoryEl) - continue; - categoryEl.checked = true; - } - } - - this.changeEditCategoriesState_(!this.editCategoriesOpened_); - this.updateManualSelectionView_(); - this.recordButtonEl_.focus(); - }, - - changeEditCategoriesState_: function(editCategoriesState) { - var presetOptionsGroup = this.querySelector('.labeled-option-group'); - if (!presetOptionsGroup) - return; - - this.editCategoriesOpened_ = editCategoriesState; - if (this.editCategoriesOpened_) - presetOptionsGroup.classList.add('categories-expanded'); - else - presetOptionsGroup.classList.remove('categories-expanded'); - }, - - updatePresetDescription_: function() { - var description = this.querySelector('.category-description'); - if (this.usingPreset_()) { - description.innerText = this.currentlyChosenPreset_; - description.classList.remove('category-description-hidden'); - } else { - description.innerText = ''; - if (!description.classList.contains('category-description-hidden')) - description.classList.add('category-description-hidden'); - } - }, - - categoryFilter: function() { - if (this.usingPreset_()) { - var categories = []; - var allCategories = this.allCategories_(); - for (var category in allCategories) { - var disabled = category.indexOf('disabled-by-default-') == 0; - if (this.currentlyChosenPreset_.indexOf(category) >= 0) { - if (disabled) - categories.push(category); - } else { - if (!disabled) - categories.push('-' + category); - } - } - return categories.join(','); - } - - var categories = this.unselectedCategories_(); - var categories_length = categories.length; - var negated_categories = []; - for (var i = 0; i < categories_length; ++i) { - // Skip any category with a , as it will cause issues when we negate. - // Both sides should have been added as separate categories, these can - // only come from settings. - if (categories[i].match(/,/)) - continue; - negated_categories.push('-' + categories[i]); - } - categories = negated_categories.join(','); - - var disabledCategories = this.enabledDisabledByDefaultCategories_(); - disabledCategories = disabledCategories.join(','); - - var results = []; - if (categories !== '') - results.push(categories); - if (disabledCategories !== '') - results.push(disabledCategories); - return results.join(','); - }, - - clickRecordButton: function() { - this.recordButtonEl_.click(); - }, - - onRecordButtonClicked_: function() { - this.visible = false; - tr.b.dispatchSimpleEvent(this, 'recordclick'); - return false; - }, - - collectInputs_: function(inputs, isChecked) { - var inputs_length = inputs.length; - var categories = []; - for (var i = 0; i < inputs_length; ++i) { - var input = inputs[i]; - if (input.checked === isChecked) - categories.push(input.value); - } - return categories; - }, - - unselectedCategories_: function() { - var inputs = - this.enabledCategoriesContainerEl_.querySelectorAll('input'); - return this.collectInputs_(inputs, false); - }, - - enabledDisabledByDefaultCategories_: function() { - var inputs = - this.disabledCategoriesContainerEl_.querySelectorAll('input'); - return this.collectInputs_(inputs, true); - }, - - onVisibleChange_: function() { - if (this.visible) - this.updateForm_(); - }, - - buildInputs_: function(inputs, checkedDefault, parent) { - var inputs_length = inputs.length; - for (var i = 0; i < inputs_length; i++) { - var category = inputs[i]; - - var inputEl = document.createElement('input'); - inputEl.type = 'checkbox'; - inputEl.id = category; - inputEl.value = category; - - inputEl.checked = tr.b.Settings.get( - category, checkedDefault, this.settings_key_); - inputEl.onclick = this.updateSetting_.bind(this); - - var labelEl = document.createElement('label'); - labelEl.textContent = category.replace('disabled-by-default-', ''); - labelEl.setAttribute('for', category); - - var divEl = document.createElement('div'); - divEl.appendChild(inputEl); - divEl.appendChild(labelEl); - - parent.appendChild(divEl); - } - }, - - allCategories_: function() { - // Dedup the categories. We may have things in settings that are also - // returned when we query the category list. - var categorySet = {}; - var allCategories = - this.categories_.concat(tr.b.Settings.keys(this.settings_key_)); - var allCategoriesLength = allCategories.length; - for (var i = 0; i < allCategoriesLength; ++i) - categorySet[allCategories[i]] = true; - return categorySet; - }, - - updateForm_: function() { - function ignoreCaseCompare(a, b) { - return a.toLowerCase().localeCompare(b.toLowerCase()); - } - - this.enabledCategoriesContainerEl_.innerHTML = ''; // Clear old categories - this.disabledCategoriesContainerEl_.innerHTML = ''; - - this.recordButtonEl_.focus(); - - var allCategories = this.allCategories_(); - var categories = []; - var disabledCategories = []; - for (var category in allCategories) { - if (category.indexOf('disabled-by-default-') == 0) - disabledCategories.push(category); - else - categories.push(category); - } - disabledCategories = disabledCategories.sort(ignoreCaseCompare); - categories = categories.sort(ignoreCaseCompare); - - if (this.categories_.length == 0) { - this.infoBarGroup_.addMessage( - 'No categories found; recording will use default categories.'); - } - - this.buildInputs_(categories, true, this.enabledCategoriesContainerEl_); - - if (disabledCategories.length > 0) { - this.disabledCategoriesContainerEl_.hidden = false; - this.buildInputs_(disabledCategories, false, - this.disabledCategoriesContainerEl_); - } - }, - - updateSetting_: function(e) { - var checkbox = e.target; - tr.b.Settings.set(checkbox.value, checkbox.checked, this.settings_key_); - - // Change the current record mode to 'Manually select settings' from - // preset mode if and only if currently user is in preset record mode - // and user selects/deselects any category in 'Edit Categories' mode. - if (this.usingPreset_()) { - this.currentlyChosenPreset_ = [] /* manually select settings */; - var categoryEl = this.querySelector( - '#category-preset-Manually-select-settings'); - categoryEl.checked = true; - var description = this.querySelector('.category-description'); - description.innerText = ''; - description.classList.add('category-description-hidden'); - } - }, - - createGroupSelectButtons_: function(parent) { - var flipInputs = function(dir) { - var inputs = parent.querySelectorAll('input'); - for (var i = 0; i < inputs.length; i++) { - if (inputs[i].checked === dir) - continue; - // click() is used so the settings will be correclty stored. Setting - // checked does not trigger the onclick (or onchange) callback. - inputs[i].click(); - } - }; - - var allBtn = parent.querySelector('.all-btn'); - allBtn.onclick = function(evt) { - flipInputs(true); - evt.preventDefault(); - }; - - var noneBtn = parent.querySelector('.none-btn'); - noneBtn.onclick = function(evt) { - flipInputs(false); - evt.preventDefault(); - }; - }, - - setWarningDialogOverlayText_: function(messages) { - var contentDiv = document.createElement('div'); - - for (var i = 0; i < messages.length; ++i) { - var messageDiv = document.createElement('div'); - messageDiv.textContent = messages[i]; - contentDiv.appendChild(messageDiv); - } - this.warningOverlay_.textContent = ''; - this.warningOverlay_.appendChild(contentDiv); - }, - - createDefaultDisabledWarningDialog_: function(warningLink) { - function onClickHandler(evt) { - this.warningOverlay_ = tr.ui.b.Overlay(); - this.warningOverlay_.parentEl_ = this; - this.warningOverlay_.title = 'Warning...'; - this.warningOverlay_.userCanClose = true; - this.warningOverlay_.visible = true; - - this.setWarningDialogOverlayText_([ - 'Enabling the default disabled categories may have', - 'performance and memory impact while tr.c.' - ]); - - evt.preventDefault(); - } - warningLink.onclick = onClickHandler.bind(this); - } - }; - - return { - RecordSelectionDialog: RecordSelectionDialog - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/about_tracing/record_selection_dialog_test.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/about_tracing/record_selection_dialog_test.html deleted file mode 100644 index 1142f6e6035..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/about_tracing/record_selection_dialog_test.html +++ /dev/null @@ -1,386 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/settings.html"> -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/ui/extras/about_tracing/record_selection_dialog.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - test('instantitate', function() { - var showButton = document.createElement('button'); - showButton.textContent = 'Show record selection dialog'; - this.addHTMLOutput(showButton); - - showButton.addEventListener('click', function(e) { - e.stopPropagation(); - - var categories = []; - for (var i = 0; i < 30; i++) - categories.push('cat-' + i); - for (var i = 0; i < 20; i++) - categories.push('disabled-by-default-cat-' + i); - categories.push( - 'really-really-really-really-really-really-very-loong-cat'); - categories.push('first,second,third'); - categories.push('cc,disabled-by-default-cc.debug'); - - var dlg = new tr.ui.e.about_tracing.RecordSelectionDialog(); - dlg.categories = categories; - dlg.settings_key = 'key'; - dlg.visible = true; - }); - }); - - test('recordSelectionDialog_splitCategories', function() { - var dlg = new tr.ui.e.about_tracing.RecordSelectionDialog(); - dlg.categories = - ['cc,disabled-by-default-one,cc.debug', 'two,three', 'three']; - dlg.settings_key = 'key'; - dlg.currentlyChosenPreset = []; - dlg.updateForm_(); - - var expected = - ['"cc"', '"cc.debug"', '"disabled-by-default-one"', '"three"', '"two"']; - - var labels = dlg.querySelectorAll('.categories input'); - var results = []; - for (var i = 0; i < labels.length; i++) { - results.push('"' + labels[i].value + '"'); - } - results = results.sort(); - - assert.deepEqual(results, expected); - }); - - test('recordSelectionDialog_UpdateForm_NoSettings', function() { - var dlg = new tr.ui.e.about_tracing.RecordSelectionDialog(); - dlg.categories = ['disabled-by-default-one', 'two', 'three']; - dlg.settings_key = 'key'; - dlg.currentlyChosenPreset = []; - dlg.updateForm_(); - - var checkboxes = dlg.querySelectorAll('.categories input'); - assert.equal(checkboxes.length, 3); - assert.equal(checkboxes[0].id, 'three'); - assert.equal(checkboxes[0].value, 'three'); - assert.isTrue(checkboxes[0].checked); - assert.equal(checkboxes[1].id, 'two'); - assert.equal(checkboxes[1].value, 'two'); - assert.isTrue(checkboxes[1].checked); - assert.equal(checkboxes[2].id, 'disabled-by-default-one'); - assert.equal(checkboxes[2].value, 'disabled-by-default-one'); - assert.isFalse(checkboxes[2].checked); - - assert.equal(dlg.categoryFilter(), ''); - - var labels = dlg.querySelectorAll('.categories label'); - assert.equal(labels.length, 3); - assert.equal(labels[0].textContent, 'three'); - assert.equal(labels[1].textContent, 'two'); - assert.equal(labels[2].textContent, 'one'); - }); - - test('recordSelectionDialog_UpdateForm_Settings', function() { - tr.b.Settings.set('two', true, 'categories'); - tr.b.Settings.set('three', false, 'categories'); - - var dlg = new tr.ui.e.about_tracing.RecordSelectionDialog(); - dlg.categories = ['disabled-by-default-one']; - dlg.settings_key = 'categories'; - dlg.currentlyChosenPreset = []; - dlg.updateForm_(); - - var checkboxes = dlg.querySelectorAll('.categories input'); - assert.equal(checkboxes.length, 3); - assert.equal(checkboxes[0].id, 'three'); - assert.equal(checkboxes[0].value, 'three'); - assert.isFalse(checkboxes[0].checked); - assert.equal(checkboxes[1].id, 'two'); - assert.equal(checkboxes[1].value, 'two'); - assert.isTrue(checkboxes[1].checked); - assert.equal(checkboxes[2].id, 'disabled-by-default-one'); - assert.equal(checkboxes[2].value, 'disabled-by-default-one'); - assert.isFalse(checkboxes[2].checked); - - assert.equal(dlg.categoryFilter(), '-three'); - - var labels = dlg.querySelectorAll('.categories label'); - assert.equal(labels.length, 3); - assert.equal(labels[0].textContent, 'three'); - assert.equal(labels[1].textContent, 'two'); - assert.equal(labels[2].textContent, 'one'); - }); - - test('recordSelectionDialog_UpdateForm_DisabledByDefault', function() { - var dlg = new tr.ui.e.about_tracing.RecordSelectionDialog(); - dlg.categories = ['disabled-by-default-bar', 'baz']; - dlg.settings_key = 'categories'; - dlg.currentlyChosenPreset = []; - dlg.updateForm_(); - - assert.equal(dlg.categoryFilter(), ''); - - var inputs = - dlg.querySelector('input#disabled-by-default-bar').click(); - - assert.equal(dlg.categoryFilter(), 'disabled-by-default-bar'); - - assert.isFalse( - tr.b.Settings.get('disabled-by-default-foo', false, 'categories')); - }); - - test('selectAll', function() { - tr.b.Settings.set('two', true, 'categories'); - tr.b.Settings.set('three', false, 'categories'); - - var dlg = new tr.ui.e.about_tracing.RecordSelectionDialog(); - dlg.categories = ['disabled-by-default-one']; - dlg.settings_key = 'categories'; - dlg.currentlyChosenPreset = []; - dlg.updateForm_(); - }); - - test('selectNone', function() { - tr.b.Settings.set('two', true, 'categories'); - tr.b.Settings.set('three', false, 'categories'); - - var dlg = new tr.ui.e.about_tracing.RecordSelectionDialog(); - dlg.categories = ['disabled-by-default-one']; - dlg.settings_key = 'categories'; - dlg.currentlyChosenPreset = []; - dlg.updateForm_(); - - // Enables the three option, two already enabled. - dlg.querySelector('.default-enabled-categories .all-btn').click(); - assert.equal(dlg.categoryFilter(), ''); - assert.isTrue(tr.b.Settings.get('three', false, 'categories')); - - // Disables three and two. - dlg.querySelector('.default-enabled-categories .none-btn').click(); - assert.equal(dlg.categoryFilter(), '-three,-two'); - assert.isFalse(tr.b.Settings.get('two', false, 'categories')); - assert.isFalse(tr.b.Settings.get('three', false, 'categories')); - - // Turn categories back on so they can be ignored. - dlg.querySelector('.default-enabled-categories .all-btn').click(); - - // Enables disabled category. - dlg.querySelector('.default-disabled-categories .all-btn').click(); - assert.equal(dlg.categoryFilter(), 'disabled-by-default-one'); - assert.isTrue( - tr.b.Settings.get('disabled-by-default-one', false, 'categories')); - - // Turn disabled by default back off. - dlg.querySelector('.default-disabled-categories .none-btn').click(); - assert.equal(dlg.categoryFilter(), ''); - assert.isFalse( - tr.b.Settings.get('disabled-by-default-one', false, 'categories')); - }); - - test('recordSelectionDialog_noPreset', function() { - tr.b.Settings.set('about_tracing.record_selection_dialog_preset', []); - var dlg = new tr.ui.e.about_tracing.RecordSelectionDialog(); - assert.isFalse(dlg.usingPreset_()); - }); - - test('recordSelectionDialog_defaultPreset', function() { - tr.b.Settings.set('two', true, 'categories'); - tr.b.Settings.set('three', false, 'categories'); - - var dlg = new tr.ui.e.about_tracing.RecordSelectionDialog(); - dlg.categories = ['disabled-by-default-one']; - dlg.settings_key = 'categories'; - // Note: currentlyChosenPreset is not set here, so the default is used. - dlg.updateForm_(); - - // Make sure the default filter is returned. - assert.equal(dlg.categoryFilter(), '-three,-two'); - - // Make sure the default tracing types are returned. - assert.equal(dlg.tracingRecordMode, 'record-until-full'); - assert.isTrue(dlg.useSystemTracing); - assert.isFalse(dlg.useSampling); - - // Make sure the manual settings are not visible. - var classList = dlg.categoriesView_.classList; - assert.isTrue(classList.contains('categories-column-view-hidden')); - - // Verify manual settings do not modify the checkboxes. - var checkboxes = dlg.querySelectorAll('.categories input'); - assert.equal(checkboxes.length, 3); - assert.equal(checkboxes[0].id, 'three'); - assert.equal(checkboxes[0].value, 'three'); - assert.isFalse(checkboxes[0].checked); - assert.equal(checkboxes[1].id, 'two'); - assert.equal(checkboxes[1].value, 'two'); - assert.isTrue(checkboxes[1].checked); - assert.equal(checkboxes[2].id, 'disabled-by-default-one'); - assert.equal(checkboxes[2].value, 'disabled-by-default-one'); - assert.isFalse(checkboxes[2].checked); - }); - - test('recordSelectionDialog_editPreset', function() { - function createDialog() { - var dlg = new tr.ui.e.about_tracing.RecordSelectionDialog(); - dlg.categories = ['one', 'two', 'disabled-by-default-three']; - dlg.settings_key = 'categories'; - // Note: currentlyChosenPreset is not set here, so the default is used. - dlg.updateForm_(); - return dlg; - } - - // After the dialog is created, it should be using the default preset. - var dlg = createDialog(); - assert.strictEqual(dlg.categoryFilter(), '-one,-two'); - assert.isTrue(dlg.usingPreset_()); - assert.isFalse( - dlg.querySelector('#category-preset-Manually-select-settings').checked); - - // After clicking on "Edit Categories", the default preset should still be - // used. - dlg.onClickEditCategories(); - assert.strictEqual(dlg.categoryFilter(), '-one,-two'); - assert.isTrue(dlg.usingPreset_()); - assert.isFalse( - dlg.querySelector('#category-preset-Manually-select-settings').checked); - - // After clicking on category checkbox(es), the mode should be changed to - // "Manually select settings". - Array.prototype.forEach.call(dlg.querySelectorAll('.categories input'), - checkbox => checkbox.click()); - assert.strictEqual(dlg.categoryFilter(), 'disabled-by-default-three'); - assert.isFalse(dlg.usingPreset_()); - assert.isTrue( - dlg.querySelector('#category-preset-Manually-select-settings').checked); - - // After the dialog is opened again, it should be using the default preset. - // More importantly, the default preset should NOT be modified. - dlg = createDialog(); - assert.strictEqual(dlg.categoryFilter(), '-one,-two'); - assert.isTrue(dlg.usingPreset_()); - assert.isFalse( - dlg.querySelector('#category-preset-Manually-select-settings').checked); - }); - - test('recordSelectionDialog_changePresets', function() { - tr.b.Settings.set('two', true, 'categories'); - tr.b.Settings.set('three', false, 'categories'); - tr.b.Settings.set('disabled-by-default-cc.debug', true, 'categories'); - tr.b.Settings.set('recordSelectionDialog.tracingRecordMode', - 'record-as-much-as-possible'); - tr.b.Settings.set('recordSelectionDialog.useSystemTracing', true); - tr.b.Settings.set('recordSelectionDialog.useSampling', false); - - var dlg = new tr.ui.e.about_tracing.RecordSelectionDialog(); - dlg.categories = ['disabled-by-default-one']; - dlg.settings_key = 'categories'; - // Note: currentlyChosenPreset is not set here, so the default is used. - dlg.updateForm_(); - - // Preset mode is on. - assert.isTrue(dlg.usingPreset_()); - - // Make sure the default filter is returned. - assert.equal(dlg.categoryFilter(), - '-three,-two'); - - // Make sure the default tracing types are returned. - assert.equal(dlg.tracingRecordMode, 'record-as-much-as-possible'); - assert.isTrue(dlg.useSystemTracing); - assert.isFalse(dlg.useSampling); - - // Make sure the manual settings are not visible. - var classList = dlg.categoriesView_.classList; - assert.isTrue(classList.contains('categories-column-view-hidden')); - - // Switch to manual settings and verify the default values are not returned. - dlg.currentlyChosenPreset = []; - - // Preset mode is off. - assert.isFalse(dlg.usingPreset_()); - - // Make sure the default filter is returned. - assert.equal(dlg.categoryFilter(), '-three,disabled-by-default-cc.debug'); - - // Make sure the tracing types set by catalog are returned. - assert.equal(dlg.tracingRecordMode, 'record-as-much-as-possible'); - assert.isTrue(dlg.useSystemTracing); - assert.isFalse(dlg.useSampling); - assert.isFalse(classList.contains('categories-column-view-hidden')); - - // Switch to the graphics, rendering, and rasterization preset. - dlg.currentlyChosenPreset = ['blink', 'cc', 'renderer', - 'disabled-by-default-cc.debug']; - assert.equal(dlg.categoryFilter(), - 'disabled-by-default-cc.debug,-three,-two'); - }); - - test('recordSelectionDialog_savedPreset', function() { - tr.b.Settings.set('two', true, 'categories'); - tr.b.Settings.set('three', false, 'categories'); - tr.b.Settings.set('recordSelectionDialog.tracingRecordMode', - 'record-continuously'); - tr.b.Settings.set('recordSelectionDialog.useSystemTracing', true); - tr.b.Settings.set('recordSelectionDialog.useSampling', true); - tr.b.Settings.set('tr.ui.e.about_tracing.record_selection_dialog_preset', - ['blink', 'cc', 'renderer', 'cc.debug']); - - var dlg = new tr.ui.e.about_tracing.RecordSelectionDialog(); - dlg.categories = ['disabled-by-default-one']; - dlg.settings_key = 'categories'; - dlg.updateForm_(); - - // Make sure the correct filter is returned. - assert.equal(dlg.categoryFilter(), '-three,-two'); - - // Make sure the correct tracing types are returned. - assert.equal(dlg.tracingRecordMode, 'record-continuously'); - assert.isTrue(dlg.useSystemTracing); - assert.isTrue(dlg.useSampling); - - // Make sure the manual settings are not visible. - var classList = dlg.categoriesView_.classList; - assert.isTrue(classList.contains('categories-column-view-hidden')); - - // Switch to manual settings and verify the default values are not returned. - dlg.currentlyChosenPreset = []; - assert.equal(dlg.categoryFilter(), '-three'); - assert.equal(dlg.tracingRecordMode, 'record-continuously'); - assert.isTrue(dlg.useSystemTracing); - assert.isTrue(dlg.useSampling); - assert.isFalse(classList.contains('categories-column-view-hidden')); - }); - - test('recordSelectionDialog_categoryFilters', function() { - tr.b.Settings.set('default1', true, 'categories'); - tr.b.Settings.set('disabled1', false, 'categories'); - tr.b.Settings.set('disabled-by-default-cc.disabled2', false, 'categories'); - tr.b.Settings.set('input', true, 'categories'); - tr.b.Settings.set('blink', true, 'categories'); - tr.b.Settings.set('cc', false, 'categories'); - tr.b.Settings.set('disabled-by-default-cc.debug', true, 'categories'); - - var dlg = new tr.ui.e.about_tracing.RecordSelectionDialog(); - dlg.settings_key = 'categories'; - dlg.categories = []; - dlg.currentlyChosenPreset = []; - dlg.updateForm_(); - - assert.equal(dlg.categoryFilter(), - '-cc,-disabled1,disabled-by-default-cc.debug'); - - // Switch to the graphics, rendering, and rasterization preset. - dlg.currentlyChosenPreset = ['blink', 'cc', 'renderer', - 'disabled-by-default-cc.debug']; - assert.equal(dlg.categoryFilter(), - '-default1,disabled-by-default-cc.debug,-disabled1,-input'); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/about_tracing/tracing_controller_client.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/about_tracing/tracing_controller_client.html deleted file mode 100644 index 8c34b00e859..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/about_tracing/tracing_controller_client.html +++ /dev/null @@ -1,36 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/base.html"> -<script> -'use strict'; - -tr.exportTo('tr.ui.e.about_tracing', function() { - /** - * Communicates with content/browser/tracing_controller_impl.cc - * - * @constructor - */ - function TracingControllerClient() { } - - TracingControllerClient.prototype = { - beginMonitoring: function(monitoringOptions) { }, - endMonitoring: function() { }, - captureMonitoring: function() { }, - getMonitoringStatus: function() { }, - getCategories: function() { }, - beginRecording: function(recordingOptions) { }, - beginGetBufferPercentFull: function() { }, - endRecording: function() { }, - defaultTraceName: function() { } - }; - - return { - TracingControllerClient: TracingControllerClient - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/about_tracing/xhr_based_tracing_controller_client.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/about_tracing/xhr_based_tracing_controller_client.html deleted file mode 100644 index c7c68cc8483..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/about_tracing/xhr_based_tracing_controller_client.html +++ /dev/null @@ -1,113 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/base64.html"> -<link rel="import" - href="/tracing/ui/extras/about_tracing/tracing_controller_client.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.e.about_tracing', function() { - var Base64 = tr.b.Base64; - - function beginXhr(method, path, data) { - if (data === undefined) - data = null; - return new Promise(function(resolve, reject) { - var req = new XMLHttpRequest(); - if (method != 'POST' && data !== null) - throw new Error('Non-POST should have data==null'); - req.open(method, path, true); - req.onreadystatechange = function(e) { - if (req.readyState == 4) { - window.setTimeout(function() { - if (req.status == 200 && req.responseText != '##ERROR##') { - resolve(req.responseText); - } else { - reject(new Error('Error occured at ' + path)); - } - }, 0); - } - }; - req.send(data); - }); - } - - /** - * @constructor - */ - function XhrBasedTracingControllerClient() { } - - XhrBasedTracingControllerClient.prototype = { - __proto__: tr.ui.e.about_tracing.TracingControllerClient.prototype, - - beginMonitoring: function(monitoringOptions) { - var monitoringOptionsB64 = Base64.btoa(JSON.stringify(monitoringOptions)); - return beginXhr('GET', '/json/begin_monitoring?' + monitoringOptionsB64); - }, - - endMonitoring: function() { - return beginXhr('GET', '/json/end_monitoring'); - }, - - captureMonitoring: function() { - return beginXhr('GET', '/json/capture_monitoring_compressed').then( - function(data) { - var decoded_size = Base64.getDecodedBufferLength(data); - var buffer = new ArrayBuffer(decoded_size); - Base64.DecodeToTypedArray(data, new DataView(buffer)); - return buffer; - } - ); - }, - - getMonitoringStatus: function() { - return beginXhr('GET', '/json/get_monitoring_status').then( - function(monitoringOptionsB64) { - return JSON.parse(Base64.atob(monitoringOptionsB64)); - }); - }, - - getCategories: function() { - return beginXhr('GET', '/json/categories').then( - function(json) { - return JSON.parse(json); - }); - }, - - beginRecording: function(recordingOptions) { - var recordingOptionsB64 = Base64.btoa(JSON.stringify(recordingOptions)); - return beginXhr('GET', '/json/begin_recording?' + - recordingOptionsB64); - }, - - beginGetBufferPercentFull: function() { - return beginXhr('GET', '/json/get_buffer_percent_full'); - }, - - endRecording: function() { - return beginXhr('GET', '/json/end_recording_compressed').then( - function(data) { - var decoded_size = Base64.getDecodedBufferLength(data); - var buffer = new ArrayBuffer(decoded_size); - Base64.DecodeToTypedArray(data, new DataView(buffer)); - return buffer; - } - ); - }, - - defaultTraceName: function() { - return 'trace.json.gz'; - } - }; - - return { - XhrBasedTracingControllerClient: XhrBasedTracingControllerClient - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/cc.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/cc.html deleted file mode 100644 index 79ba7e593c0..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/cc.html +++ /dev/null @@ -1,14 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/extras/chrome/cc/cc.html"> -<link rel="import" href="/tracing/ui/extras/chrome/cc/display_item_list_view.html"> -<link rel="import" href="/tracing/ui/extras/chrome/cc/layer_tree_host_impl_view.html"> -<link rel="import" href="/tracing/ui/extras/chrome/cc/picture_view.html"> -<link rel="import" href="/tracing/ui/extras/chrome/cc/raster_task_selection.html"> -<link rel="import" href="/tracing/ui/extras/chrome/cc/raster_task_view.html"> -<link rel="import" href="/tracing/ui/extras/chrome/cc/tile_view.html"> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/display_item_debugger.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/display_item_debugger.html deleted file mode 100644 index 55a028ce4c3..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/display_item_debugger.html +++ /dev/null @@ -1,467 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/base64.html"> -<link rel="import" href="/tracing/extras/chrome/cc/picture.html"> -<link rel="import" href="/tracing/ui/analysis/generic_object_view.html"> -<link rel="import" href="/tracing/ui/base/drag_handle.html"> -<link rel="import" href="/tracing/ui/base/hotkey_controller.html"> -<link rel="import" href="/tracing/ui/base/info_bar.html"> -<link rel="import" href="/tracing/ui/base/list_view.html"> -<link rel="import" href="/tracing/ui/base/mouse_mode_selector.html"> -<link rel="import" href="/tracing/ui/base/overlay.html"> -<link rel="import" href="/tracing/ui/base/utils.html"> -<link rel="import" href="/tracing/ui/extras/chrome/cc/display_item_list_item.html"> -<link rel="import" href="/tracing/ui/extras/chrome/cc/picture_ops_list_view.html"> - -<template id="tr-ui-e-chrome-cc-display-item-debugger-template"> - <style> - * /deep/ tr-ui-e-chrome-cc-display-item-debugger { - -webkit-flex: 1 1 auto; - display: -webkit-flex; - } - - * /deep/ tr-ui-e-chrome-cc-display-item-debugger > left-panel { - -webkit-flex-direction: column; - display: -webkit-flex; - min-width: 300px; - overflow-y: auto; - } - - * /deep/ tr-ui-e-chrome-cc-display-item-debugger > left-panel > - display-item-info { - -webkit-flex: 1 1 auto; - padding-top: 2px; - } - - * /deep/ tr-ui-e-chrome-cc-display-item-debugger > left-panel > - display-item-info .title { - font-weight: bold; - margin-left: 5px; - margin-right: 5px; - } - - * /deep/ tr-ui-e-chrome-cc-display-item-debugger > left-panel > - display-item-info .export { - margin: 5px; - } - - * /deep/ tr-ui-e-chrome-cc-display-item-debugger > tr-ui-b-drag-handle { - -webkit-flex: 0 0 auto; - } - - * /deep/ tr-ui-e-chrome-cc-display-item-debugger > right-panel { - -webkit-flex: 1 1 auto; - display: -webkit-flex; - } - - * /deep/ tr-ui-e-chrome-cc-display-item-debugger > left-panel > - display-item-info > header { - border-bottom: 1px solid #555; - } - - /*************************************************/ - - * /deep/ tr-ui-e-chrome-cc-display-item-debugger > right-panel > - tr-ui-e-chrome-cc-picture-ops-list-view.hasPictureOps { - display: block; - } - - * /deep/ tr-ui-e-chrome-cc-display-item-debugger > right-panel > - tr-ui-b-drag-handle.hasPictureOps { - display: block; - } - - * /deep/ tr-ui-e-chrome-cc-display-item-debugger > right-panel > - tr-ui-e-chrome-cc-picture-ops-list-view { - display: none; - overflow-y: auto; - } - - * /deep/ tr-ui-e-chrome-cc-display-item-debugger > right-panel > - tr-ui-b-drag-handle { - display: none; - } - - * /deep/ tr-ui-e-chrome-cc-display-item-debugger raster-area { - -webkit-flex: 1 1 auto; - background-color: #ddd; - min-height: 200px; - min-width: 200px; - overflow-y: auto; - padding-left: 5px; - } - </style> - - <left-panel> - <display-item-info> - <header> - <span class='title'>Display Item List</span> - <span class='size'></span> - <div class='export'> - <input class='dlfilename' type='text' value='displayitemlist.json' /> - <button class='dlexport'>Export display item list</button> - </div> - <div class='export'> - <input class='skpfilename' type='text' value='skpicture.skp' /> - <button class='skpexport'>Export list as SkPicture</button> - </div> - </header> - </display-item-info> - </left-panel> - <right-panel> - <raster-area><canvas></canvas></raster-area> - </right-panel> -</template> - -<script> -'use strict'; - -tr.exportTo('tr.ui.e.chrome.cc', function() { - var THIS_DOC = document.currentScript.ownerDocument; - - /** - * DisplayItemDebugger is a view of a DisplayItemListSnapshot for inspecting - * a display item list and the pictures within it. - * - * @constructor - */ - var DisplayItemDebugger = tr.ui.b.define( - 'tr-ui-e-chrome-cc-display-item-debugger'); - - DisplayItemDebugger.prototype = { - __proto__: HTMLUnknownElement.prototype, - - decorate: function() { - var node = tr.ui.b.instantiateTemplate( - '#tr-ui-e-chrome-cc-display-item-debugger-template', THIS_DOC); - - this.appendChild(node); - - this.pictureAsImageData_ = undefined; - this.zoomScaleValue_ = 1; - - this.sizeInfo_ = this.querySelector('.size'); - this.rasterArea_ = this.querySelector('raster-area'); - this.rasterCanvas_ = this.rasterArea_.querySelector('canvas'); - this.rasterCtx_ = this.rasterCanvas_.getContext('2d'); - - this.trackMouse_(); - - this.displayItemInfo_ = this.querySelector('display-item-info'); - this.displayItemInfo_.addEventListener( - 'click', this.onDisplayItemInfoClick_.bind(this), false); - - this.displayItemListView_ = new tr.ui.b.ListView(); - this.displayItemListView_.addEventListener('selection-changed', - this.onDisplayItemListSelection_.bind(this)); - this.displayItemInfo_.appendChild(this.displayItemListView_); - - this.displayListFilename_ = this.querySelector('.dlfilename'); - this.displayListExportButton_ = this.querySelector('.dlexport'); - this.displayListExportButton_.addEventListener( - 'click', this.onExportDisplayListClicked_.bind(this)); - - this.skpFilename_ = this.querySelector('.skpfilename'); - this.skpExportButton_ = this.querySelector('.skpexport'); - this.skpExportButton_.addEventListener( - 'click', this.onExportSkPictureClicked_.bind(this)); - - var leftPanel = this.querySelector('left-panel'); - - var middleDragHandle = document.createElement('tr-ui-b-drag-handle'); - middleDragHandle.horizontal = false; - middleDragHandle.target = leftPanel; - - var rightPanel = this.querySelector('right-panel'); - - this.infoBar_ = document.createElement('tr-ui-b-info-bar'); - this.rasterArea_.insertBefore(this.infoBar_, this.rasterCanvas_); - - this.insertBefore(middleDragHandle, rightPanel); - - this.picture_ = undefined; - - this.pictureOpsListView_ = new tr.ui.e.chrome.cc.PictureOpsListView(); - rightPanel.insertBefore(this.pictureOpsListView_, this.rasterArea_); - - this.pictureOpsListDragHandle_ = - document.createElement('tr-ui-b-drag-handle'); - this.pictureOpsListDragHandle_.horizontal = false; - this.pictureOpsListDragHandle_.target = this.pictureOpsListView_; - rightPanel.insertBefore(this.pictureOpsListDragHandle_, this.rasterArea_); - }, - - get picture() { - return this.picture_; - }, - - set displayItemList(displayItemList) { - this.displayItemList_ = displayItemList; - this.picture = this.displayItemList_; - - this.displayItemListView_.clear(); - this.displayItemList_.items.forEach(function(item) { - var listItem = document.createElement( - 'tr-ui-e-chrome-cc-display-item-list-item'); - listItem.data = item; - this.displayItemListView_.appendChild(listItem); - }.bind(this)); - }, - - set picture(picture) { - this.picture_ = picture; - - // Hide the ops list if we are showing the "main" display item list. - var showOpsList = picture && picture !== this.displayItemList_; - this.updateDrawOpsList_(showOpsList); - - if (picture) { - var size = this.getRasterCanvasSize_(); - this.rasterCanvas_.width = size.width; - this.rasterCanvas_.height = size.height; - } - - var bounds = this.rasterArea_.getBoundingClientRect(); - var selectorBounds = this.mouseModeSelector_.getBoundingClientRect(); - this.mouseModeSelector_.pos = { - x: (bounds.right - selectorBounds.width - 10), - y: bounds.top - }; - - this.rasterize_(); - - this.scheduleUpdateContents_(); - }, - - getRasterCanvasSize_: function() { - var style = window.getComputedStyle(this.rasterArea_); - var width = parseInt(style.width); - var height = parseInt(style.height); - if (this.picture_) { - width = Math.max(width, this.picture_.layerRect.width); - height = Math.max(height, this.picture_.layerRect.height); - } - - return { - width: width, - height: height - }; - }, - - scheduleUpdateContents_: function() { - if (this.updateContentsPending_) - return; - this.updateContentsPending_ = true; - tr.b.requestAnimationFrameInThisFrameIfPossible( - this.updateContents_.bind(this) - ); - }, - - updateContents_: function() { - this.updateContentsPending_ = false; - - if (this.picture_) { - this.sizeInfo_.textContent = '(' + - this.picture_.layerRect.width + ' x ' + - this.picture_.layerRect.height + ')'; - } - - // Return if picture hasn't finished rasterizing. - if (!this.pictureAsImageData_) - return; - - this.infoBar_.visible = false; - this.infoBar_.removeAllButtons(); - if (this.pictureAsImageData_.error) { - this.infoBar_.message = 'Cannot rasterize...'; - this.infoBar_.addButton('More info...', function(e) { - var overlay = new tr.ui.b.Overlay(); - overlay.textContent = this.pictureAsImageData_.error; - overlay.visible = true; - e.stopPropagation(); - return false; - }.bind(this)); - this.infoBar_.visible = true; - } - - this.drawPicture_(); - }, - - drawPicture_: function() { - var size = this.getRasterCanvasSize_(); - if (size.width !== this.rasterCanvas_.width) - this.rasterCanvas_.width = size.width; - if (size.height !== this.rasterCanvas_.height) - this.rasterCanvas_.height = size.height; - - this.rasterCtx_.clearRect(0, 0, size.width, size.height); - - if (!this.picture_ || !this.pictureAsImageData_.imageData) - return; - - var imgCanvas = this.pictureAsImageData_.asCanvas(); - var w = imgCanvas.width; - var h = imgCanvas.height; - this.rasterCtx_.drawImage(imgCanvas, 0, 0, w, h, - 0, 0, w * this.zoomScaleValue_, - h * this.zoomScaleValue_); - }, - - rasterize_: function() { - if (this.picture_) { - this.picture_.rasterize( - { - showOverdraw: false - }, - this.onRasterComplete_.bind(this)); - } - }, - - onRasterComplete_: function(pictureAsImageData) { - this.pictureAsImageData_ = pictureAsImageData; - this.scheduleUpdateContents_(); - }, - - onDisplayItemListSelection_: function(e) { - var selected = this.displayItemListView_.selectedElement; - - if (!selected) { - this.picture = this.displayItemList_; - return; - } - - var index = Array.prototype.indexOf.call( - this.displayItemListView_.children, selected); - var displayItem = this.displayItemList_.items[index]; - if (displayItem && displayItem.skp64) - this.picture = new tr.e.cc.Picture( - displayItem.skp64, this.displayItemList_.layerRect); - else - this.picture = undefined; - }, - - onDisplayItemInfoClick_: function(e) { - if (e && e.target == this.displayItemInfo_) { - this.displayItemListView_.selectedElement = undefined; - } - }, - - updateDrawOpsList_: function(showOpsList) { - if (showOpsList) { - this.pictureOpsListView_.picture = this.picture_; - if (this.pictureOpsListView_.numOps > 0) { - this.pictureOpsListView_.classList.add('hasPictureOps'); - this.pictureOpsListDragHandle_.classList.add('hasPictureOps'); - } - } else { - this.pictureOpsListView_.classList.remove('hasPictureOps'); - this.pictureOpsListDragHandle_.classList.remove('hasPictureOps'); - } - }, - - trackMouse_: function() { - this.mouseModeSelector_ = document.createElement( - 'tr-ui-b-mouse-mode-selector'); - this.mouseModeSelector_.targetElement = this.rasterArea_; - this.rasterArea_.appendChild(this.mouseModeSelector_); - - this.mouseModeSelector_.supportedModeMask = - tr.ui.b.MOUSE_SELECTOR_MODE.ZOOM; - this.mouseModeSelector_.mode = tr.ui.b.MOUSE_SELECTOR_MODE.ZOOM; - this.mouseModeSelector_.defaultMode = tr.ui.b.MOUSE_SELECTOR_MODE.ZOOM; - this.mouseModeSelector_.settingsKey = 'pictureDebugger.mouseModeSelector'; - - this.mouseModeSelector_.addEventListener('beginzoom', - this.onBeginZoom_.bind(this)); - this.mouseModeSelector_.addEventListener('updatezoom', - this.onUpdateZoom_.bind(this)); - this.mouseModeSelector_.addEventListener('endzoom', - this.onEndZoom_.bind(this)); - }, - - onBeginZoom_: function(e) { - this.isZooming_ = true; - - this.lastMouseViewPos_ = this.extractRelativeMousePosition_(e); - - e.preventDefault(); - }, - - onUpdateZoom_: function(e) { - if (!this.isZooming_) - return; - - var currentMouseViewPos = this.extractRelativeMousePosition_(e); - - // Take the distance the mouse has moved and we want to zoom at about - // 1/1000th of that speed. 0.01 feels jumpy. This could possibly be tuned - // more if people feel it's too slow. - this.zoomScaleValue_ += - ((this.lastMouseViewPos_.y - currentMouseViewPos.y) * 0.001); - this.zoomScaleValue_ = Math.max(this.zoomScaleValue_, 0.1); - - this.drawPicture_(); - - this.lastMouseViewPos_ = currentMouseViewPos; - }, - - onEndZoom_: function(e) { - this.lastMouseViewPos_ = undefined; - this.isZooming_ = false; - e.preventDefault(); - }, - - extractRelativeMousePosition_: function(e) { - return { - x: e.clientX - this.rasterArea_.offsetLeft, - y: e.clientY - this.rasterArea_.offsetTop - }; - }, - - saveFile_: function(filename, rawData) { - if (!rawData) - return; - - // Convert this String into an Uint8Array - var length = rawData.length; - var arrayBuffer = new ArrayBuffer(length); - var uint8Array = new Uint8Array(arrayBuffer); - for (var c = 0; c < length; c++) - uint8Array[c] = rawData.charCodeAt(c); - - // Create a blob URL from the binary array. - var blob = new Blob([uint8Array], {type: 'application/octet-binary'}); - var blobUrl = window.URL.createObjectURL(blob); - - // Create a link and click on it. - var link = document.createElementNS('http://www.w3.org/1999/xhtml', 'a'); - link.href = blobUrl; - link.download = filename; - var event = document.createEvent('MouseEvents'); - event.initMouseEvent( - 'click', true, false, window, 0, 0, 0, 0, 0, - false, false, false, false, 0, null); - link.dispatchEvent(event); - }, - - onExportDisplayListClicked_: function() { - var rawData = JSON.stringify(this.displayItemList_.items); - this.saveFile_(this.displayListFilename_.value, rawData); - }, - - onExportSkPictureClicked_: function() { - var rawData = tr.b.Base64.atob(this.picture_.getBase64SkpData()); - this.saveFile_(this.skpFilename_.value, rawData); - } - }; - - return { - DisplayItemDebugger: DisplayItemDebugger - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/display_item_debugger_test.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/display_item_debugger_test.html deleted file mode 100644 index 91ea9ea4304..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/display_item_debugger_test.html +++ /dev/null @@ -1,130 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/extras/chrome/cc/display_item_list.html"> -<link rel="import" href="/tracing/ui/extras/chrome/cc/display_item_debugger.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - test('instantiate', function() { - var displayItemList = new tr.e.cc.DisplayItemListSnapshot( - {id: '31415'}, - 10, - { - 'params': { - 'layer_rect': [-15, -15, 46, 833], - 'items': [ - 'BeginClipDisplayItem', - 'EndClipDisplayItem' - ] - }, - 'skp64': '[another skia picture in base64]'}); - displayItemList.preInitialize(); - displayItemList.initialize(); - - var dbg = new tr.ui.e.chrome.cc.DisplayItemDebugger(); - this.addHTMLOutput(dbg); - assert.isUndefined(dbg.displayItemList_); - assert.isUndefined(dbg.picture_); - dbg.displayItemList = displayItemList; - assert.isDefined(dbg.displayItemList_); - assert.isDefined(dbg.picture_); - assert.equal(dbg.displayItemList_.items.length, 2); - dbg.style.border = '1px solid black'; - }); - - test('selections', function() { - var displayItemList = new tr.e.cc.DisplayItemListSnapshot( - {id: '31415'}, - 10, - { - 'params': { - 'layer_rect': [-15, -15, 46, 833], - 'items': [ - 'BeginClipDisplayItem', - 'TransformDisplayItem', - {'name': 'DrawingDisplayItem', 'skp64': '[skia picture in base64]'}, - 'EndTransformDisplayItem', - 'EndClipDisplayItem' - ] - }, - 'skp64': '[another skia picture in base64]'}); - displayItemList.preInitialize(); - displayItemList.initialize(); - - var dbg = new tr.ui.e.chrome.cc.DisplayItemDebugger(); - this.addHTMLOutput(dbg); - dbg.displayItemList = displayItemList; - assert.isDefined(dbg.displayItemList_); - assert.isDefined(dbg.picture_); - assert.equal(dbg.displayItemList_.items.length, 5); - - var initialPicture = dbg.picture_; - assert.isAbove(initialPicture.guid, 0); - - // Select the drawing display item and make sure the picture updates. - var listView = dbg.displayItemListView_; - listView.selectedElement = listView.getElementByIndex(3); - var updatedPicture = dbg.picture_; - assert.isAbove(updatedPicture.guid, 0); - assert.notEqual(initialPicture.guid, updatedPicture.guid); - - // Select the TransformDisplayItem and make sure the picture is blank. - listView.selectedElement = listView.getElementByIndex(2); - assert.isUndefined(dbg.picture_); - - // Deselect a list item and make sure the picture is reset to the original. - listView.selectedElement = undefined; - updatedPicture = dbg.picture_; - assert.isAbove(updatedPicture.guid, 0); - assert.equal(initialPicture.guid, updatedPicture.guid); - - dbg.style.border = '1px solid black'; - }); - - test('export', function() { - var displayItemList = new tr.e.cc.DisplayItemListSnapshot( - {id: '31415'}, - 10, - { - 'params': { - 'layer_rect': [-15, -15, 46, 833], - 'items': [ - 'BeginClipDisplayItem', - 'EndClipDisplayItem' - ] - }, - 'skp64': 'c2twaWN0dXJl'}); - displayItemList.preInitialize(); - displayItemList.initialize(); - - var dbg = new tr.ui.e.chrome.cc.DisplayItemDebugger(); - this.addHTMLOutput(dbg); - dbg.displayItemList = displayItemList; - - var onSaveDisplayListCalled = false; - dbg.saveFile_ = function(filename, rawData) { - onSaveDisplayListCalled = true; - assert.equal(filename, 'displayitemlist.json'); - assert.equal(rawData, '["BeginClipDisplayItem","EndClipDisplayItem"]'); - }; - dbg.onExportDisplayListClicked_(); - assert(onSaveDisplayListCalled); - - var onSaveSkPictureCalled = false; - dbg.saveFile_ = function(filename, rawData) { - onSaveSkPictureCalled = true; - assert.equal(filename, 'skpicture.skp'); - assert.equal(rawData, 'skpicture'); - }; - dbg.onExportSkPictureClicked_(); - assert(onSaveSkPictureCalled); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/display_item_list_item.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/display_item_list_item.html deleted file mode 100644 index b34495a6b41..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/display_item_list_item.html +++ /dev/null @@ -1,124 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright 2016 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<!-- -An element displaying basic information about a display item in a list view. ---> -<polymer-element name="tr-ui-e-chrome-cc-display-item-list-item"> - <template> - <style> - :host { - border-bottom: 1px solid #555; - display: block; - font-size: 12px; - padding: 3px 5px; - } - - :host(:hover) { - background-color: #f0f0f0; - cursor: pointer; - } - - .header { - font-weight: bold; - margin: 2px 0; - } - - .header > .extra { - background-color: #777; - border-radius: 4px; - color: white; - margin: 0 6px; - text-decoration: none; - padding: 2px 4px; - } - - .raw-details { - white-space: pre-wrap; - } - - .details > dl { - margin: 0; - } - - :host(:not([selected])) .details { - display: none; - } - </style> - <div class="header"> - {{name}} - <template if="{{richDetails && richDetails.skp64}}"> - <a class="extra" - href="data:application/octet-stream;base64,{{richDetails.skp64}}" - download="drawing.skp" on-click="{{stopPropagation}}">SKP</a> - </template> - </div> - <div class="details"> - <template if="{{rawDetails}}"> - <div class="raw-details">{{rawDetails}}</div> - </template> - <template if="{{richDetails}}" bind="{{richDetails}}"> - <dl> - <template if="{{cullRect}}" bind="{{cullRect}}"> - <dt>Cull rect</dt> - <dd>{{x}},{{y}} {{width}}×{{height}}</dd> - </template> - <template if="{{visualRect}}" bind="{{visualRect}}"> - <dt>Visual rect</dt> - <dd>{{x}},{{y}} {{width}}×{{height}}</dd> - </template> - </dl> - </template> - </div> - </template> - <script> - 'use strict'; - (function() { - // Extracts the "type" and "details" parts of the unstructured (plaintext) - // display item format, even if the details span multiple lines. - // For example, given "FooDisplayItem type=hello\nworld", produces - // "FooDisplayItem" as the first capture and "type=hello\nworld" as the - // second. Either capture could be the empty string, but this regex will - // still successfully match. - var DETAILS_SPLIT_REGEX = /^(\S*)\s*([\S\s]*)$/; - - Polymer({ - created: function() { - this.name = ''; - this.rawDetails = ''; - this.richDetails = undefined; - this.data_ = undefined; - }, - - get data() { - return this.data_; - }, - - set data(data) { - this.data_ = data; - - if (!data) { - this.name = 'DATA MISSING'; - this.rawDetails = ''; - this.richDetails = undefined; - } else if (typeof data === 'string') { - var match = data.match(DETAILS_SPLIT_REGEX); - this.name = match[1]; - this.rawDetails = match[2]; - this.richDetails = undefined; - } else { - this.name = data.name; - this.rawDetails = ''; - this.richDetails = data; - } - }, - - stopPropagation: function(e) { e.stopPropagation(); } - }); - })(); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/display_item_list_view.css b/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/display_item_list_view.css deleted file mode 100644 index 2265f4a1bfc..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/display_item_list_view.css +++ /dev/null @@ -1,9 +0,0 @@ -/* Copyright (c) 2015 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -* /deep/ .tr-ui-e-chrome-cc-display-item-list-view { - -webkit-flex: 1 1 auto !important; - display: -webkit-flex; -} diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/display_item_list_view.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/display_item_list_view.html deleted file mode 100644 index c66327afc57..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/display_item_list_view.html +++ /dev/null @@ -1,53 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="stylesheet" href="/tracing/ui/extras/chrome/cc/display_item_list_view.css"> - -<link rel="import" href="/tracing/extras/chrome/cc/display_item_list.html"> -<link rel="import" href="/tracing/ui/analysis/generic_object_view.html"> -<link rel="import" href="/tracing/ui/analysis/object_snapshot_view.html"> -<link rel="import" href="/tracing/ui/extras/chrome/cc/display_item_debugger.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.e.chrome.cc', function() { - /* - * Displays a display item snapshot in a human readable form. - * @constructor - */ - var DisplayItemSnapshotView = tr.ui.b.define( - 'tr-ui-e-chrome-cc-display-item-list-view', - tr.ui.analysis.ObjectSnapshotView); - - DisplayItemSnapshotView.prototype = { - __proto__: tr.ui.analysis.ObjectSnapshotView.prototype, - - decorate: function() { - this.classList.add('tr-ui-e-chrome-cc-display-item-list-view'); - this.displayItemDebugger_ = new tr.ui.e.chrome.cc.DisplayItemDebugger(); - this.appendChild(this.displayItemDebugger_); - }, - - updateContents: function() { - if (this.objectSnapshot_ && this.displayItemDebugger_) - this.displayItemDebugger_.displayItemList = this.objectSnapshot_; - } - }; - - tr.ui.analysis.ObjectSnapshotView.register( - DisplayItemSnapshotView, - { - typeNames: ['cc::DisplayItemList'], - showInstances: false - }); - - return { - DisplayItemSnapshotView: DisplayItemSnapshotView - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/images/input-event.png b/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/images/input-event.png Binary files differdeleted file mode 100644 index a2b7710d3c4..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/images/input-event.png +++ /dev/null diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/images/input-event.svg b/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/images/input-event.svg deleted file mode 100644 index 00531ac68d7..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/images/input-event.svg +++ /dev/null @@ -1,114 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<!-- Created with Inkscape (http://www.inkscape.org/) --> - -<svg - xmlns:dc="http://purl.org/dc/elements/1.1/" - xmlns:cc="http://creativecommons.org/ns#" - xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" - xmlns:svg="http://www.w3.org/2000/svg" - xmlns="http://www.w3.org/2000/svg" - xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" - xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - width="744.09448819" - height="1052.3622047" - id="svg2" - version="1.1" - inkscape:version="0.48.4 r9939" - sodipodi:docname="New document 1"> - <defs - id="defs4"> - <filter - inkscape:collect="always" - id="filter3791"> - <feGaussianBlur - inkscape:collect="always" - stdDeviation="2.7246316" - id="feGaussianBlur3793" /> - </filter> - </defs> - <sodipodi:namedview - id="base" - pagecolor="#ffffff" - bordercolor="#666666" - borderopacity="1.0" - inkscape:pageopacity="0.0" - inkscape:pageshadow="2" - inkscape:zoom="2.8" - inkscape:cx="195.13782" - inkscape:cy="982.30556" - inkscape:document-units="px" - inkscape:current-layer="layer1" - showgrid="false" - inkscape:window-width="1215" - inkscape:window-height="860" - inkscape:window-x="2219" - inkscape:window-y="113" - inkscape:window-maximized="0" /> - <metadata - id="metadata7"> - <rdf:RDF> - <cc:Work - rdf:about=""> - <dc:format>image/svg+xml</dc:format> - <dc:type - rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> - <dc:title></dc:title> - </cc:Work> - </rdf:RDF> - </metadata> - <g - inkscape:label="Layer 1" - inkscape:groupmode="layer" - id="layer1"> - <g - id="g3882" - style="opacity:0.5" - inkscape:export-filename="/tmp/input-event.png" - inkscape:export-xdpi="82.07" - inkscape:export-ydpi="82.07"> - <path - transform="matrix(1.0152631,0,0,1.0152631,-0.71357503,0.46150497)" - sodipodi:type="arc" - style="opacity:0.50934604000000006;color:#000000;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:5;marker:none;visibility:visible;display:inline;overflow:visible;filter:url(#filter3791);enable-background:accumulate" - id="path3755" - sodipodi:cx="177.78685" - sodipodi:cy="100.79848" - sodipodi:rx="42.426407" - sodipodi:ry="42.426407" - d="m 220.21326,100.79848 a 42.426407,42.426407 0 1 1 -84.85282,0 42.426407,42.426407 0 1 1 84.85282,0 z" /> - <path - transform="translate(-2,-2)" - d="m 220.21326,100.79848 a 42.426407,42.426407 0 1 1 -84.85282,0 42.426407,42.426407 0 1 1 84.85282,0 z" - sodipodi:ry="42.426407" - sodipodi:rx="42.426407" - sodipodi:cy="100.79848" - sodipodi:cx="177.78685" - id="path2985" - style="color:#000000;fill:#d4d4d4;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:8;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" - sodipodi:type="arc" /> - <path - inkscape:connector-curvature="0" - id="path3853" - d="m 175.28125,96.03125 0,8.46875 1,0 0,-8.46875 -1,0 z" - style="font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-indent:0;text-align:start;text-decoration:none;line-height:normal;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;text-anchor:start;baseline-shift:baseline;color:#000000;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate;font-family:Sans;-inkscape-font-specification:Sans" /> - <path - inkscape:connector-curvature="0" - id="path3859" - d="m 171.53125,99.75 0,1 8.46875,0 0,-1 -8.46875,0 z" - style="font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-indent:0;text-align:start;text-decoration:none;line-height:normal;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;text-anchor:start;baseline-shift:baseline;color:#000000;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate;font-family:Sans;-inkscape-font-specification:Sans" /> - </g> - <path - transform="matrix(1.2923213,0,0,1.2923213,-53.970887,-31.465544)" - d="m 220.21326,100.79848 a 42.426407,42.426407 0 1 1 -84.85282,0 42.426407,42.426407 0 1 1 84.85282,0 z" - sodipodi:ry="42.426407" - sodipodi:rx="42.426407" - sodipodi:cy="100.79848" - sodipodi:cx="177.78685" - id="path3867" - style="color:#000000;fill:none;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:8;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" - sodipodi:type="arc" - inkscape:export-filename="/tmp/input-event.png" - inkscape:export-xdpi="82.07" - inkscape:export-ydpi="82.07" /> - </g> -</svg> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/layer_picker.css b/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/layer_picker.css deleted file mode 100644 index 8841b4da953..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/layer_picker.css +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright (c) 2013 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -* /deep/ tr-ui-e-chrome-cc-layer-picker { - -webkit-flex-direction: column; - display: -webkit-flex; -} - -* /deep/ tr-ui-e-chrome-cc-layer-picker > top-controls { - -webkit-flex: 0 0 auto; - background-image: -webkit-gradient(linear, - 0 0, 100% 0, - from(#E5E5E5), - to(#D1D1D1)); - border-bottom: 1px solid #8e8e8e; - border-top: 1px solid white; - display: inline; - font-size: 14px; - padding-left: 2px; -} - -* /deep/ tr-ui-e-chrome-cc-layer-picker > top-controls input[type='checkbox'] { - vertical-align: -2px; -} - -* /deep/ tr-ui-e-chrome-cc-layer-picker > .x-list-view { - -webkit-flex: 1 1 auto; - font-family: monospace; - overflow: auto; -} - -* /deep/ tr-ui-e-chrome-cc-layer-picker > tr-ui-a-generic-object-view { - -webkit-flex: 0 0 auto; - height: 200px; - overflow: auto; -} - -* /deep/ tr-ui-e-chrome-cc-layer-picker > tr-ui-a-generic-object-view * { - -webkit-user-select: text !important; - cursor: text; -} diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/layer_picker.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/layer_picker.html deleted file mode 100644 index 780fe03d86c..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/layer_picker.html +++ /dev/null @@ -1,322 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="stylesheet" href="/tracing/ui/extras/chrome/cc/layer_picker.css"> - -<link rel="import" href="/tracing/extras/chrome/cc/constants.html"> -<link rel="import" href="/tracing/extras/chrome/cc/layer_tree_host_impl.html"> -<link rel="import" href="/tracing/extras/chrome/cc/util.html"> -<link rel="import" href="/tracing/ui/analysis/generic_object_view.html"> -<link rel="import" href="/tracing/model/event.html"> -<link rel="import" href="/tracing/ui/base/drag_handle.html"> -<link rel="import" href="/tracing/ui/base/list_view.html"> -<link rel="import" href="/tracing/ui/base/dom_helpers.html"> -<link rel="import" href="/tracing/ui/extras/chrome/cc/selection.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.e.chrome.cc', function() { - var constants = tr.e.cc.constants; - var bytesToRoundedMegabytes = tr.e.cc.bytesToRoundedMegabytes; - var RENDER_PASS_QUADS = - Math.max(constants.ACTIVE_TREE, constants.PENDING_TREE) + 1; - - /** - * @constructor - */ - var LayerPicker = tr.ui.b.define('tr-ui-e-chrome-cc-layer-picker'); - - LayerPicker.prototype = { - __proto__: HTMLUnknownElement.prototype, - - decorate: function() { - this.lthi_ = undefined; - this.controls_ = document.createElement('top-controls'); - this.renderPassQuads_ = false; - - - this.itemList_ = new tr.ui.b.ListView(); - this.appendChild(this.controls_); - - this.appendChild(this.itemList_); - - this.itemList_.addEventListener( - 'selection-changed', this.onItemSelectionChanged_.bind(this)); - - this.controls_.appendChild(tr.ui.b.createSelector( - this, 'whichTree', - 'layerPicker.whichTree', constants.ACTIVE_TREE, - [{label: 'Active tree', value: constants.ACTIVE_TREE}, - {label: 'Pending tree', value: constants.PENDING_TREE}, - {label: 'Render pass quads', value: RENDER_PASS_QUADS}])); - - this.showPureTransformLayers_ = false; - var showPureTransformLayers = tr.ui.b.createCheckBox( - this, 'showPureTransformLayers', - 'layerPicker.showPureTransformLayers', false, - 'Transform layers'); - showPureTransformLayers.classList.add('show-transform-layers'); - showPureTransformLayers.title = - 'When checked, pure transform layers are shown'; - this.controls_.appendChild(showPureTransformLayers); - }, - - get lthiSnapshot() { - return this.lthiSnapshot_; - }, - - set lthiSnapshot(lthiSnapshot) { - this.lthiSnapshot_ = lthiSnapshot; - this.updateContents_(); - }, - - get whichTree() { - return this.renderPassQuads_ ? constants.ACTIVE_TREE : this.whichTree_; - }, - - set whichTree(whichTree) { - this.whichTree_ = whichTree; - this.renderPassQuads_ = (whichTree == RENDER_PASS_QUADS); - this.updateContents_(); - tr.b.dispatchSimpleEvent(this, 'selection-change', false); - }, - - get layerTreeImpl() { - if (this.lthiSnapshot === undefined) - return undefined; - return this.lthiSnapshot.getTree(this.whichTree); - }, - - get isRenderPassQuads() { - return this.renderPassQuads_; - }, - - get showPureTransformLayers() { - return this.showPureTransformLayers_; - }, - - set showPureTransformLayers(show) { - if (this.showPureTransformLayers_ === show) - return; - this.showPureTransformLayers_ = show; - this.updateContents_(); - }, - - getRenderPassInfos_: function() { - if (!this.lthiSnapshot_) - return []; - - var renderPassInfo = []; - if (!this.lthiSnapshot_.args.frame || - !this.lthiSnapshot_.args.frame.renderPasses) - return renderPassInfo; - - var renderPasses = this.lthiSnapshot_.args.frame.renderPasses; - for (var i = 0; i < renderPasses.length; ++i) { - var info = {renderPass: renderPasses[i], - depth: 0, - id: i, - name: 'cc::RenderPass'}; - renderPassInfo.push(info); - } - return renderPassInfo; - }, - - getLayerInfos_: function() { - if (!this.lthiSnapshot_) - return []; - - var tree = this.lthiSnapshot_.getTree(this.whichTree_); - if (!tree) - return []; - - var layerInfos = []; - - var showPureTransformLayers = this.showPureTransformLayers_; - - function isPureTransformLayer(layer) { - if (layer.args.compositingReasons && - layer.args.compositingReasons.length != 1 && - layer.args.compositingReasons[0] != 'No reasons given') - return false; - - if (layer.args.drawsContent) - return false; - - return true; - } - var visitedLayers = {}; - function visitLayer(layer, depth, isMask, isReplica) { - if (visitedLayers[layer.layerId]) - return; - visitedLayers[layer.layerId] = true; - var info = {layer: layer, - depth: depth}; - - if (layer.args.drawsContent) - info.name = layer.objectInstance.name; - else - info.name = 'cc::LayerImpl'; - - if (layer.usingGpuRasterization) - info.name += ' (G)'; - - info.isMaskLayer = isMask; - info.replicaLayer = isReplica; - - if (showPureTransformLayers || !isPureTransformLayer(layer)) - layerInfos.push(info); - - }; - tree.iterLayers(visitLayer); - return layerInfos; - }, - - updateContents_: function() { - if (this.renderPassQuads_) - this.updateRenderPassContents_(); - else - this.updateLayerContents_(); - }, - - updateRenderPassContents_: function() { - this.itemList_.clear(); - - var selectedRenderPassId; - if (this.selection_ && this.selection_.associatedRenderPassId) - selectedRenderPassId = this.selection_.associatedRenderPassId; - - var renderPassInfos = this.getRenderPassInfos_(); - renderPassInfos.forEach(function(renderPassInfo) { - var renderPass = renderPassInfo.renderPass; - var id = renderPassInfo.id; - - var item = this.createElementWithDepth_(renderPassInfo.depth); - var labelEl = item.appendChild(tr.ui.b.createSpan()); - - labelEl.textContent = renderPassInfo.name + ' ' + id; - item.renderPass = renderPass; - item.renderPassId = id; - this.itemList_.appendChild(item); - - if (id == selectedRenderPassId) { - renderPass.selectionState = - tr.model.SelectionState.SELECTED; - } - }, this); - }, - - updateLayerContents_: function() { - this.changingItemSelection_ = true; - try { - this.itemList_.clear(); - - var selectedLayerId; - if (this.selection_ && this.selection_.associatedLayerId) - selectedLayerId = this.selection_.associatedLayerId; - - var layerInfos = this.getLayerInfos_(); - layerInfos.forEach(function(layerInfo) { - var layer = layerInfo.layer; - var id = layer.layerId; - - var item = this.createElementWithDepth_(layerInfo.depth); - var labelEl = item.appendChild(tr.ui.b.createSpan()); - - labelEl.textContent = layerInfo.name + ' ' + id; - - var notesEl = item.appendChild(tr.ui.b.createSpan()); - if (layerInfo.isMaskLayer) - notesEl.textContent += '(mask)'; - if (layerInfo.isReplicaLayer) - notesEl.textContent += '(replica)'; - - if (layer.gpuMemoryUsageInBytes !== undefined) { - var rounded = bytesToRoundedMegabytes(layer.gpuMemoryUsageInBytes); - if (rounded !== 0) - notesEl.textContent += ' (' + rounded + ' MB)'; - } - - item.layer = layer; - this.itemList_.appendChild(item); - - if (layer.layerId == selectedLayerId) { - layer.selectionState = tr.model.SelectionState.SELECTED; - item.selected = true; - } - }, this); - } finally { - this.changingItemSelection_ = false; - } - }, - - createElementWithDepth_: function(depth) { - var item = document.createElement('div'); - - var indentEl = item.appendChild(tr.ui.b.createSpan()); - indentEl.style.whiteSpace = 'pre'; - for (var i = 0; i < depth; i++) - indentEl.textContent = indentEl.textContent + ' '; - return item; - }, - - onItemSelectionChanged_: function(e) { - if (this.changingItemSelection_) - return; - if (this.renderPassQuads_) - this.onRenderPassSelected_(e); - else - this.onLayerSelected_(e); - tr.b.dispatchSimpleEvent(this, 'selection-change', false); - }, - - onRenderPassSelected_: function(e) { - var selectedRenderPass; - var selectedRenderPassId; - if (this.itemList_.selectedElement) { - selectedRenderPass = this.itemList_.selectedElement.renderPass; - selectedRenderPassId = - this.itemList_.selectedElement.renderPassId; - } - - if (selectedRenderPass) { - this.selection_ = new tr.ui.e.chrome.cc.RenderPassSelection( - selectedRenderPass, selectedRenderPassId); - } else { - this.selection_ = undefined; - } - }, - - onLayerSelected_: function(e) { - var selectedLayer; - if (this.itemList_.selectedElement) - selectedLayer = this.itemList_.selectedElement.layer; - - if (selectedLayer) - this.selection_ = new tr.ui.e.chrome.cc.LayerSelection(selectedLayer); - else - this.selection_ = undefined; - }, - - get selection() { - return this.selection_; - }, - - set selection(selection) { - if (this.selection_ == selection) - return; - this.selection_ = selection; - this.updateContents_(); - } - }; - - return { - LayerPicker: LayerPicker - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/layer_tree_host_impl_view.css b/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/layer_tree_host_impl_view.css deleted file mode 100644 index 3f5069a7cc8..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/layer_tree_host_impl_view.css +++ /dev/null @@ -1,18 +0,0 @@ -/* Copyright (c) 2013 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -* /deep/ .tr-ui-e-chrome-cc-lthi-s-view { - -webkit-flex: 1 1 auto !important; - -webkit-flex-direction: row; - display: -webkit-flex; -} - -* /deep/ .tr-ui-e-chrome-cc-lthi-s-view > tr-ui-e-chrome-cc-layer-picker { - -webkit-flex: 1 1 auto; -} - -* /deep/ .tr-ui-e-chrome-cc-lthi-s-view > tr-ui-b-drag-handle { - -webkit-flex: 0 0 auto; -} diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/layer_tree_host_impl_view.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/layer_tree_host_impl_view.html deleted file mode 100644 index d808bc5e869..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/layer_tree_host_impl_view.html +++ /dev/null @@ -1,127 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="stylesheet" - href="/tracing/ui/extras/chrome/cc/layer_tree_host_impl_view.css"> - -<link rel="import" href="/tracing/extras/chrome/cc/layer_tree_host_impl.html"> -<link rel="import" href="/tracing/ui/extras/chrome/cc/layer_picker.html"> -<link rel="import" href="/tracing/ui/extras/chrome/cc/layer_view.html"> -<link rel="import" href="/tracing/extras/chrome/cc/tile.html"> -<link rel="import" href="/tracing/ui/analysis/object_snapshot_view.html"> -<link rel="import" href="/tracing/ui/base/drag_handle.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.e.chrome.cc', function() { - /* - * Displays a LayerTreeHostImpl snapshot in a human readable form. - * @constructor - */ - var LayerTreeHostImplSnapshotView = tr.ui.b.define( - 'tr-ui-e-chrome-cc-layer-tree-host-impl-snapshot-view', - tr.ui.analysis.ObjectSnapshotView); - - LayerTreeHostImplSnapshotView.prototype = { - __proto__: tr.ui.analysis.ObjectSnapshotView.prototype, - - decorate: function() { - this.classList.add('tr-ui-e-chrome-cc-lthi-s-view'); - - this.selection_ = undefined; - - this.layerPicker_ = new tr.ui.e.chrome.cc.LayerPicker(); - this.layerPicker_.addEventListener( - 'selection-change', - this.onLayerPickerSelectionChanged_.bind(this)); - - this.layerView_ = new tr.ui.e.chrome.cc.LayerView(); - this.layerView_.addEventListener( - 'selection-change', - this.onLayerViewSelectionChanged_.bind(this)); - this.dragHandle_ = document.createElement('tr-ui-b-drag-handle'); - this.dragHandle_.horizontal = false; - this.dragHandle_.target = this.layerView_; - - this.appendChild(this.layerPicker_); - this.appendChild(this.dragHandle_); - this.appendChild(this.layerView_); - - // Make sure we have the current values from layerView_ and layerPicker_, - // since those might have been created before we added the listener. - this.onLayerViewSelectionChanged_(); - this.onLayerPickerSelectionChanged_(); - - }, - - get objectSnapshot() { - return this.objectSnapshot_; - }, - - set objectSnapshot(objectSnapshot) { - this.objectSnapshot_ = objectSnapshot; - - var lthi = this.objectSnapshot; - var layerTreeImpl; - if (lthi) - layerTreeImpl = lthi.getTree(this.layerPicker_.whichTree); - - this.layerPicker_.lthiSnapshot = lthi; - this.layerView_.layerTreeImpl = layerTreeImpl; - this.layerView_.regenerateContent(); - - if (!this.selection_) - return; - this.selection = this.selection_.findEquivalent(lthi); - }, - - get selection() { - return this.selection_; - }, - - set selection(selection) { - if (this.selection_ == selection) - return; - this.selection_ = selection; - this.layerPicker_.selection = selection; - this.layerView_.selection = selection; - tr.b.dispatchSimpleEvent(this, 'cc-selection-change'); - }, - - onLayerPickerSelectionChanged_: function() { - this.selection_ = this.layerPicker_.selection; - this.layerView_.selection = this.selection; - this.layerView_.layerTreeImpl = this.layerPicker_.layerTreeImpl; - this.layerView_.isRenderPassQuads = this.layerPicker_.isRenderPassQuads; - this.layerView_.regenerateContent(); - tr.b.dispatchSimpleEvent(this, 'cc-selection-change'); - }, - - onLayerViewSelectionChanged_: function() { - this.selection_ = this.layerView_.selection; - this.layerPicker_.selection = this.selection; - tr.b.dispatchSimpleEvent(this, 'cc-selection-change'); - }, - - get extraHighlightsByLayerId() { - return this.layerView_.extraHighlightsByLayerId; - }, - - set extraHighlightsByLayerId(extraHighlightsByLayerId) { - this.layerView_.extraHighlightsByLayerId = extraHighlightsByLayerId; - } - }; - - tr.ui.analysis.ObjectSnapshotView.register( - LayerTreeHostImplSnapshotView, {typeName: 'cc::LayerTreeHostImpl'}); - - return { - LayerTreeHostImplSnapshotView: LayerTreeHostImplSnapshotView - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/layer_tree_host_impl_view_test.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/layer_tree_host_impl_view_test.html deleted file mode 100644 index b06765aa91d..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/layer_tree_host_impl_view_test.html +++ /dev/null @@ -1,37 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/extras/chrome/cc/layer_tree_host_impl.html"> -<link rel="import" href="/tracing/extras/importer/trace_event_importer.html"> -<link rel="import" href="/tracing/extras/chrome/cc/raster_task.html"> -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/ui/extras/chrome/cc/layer_tree_host_impl_view.html"> - -<script src="/tracing/extras/chrome/cc/layer_tree_host_impl_test_data.js"> -</script> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - test('instantiate', function() { - var m = tr.c.TestUtils.newModelWithEvents([g_catLTHIEvents]); - var p = tr.b.dictionaryValues(m.processes)[0]; - - var instance = p.objects.getAllInstancesNamed('cc::LayerTreeHostImpl')[0]; - var snapshot = instance.snapshots[0]; - - var view = new tr.ui.e.chrome.cc.LayerTreeHostImplSnapshotView(); - view.style.width = '900px'; - view.style.height = '400px'; - view.objectSnapshot = snapshot; - - this.addHTMLOutput(view); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/layer_tree_quad_stack_view.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/layer_tree_quad_stack_view.html deleted file mode 100644 index a54deecabfc..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/layer_tree_quad_stack_view.html +++ /dev/null @@ -1,1192 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/color.html"> -<link rel="import" href="/tracing/base/quad.html"> -<link rel="import" href="/tracing/base/raf.html"> -<link rel="import" href="/tracing/base/range.html"> -<link rel="import" href="/tracing/extras/chrome/cc/debug_colors.html"> -<link rel="import" href="/tracing/extras/chrome/cc/picture.html"> -<link rel="import" href="/tracing/extras/chrome/cc/render_pass.html"> -<link rel="import" href="/tracing/extras/chrome/cc/tile.html"> -<link rel="import" href="/tracing/extras/chrome/cc/util.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/ui/base/info_bar.html"> -<link rel="import" href="/tracing/ui/base/quad_stack_view.html"> -<link rel="import" href="/tracing/ui/base/utils.html"> - -<style> -* /deep/ tr-ui-e-chrome-cc-layer-tree-quad-stack-view { - position: relative; -} - -* /deep/ tr-ui-e-chrome-cc-layer-tree-quad-stack-view > top-controls { - -webkit-flex: 0 0 auto; - background-image: -webkit-gradient(linear, - 0 0, 100% 0, - from(#E5E5E5), - to(#D1D1D1)); - border-bottom: 1px solid #8e8e8e; - border-top: 1px solid white; - display: flex; - flex-flow: row wrap; - flex-direction: row; - font-size: 14px; - padding-left: 2px; - overflow: hidden; -} - -* /deep/ tr-ui-e-chrome-cc-layer-tree-quad-stack-view > - top-controls input[type='checkbox'] { - vertical-align: -2px; -} - -* /deep/ tr-ui-e-chrome-cc-layer-tree-quad-stack-view > .what-rasterized { - color: -webkit-link; - cursor: pointer; - text-decoration: underline; - position: absolute; - bottom: 10px; - left: 10px; -} - -* /deep/ tr-ui-e-chrome-cc-layer-tree-quad-stack-view > #input-event { - background-image: url('./images/input-event.png'); - display: none; -} -</style> - -<template id='tr-ui-e-chrome-cc-layer-tree-quad-stack-view-template'> - <img id='input-event'/> -</template> - -<script> -'use strict'; - -/** - * @fileoverview Graphical view of LayerTreeImpl, with controls for - * type of layer content shown and info bar for content-loading warnings. - */ -tr.exportTo('tr.ui.e.chrome.cc', function() { - var ColorScheme = tr.b.ColorScheme; - - var THIS_DOC = document.currentScript.ownerDocument; - var TILE_HEATMAP_TYPE = {}; - TILE_HEATMAP_TYPE.NONE = 'none'; - TILE_HEATMAP_TYPE.SCHEDULED_PRIORITY = 'scheduledPriority'; - TILE_HEATMAP_TYPE.USING_GPU_MEMORY = 'usingGpuMemory'; - - var cc = tr.ui.e.chrome.cc; - - function createTileRectsSelectorBaseOptions() { - return [{label: 'None', value: 'none'}, - {label: 'Coverage Rects', value: 'coverage'}]; - } - - var bytesToRoundedMegabytes = tr.e.cc.bytesToRoundedMegabytes; - - - /** - * @constructor - */ - var LayerTreeQuadStackView = - tr.ui.b.define('tr-ui-e-chrome-cc-layer-tree-quad-stack-view'); - - LayerTreeQuadStackView.prototype = { - __proto__: HTMLDivElement.prototype, - - decorate: function() { - this.isRenderPassQuads_ = false; - this.pictureAsImageData_ = {}; // Maps picture.guid to PictureAsImageData. - this.messages_ = []; - this.controls_ = document.createElement('top-controls'); - this.infoBar_ = document.createElement('tr-ui-b-info-bar'); - this.quadStackView_ = new tr.ui.b.QuadStackView(); - this.quadStackView_.addEventListener( - 'selectionchange', this.onQuadStackViewSelectionChange_.bind(this)); - this.extraHighlightsByLayerId_ = undefined; - this.inputEventImageData_ = undefined; - - var m = tr.ui.b.MOUSE_SELECTOR_MODE; - var mms = this.quadStackView_.mouseModeSelector; - mms.settingsKey = 'tr.e.cc.layerTreeQuadStackView.mouseModeSelector'; - mms.setKeyCodeForMode(m.SELECTION, 'Z'.charCodeAt(0)); - mms.setKeyCodeForMode(m.PANSCAN, 'X'.charCodeAt(0)); - mms.setKeyCodeForMode(m.ZOOM, 'C'.charCodeAt(0)); - mms.setKeyCodeForMode(m.ROTATE, 'V'.charCodeAt(0)); - - var node = tr.ui.b.instantiateTemplate( - '#tr-ui-e-chrome-cc-layer-tree-quad-stack-view-template', THIS_DOC); - this.appendChild(node); - this.appendChild(this.controls_); - this.appendChild(this.infoBar_); - this.appendChild(this.quadStackView_); - - this.tileRectsSelector_ = tr.ui.b.createSelector( - this, 'howToShowTiles', - 'layerView.howToShowTiles', 'none', - createTileRectsSelectorBaseOptions()); - this.controls_.appendChild(this.tileRectsSelector_); - - var tileHeatmapText = tr.ui.b.createSpan({ - textContent: 'Tile heatmap:' - }); - this.controls_.appendChild(tileHeatmapText); - - var tileHeatmapSelector = tr.ui.b.createSelector( - this, 'tileHeatmapType', - 'layerView.tileHeatmapType', TILE_HEATMAP_TYPE.NONE, - [{label: 'None', - value: TILE_HEATMAP_TYPE.NONE}, - {label: 'Scheduled Priority', - value: TILE_HEATMAP_TYPE.SCHEDULED_PRIORITY}, - {label: 'Is using GPU memory', - value: TILE_HEATMAP_TYPE.USING_GPU_MEMORY} - ]); - this.controls_.appendChild(tileHeatmapSelector); - - var showOtherLayersCheckbox = tr.ui.b.createCheckBox( - this, 'showOtherLayers', - 'layerView.showOtherLayers', true, - 'Other layers/passes'); - showOtherLayersCheckbox.title = - 'When checked, show all layers, selected or not.'; - this.controls_.appendChild(showOtherLayersCheckbox); - - var showInvalidationsCheckbox = tr.ui.b.createCheckBox( - this, 'showInvalidations', - 'layerView.showInvalidations', true, - 'Invalidations'); - showInvalidationsCheckbox.title = - 'When checked, compositing invalidations are highlighted in red'; - this.controls_.appendChild(showInvalidationsCheckbox); - - var showUnrecordedRegionCheckbox = tr.ui.b.createCheckBox( - this, 'showUnrecordedRegion', - 'layerView.showUnrecordedRegion', true, - 'Unrecorded area'); - showUnrecordedRegionCheckbox.title = - 'When checked, unrecorded areas are highlighted in yellow'; - this.controls_.appendChild(showUnrecordedRegionCheckbox); - - var showBottlenecksCheckbox = tr.ui.b.createCheckBox( - this, 'showBottlenecks', - 'layerView.showBottlenecks', true, - 'Bottlenecks'); - showBottlenecksCheckbox.title = - 'When checked, scroll bottlenecks are highlighted'; - this.controls_.appendChild(showBottlenecksCheckbox); - - var showLayoutRectsCheckbox = tr.ui.b.createCheckBox( - this, 'showLayoutRects', - 'layerView.showLayoutRects', false, - 'Layout rects'); - showLayoutRectsCheckbox.title = - 'When checked, shows rects for regions where layout happened'; - this.controls_.appendChild(showLayoutRectsCheckbox); - - var showContentsCheckbox = tr.ui.b.createCheckBox( - this, 'showContents', - 'layerView.showContents', true, - 'Contents'); - showContentsCheckbox.title = - 'When checked, show the rendered contents inside the layer outlines'; - this.controls_.appendChild(showContentsCheckbox); - - var showAnimationBoundsCheckbox = tr.ui.b.createCheckBox( - this, 'showAnimationBounds', - 'layerView.showAnimationBounds', false, - 'Animation Bounds'); - showAnimationBoundsCheckbox.title = 'When checked, show a border around' + - ' a layer showing the extent of its animation.'; - this.controls_.appendChild(showAnimationBoundsCheckbox); - - var showInputEventsCheckbox = tr.ui.b.createCheckBox( - this, 'showInputEvents', - 'layerView.showInputEvents', true, - 'Input events'); - showInputEventsCheckbox.title = 'When checked, input events are ' + - 'displayed as circles.'; - this.controls_.appendChild(showInputEventsCheckbox); - - this.whatRasterizedLink_ = document.createElement('a'); - this.whatRasterizedLink_.classList.add('what-rasterized'); - this.whatRasterizedLink_.textContent = 'What rasterized?'; - this.whatRasterizedLink_.addEventListener( - 'click', this.onWhatRasterizedLinkClicked_.bind(this)); - this.appendChild(this.whatRasterizedLink_); - }, - - get layerTreeImpl() { - return this.layerTreeImpl_; - }, - - set isRenderPassQuads(newValue) { - this.isRenderPassQuads_ = newValue; - }, - - set layerTreeImpl(layerTreeImpl) { - if (this.layerTreeImpl_ === layerTreeImpl) - return; - - // FIXME(pdr): We may want to clear pictureAsImageData_ here to save - // memory at the cost of performance. Note that - // pictureAsImageData_ will be cleared when this is - // destructed, but this view might live for several - // layerTreeImpls. - this.layerTreeImpl_ = layerTreeImpl; - this.selection = undefined; - }, - - get extraHighlightsByLayerId() { - return this.extraHighlightsByLayerId_; - }, - - set extraHighlightsByLayerId(extraHighlightsByLayerId) { - this.extraHighlightsByLayerId_ = extraHighlightsByLayerId; - this.scheduleUpdateContents_(); - }, - - get showOtherLayers() { - return this.showOtherLayers_; - }, - - set showOtherLayers(show) { - this.showOtherLayers_ = show; - this.updateContents_(); - }, - - get showAnimationBounds() { - return this.showAnimationBounds_; - }, - - set showAnimationBounds(show) { - this.showAnimationBounds_ = show; - this.updateContents_(); - }, - - get showInputEvents() { - return this.showInputEvents_; - }, - - set showInputEvents(show) { - this.showInputEvents_ = show; - this.updateContents_(); - }, - - get showContents() { - return this.showContents_; - }, - - set showContents(show) { - this.showContents_ = show; - this.updateContents_(); - }, - - get showInvalidations() { - return this.showInvalidations_; - }, - - set showInvalidations(show) { - this.showInvalidations_ = show; - this.updateContents_(); - }, - - get showUnrecordedRegion() { - return this.showUnrecordedRegion_; - }, - - set showUnrecordedRegion(show) { - this.showUnrecordedRegion_ = show; - this.updateContents_(); - }, - - get showBottlenecks() { - return this.showBottlenecks_; - }, - - set showBottlenecks(show) { - this.showBottlenecks_ = show; - this.updateContents_(); - }, - - get showLayoutRects() { - return this.showLayoutRects_; - }, - - set showLayoutRects(show) { - this.showLayoutRects_ = show; - this.updateContents_(); - }, - - get howToShowTiles() { - return this.howToShowTiles_; - }, - - set howToShowTiles(val) { - // Make sure val is something we expect. - console.assert( - (val === 'none') || - (val === 'coverage') || - !isNaN(parseFloat(val))); - - this.howToShowTiles_ = val; - this.updateContents_(); - }, - - get tileHeatmapType() { - return this.tileHeatmapType_; - }, - - set tileHeatmapType(val) { - this.tileHeatmapType_ = val; - this.updateContents_(); - }, - - get selection() { - return this.selection_; - }, - - set selection(selection) { - if (this.selection === selection) - return; - this.selection_ = selection; - tr.b.dispatchSimpleEvent(this, 'selection-change'); - this.updateContents_(); - }, - - regenerateContent: function() { - this.updateTilesSelector_(); - this.updateContents_(); - }, - - loadDataForImageElement_: function(image, callback) { - var imageContent = window.getComputedStyle(image).backgroundImage; - image.src = tr.ui.b.extractUrlString(imageContent); - image.onload = function() { - var canvas = document.createElement('canvas'); - var ctx = canvas.getContext('2d'); - canvas.width = image.width; - canvas.height = image.height; - ctx.drawImage(image, 0, 0); - var imageData = ctx.getImageData( - 0, 0, canvas.width, canvas.height); - callback(imageData); - }; - }, - - onQuadStackViewSelectionChange_: function(e) { - var selectableQuads = e.quads.filter(function(q) { - return q.selectionToSetIfClicked !== undefined; - }); - if (selectableQuads.length == 0) { - this.selection = undefined; - return; - } - - // Sort the quads low to high on stackingGroupId. - selectableQuads.sort(function(x, y) { - var z = x.stackingGroupId - y.stackingGroupId; - if (z != 0) - return z; - return x.selectionToSetIfClicked.specicifity - - y.selectionToSetIfClicked.specicifity; - }); - - // TODO(nduca): Support selecting N things at once. - var quadToSelect = selectableQuads[selectableQuads.length - 1]; - this.selection = quadToSelect.selectionToSetIfClicked; - }, - - scheduleUpdateContents_: function() { - if (this.updateContentsPending_) - return; - this.updateContentsPending_ = true; - tr.b.requestAnimationFrameInThisFrameIfPossible( - this.updateContents_, this); - }, - - updateContents_: function() { - if (!this.layerTreeImpl_) { - this.quadStackView_.headerText = 'No tree'; - this.quadStackView_.quads = []; - return; - } - - - var status = this.computePictureLoadingStatus_(); - if (!status.picturesComplete) - return; - - var lthi = this.layerTreeImpl_.layerTreeHostImpl; - var lthiInstance = lthi.objectInstance; - var worldViewportRect = tr.b.Rect.fromXYWH( - 0, 0, - lthi.deviceViewportSize.width, lthi.deviceViewportSize.height); - this.quadStackView_.deviceRect = worldViewportRect; - if (this.isRenderPassQuads_) - this.quadStackView_.quads = this.generateRenderPassQuads(); - else - this.quadStackView_.quads = this.generateLayerQuads(); - - this.updateWhatRasterizedLinkState_(); - - var message = ''; - if (lthi.tilesHaveGpuMemoryUsageInfo) { - var thisTreeUsageInBytes = this.layerTreeImpl_.gpuMemoryUsageInBytes; - var otherTreeUsageInBytes = lthi.gpuMemoryUsageInBytes - - thisTreeUsageInBytes; - message += bytesToRoundedMegabytes(thisTreeUsageInBytes) + - 'MB on this tree'; - if (otherTreeUsageInBytes) { - message += ', ' + - bytesToRoundedMegabytes(otherTreeUsageInBytes) + - 'MB on the other tree'; - } - } else { - if (this.layerTreeImpl_) { - var thisTreeUsageInBytes = this.layerTreeImpl_.gpuMemoryUsageInBytes; - message += bytesToRoundedMegabytes(thisTreeUsageInBytes) + - 'MB on this tree'; - - if (this.layerTreeImpl_.otherTree) { - // Older Chromes don't report enough data to know how much memory is - // being used across both trees. We know the memory consumed by each - // tree, but there is resource sharing *between the trees* so we - // can't simply sum up the per-tree costs. We need either the total - // plus one tree, to guess the unique on the other tree, etc. Newer - // chromes report memory per tile, which allows LTHI to compute the - // total tile memory usage, letting us figure things out properly. - message += ', ???MB on other tree. '; - } - } - } - - if (lthi.args.tileManagerBasicState) { - var tmgs = lthi.args.tileManagerBasicState.globalState; - message += ' (softMax=' + - bytesToRoundedMegabytes(tmgs.softMemoryLimitInBytes) + - 'MB, hardMax=' + - bytesToRoundedMegabytes(tmgs.hardMemoryLimitInBytes) + 'MB, ' + - tmgs.memoryLimitPolicy + ')'; - - } else { - // Old Chromes do not have a globalState on the LTHI dump. - // But they do issue a DidManage event wiht the globalstate. Find that - // event so that we show some global state. - var thread = lthi.snapshottedOnThread; - var didManageTilesSlices = thread.sliceGroup.slices.filter(function(s) { - if (s.category !== 'tr.e.cc') - return false; - if (s.title !== 'DidManage') - return false; - if (s.end > lthi.ts) - return false; - return true; - }); - didManageTilesSlices.sort(function(x, y) { - return x.end - y.end; - }); - if (didManageTilesSlices.length > 0) { - var newest = didManageTilesSlices[didManageTilesSlices.length - 1]; - var tmgs = newest.args.state.global_state; - message += ' (softMax=' + - bytesToRoundedMegabytes(tmgs.soft_memory_limit_in_bytes) + - 'MB, hardMax=' + - bytesToRoundedMegabytes(tmgs.hard_memory_limit_in_bytes) + 'MB, ' + - tmgs.memory_limit_policy + ')'; - } - } - - if (this.layerTreeImpl_.otherTree) - message += ' (Another tree exists)'; - - - if (message.length) - this.quadStackView_.headerText = message; - else - this.quadStackView_.headerText = undefined; - - this.updateInfoBar_(status.messages); - }, - - updateTilesSelector_: function() { - var data = createTileRectsSelectorBaseOptions(); - - if (this.layerTreeImpl_) { - // First get all of the scales information from LTHI. - var lthi = this.layerTreeImpl_.layerTreeHostImpl; - var scaleNames = lthi.getContentsScaleNames(); - for (var scale in scaleNames) { - data.push({ - label: 'Scale ' + scale + ' (' + scaleNames[scale] + ')', - value: scale - }); - } - } - - // Then create a new selector and replace the old one. - var new_selector = tr.ui.b.createSelector( - this, 'howToShowTiles', - 'layerView.howToShowTiles', 'none', - data); - this.controls_.replaceChild(new_selector, this.tileRectsSelector_); - this.tileRectsSelector_ = new_selector; - }, - - computePictureLoadingStatus_: function() { - // Figure out if we can draw the quads yet. While we're at it, figure out - // if we have any warnings we need to show. - var layers = this.layers; - var status = { - messages: [], - picturesComplete: true - }; - if (this.showContents) { - var hasPendingRasterizeImage = false; - var firstPictureError = undefined; - var hasMissingLayerRect = false; - var hasUnresolvedPictureRef = false; - for (var i = 0; i < layers.length; i++) { - var layer = layers[i]; - for (var ir = 0; ir < layer.pictures.length; ++ir) { - var picture = layer.pictures[ir]; - - if (picture.idRef) { - hasUnresolvedPictureRef = true; - continue; - } - if (!picture.layerRect) { - hasMissingLayerRect = true; - continue; - } - - var pictureAsImageData = this.pictureAsImageData_[picture.guid]; - if (!pictureAsImageData) { - hasPendingRasterizeImage = true; - this.pictureAsImageData_[picture.guid] = - tr.e.cc.PictureAsImageData.Pending(this); - picture.rasterize( - {stopIndex: undefined}, - function(pictureImageData) { - var picture_ = pictureImageData.picture; - this.pictureAsImageData_[picture_.guid] = pictureImageData; - this.scheduleUpdateContents_(); - }.bind(this)); - continue; - } - if (pictureAsImageData.isPending()) { - hasPendingRasterizeImage = true; - continue; - } - if (pictureAsImageData.error) { - if (!firstPictureError) - firstPictureError = pictureAsImageData.error; - break; - } - } - } - if (hasPendingRasterizeImage) { - status.picturesComplete = false; - } else { - if (hasUnresolvedPictureRef) { - status.messages.push({ - header: 'Missing picture', - details: 'Your trace didnt have pictures for every layer. ' + - 'Old chrome versions had this problem'}); - } - if (hasMissingLayerRect) { - status.messages.push({ - header: 'Missing layer rect', - details: 'Your trace may be corrupt or from a very old ' + - 'Chrome revision.'}); - } - if (firstPictureError) { - status.messages.push({ - header: 'Cannot rasterize', - details: firstPictureError}); - } - } - } - if (this.showInputEvents && this.layerTreeImpl.tracedInputLatencies && - this.inputEventImageData_ === undefined) { - var image = this.querySelector('#input-event'); - if (!image.src) { - this.loadDataForImageElement_(image, function(imageData) { - this.inputEventImageData_ = imageData; - this.updateContentsPending_ = false; - this.scheduleUpdateContents_(); - }.bind(this)); - } - status.picturesComplete = false; - } - return status; - }, - - get selectedRenderPass() { - if (this.selection) - return this.selection.renderPass_; - }, - - get selectedLayer() { - if (this.selection) { - var selectedLayerId = this.selection.associatedLayerId; - return this.layerTreeImpl_.findLayerWithId(selectedLayerId); - } - }, - - get renderPasses() { - var renderPasses = - this.layerTreeImpl.layerTreeHostImpl.args.frame.renderPasses; - if (!this.showOtherLayers) { - var selectedRenderPass = this.selectedRenderPass; - if (selectedRenderPass) - renderPasses = [selectedRenderPass]; - } - return renderPasses; - }, - - get layers() { - var layers = this.layerTreeImpl.renderSurfaceLayerList; - if (!this.showOtherLayers) { - var selectedLayer = this.selectedLayer; - if (selectedLayer) - layers = [selectedLayer]; - } - return layers; - }, - - appendImageQuads_: function(quads, layer, layerQuad) { - // Generate image quads for the layer - for (var ir = 0; ir < layer.pictures.length; ++ir) { - var picture = layer.pictures[ir]; - if (!picture.layerRect) - continue; - - var unitRect = picture.layerRect.asUVRectInside(layer.bounds); - var iq = layerQuad.projectUnitRect(unitRect); - - var pictureData = this.pictureAsImageData_[picture.guid]; - if (this.showContents && pictureData && pictureData.imageData) { - iq.imageData = pictureData.imageData; - iq.borderColor = 'rgba(0,0,0,0)'; - } else { - iq.imageData = undefined; - } - - iq.stackingGroupId = layerQuad.stackingGroupId; - quads.push(iq); - } - }, - - appendAnimationQuads_: function(quads, layer, layerQuad) { - if (!layer.animationBoundsRect) - return; - - var rect = layer.animationBoundsRect; - var abq = tr.b.Quad.fromRect(rect); - - abq.backgroundColor = 'rgba(164,191,48,0.5)'; - abq.borderColor = 'rgba(205,255,0,0.75)'; - abq.borderWidth = 3.0; - abq.stackingGroupId = layerQuad.stackingGroupId; - abq.selectionToSetIfClicked = new cc.AnimationRectSelection( - layer, rect); - quads.push(abq); - }, - - appendInvalidationQuads_: function(quads, layer, layerQuad) { - if (layer.layerTreeImpl.hasSourceFrameBeenDrawnBefore) - return; - - // Generate the invalidation rect quads. - for (var ir = 0; ir < layer.annotatedInvalidation.rects.length; ir++) { - var rect = layer.annotatedInvalidation.rects[ir]; - var unitRect = rect.asUVRectInside(layer.bounds); - var iq = layerQuad.projectUnitRect(unitRect); - iq.backgroundColor = 'rgba(0, 255, 0, 0.1)'; - if (rect.reason === 'renderer insertion') - iq.backgroundColor = 'rgba(0, 255, 128, 0.1)'; - iq.borderColor = 'rgba(0, 255, 0, 1)'; - iq.stackingGroupId = layerQuad.stackingGroupId; - iq.selectionToSetIfClicked = new cc.LayerRectSelection( - layer, 'Invalidation rect (' + rect.reason + ')', rect, rect); - quads.push(iq); - } - - // Show unannotated invalidation rect quads if no annotated rects are - // available. - if (layer.annotatedInvalidation.rects.length === 0) { - for (var ir = 0; ir < layer.invalidation.rects.length; ir++) { - var rect = layer.invalidation.rects[ir]; - var unitRect = rect.asUVRectInside(layer.bounds); - var iq = layerQuad.projectUnitRect(unitRect); - iq.backgroundColor = 'rgba(0, 255, 0, 0.1)'; - iq.borderColor = 'rgba(0, 255, 0, 1)'; - iq.stackingGroupId = layerQuad.stackingGroupId; - iq.selectionToSetIfClicked = new cc.LayerRectSelection( - layer, 'Invalidation rect', rect, rect); - quads.push(iq); - } - } - }, - - appendUnrecordedRegionQuads_: function(quads, layer, layerQuad) { - // Generate the unrecorded region quads. - for (var ir = 0; ir < layer.unrecordedRegion.rects.length; ir++) { - var rect = layer.unrecordedRegion.rects[ir]; - var unitRect = rect.asUVRectInside(layer.bounds); - var iq = layerQuad.projectUnitRect(unitRect); - iq.backgroundColor = 'rgba(240, 230, 140, 0.3)'; - iq.borderColor = 'rgba(240, 230, 140, 1)'; - iq.stackingGroupId = layerQuad.stackingGroupId; - iq.selectionToSetIfClicked = new cc.LayerRectSelection( - layer, 'Unrecorded area', rect, rect); - quads.push(iq); - } - }, - - appendBottleneckQuads_: function(quads, layer, layerQuad, stackingGroupId) { - function processRegion(region, label, borderColor) { - var backgroundColor = borderColor.clone(); - backgroundColor.a = 0.4 * (borderColor.a || 1.0); - - if (!region || !region.rects) - return; - - for (var ir = 0; ir < region.rects.length; ir++) { - var rect = region.rects[ir]; - var unitRect = rect.asUVRectInside(layer.bounds); - var iq = layerQuad.projectUnitRect(unitRect); - iq.backgroundColor = backgroundColor.toString(); - iq.borderColor = borderColor.toString(); - iq.borderWidth = 4.0; - iq.stackingGroupId = stackingGroupId; - iq.selectionToSetIfClicked = new cc.LayerRectSelection( - layer, label, rect, rect); - quads.push(iq); - } - } - - processRegion(layer.touchEventHandlerRegion, 'Touch listener', - tr.b.Color.fromString('rgb(228, 226, 27)')); - processRegion(layer.wheelEventHandlerRegion, 'Wheel listener', - tr.b.Color.fromString('rgb(176, 205, 29)')); - processRegion(layer.nonFastScrollableRegion, 'Repaints on scroll', - tr.b.Color.fromString('rgb(213, 134, 32)')); - }, - - appendTileCoverageRectQuads_: function( - quads, layer, layerQuad, heatmapType) { - if (!layer.tileCoverageRects) - return; - - var tiles = []; - for (var ct = 0; ct < layer.tileCoverageRects.length; ++ct) { - var tile = layer.tileCoverageRects[ct].tile; - if (tile !== undefined) - tiles.push(tile); - } - - var lthi = this.layerTreeImpl_.layerTreeHostImpl; - var minMax = - this.getMinMaxForHeatmap_(lthi.activeTiles, heatmapType); - var heatmapResult = - this.computeHeatmapColors_(tiles, minMax, heatmapType); - var heatIndex = 0; - - for (var ct = 0; ct < layer.tileCoverageRects.length; ++ct) { - var rect = layer.tileCoverageRects[ct].geometryRect; - rect = rect.scale(1.0 / layer.geometryContentsScale); - - var tile = layer.tileCoverageRects[ct].tile; - - var unitRect = rect.asUVRectInside(layer.bounds); - var quad = layerQuad.projectUnitRect(unitRect); - - quad.backgroundColor = 'rgba(0, 0, 0, 0)'; - quad.stackingGroupId = layerQuad.stackingGroupId; - var type = tr.e.cc.tileTypes.missing; - if (tile) { - type = tile.getTypeForLayer(layer); - quad.backgroundColor = heatmapResult[heatIndex].color; - ++heatIndex; - } - - quad.borderColor = tr.e.cc.tileBorder[type].color; - quad.borderWidth = tr.e.cc.tileBorder[type].width; - var label; - if (tile) - label = 'coverageRect'; - else - label = 'checkerboard coverageRect'; - quad.selectionToSetIfClicked = new cc.LayerRectSelection( - layer, label, rect, layer.tileCoverageRects[ct]); - - quads.push(quad); - } - }, - - appendLayoutRectQuads_: function(quads, layer, layerQuad) { - if (!layer.layoutRects) { - return; - } - - for (var ct = 0; ct < layer.layoutRects.length; ++ct) { - var rect = layer.layoutRects[ct].geometryRect; - rect = rect.scale(1.0 / layer.geometryContentsScale); - - var unitRect = rect.asUVRectInside(layer.bounds); - var quad = layerQuad.projectUnitRect(unitRect); - - quad.backgroundColor = 'rgba(0, 0, 0, 0)'; - quad.stackingGroupId = layerQuad.stackingGroupId; - - quad.borderColor = 'rgba(0, 0, 200, 0.7)'; - quad.borderWidth = 2; - var label; - label = 'Layout rect'; - quad.selectionToSetIfClicked = new cc.LayerRectSelection( - layer, label, rect); - - quads.push(quad); - } - }, - - getValueForHeatmap_: function(tile, heatmapType) { - if (heatmapType == TILE_HEATMAP_TYPE.SCHEDULED_PRIORITY) { - return tile.scheduledPriority == 0 ? - undefined : - tile.scheduledPriority; - } else if (heatmapType == TILE_HEATMAP_TYPE.USING_GPU_MEMORY) { - if (tile.isSolidColor) - return 0.5; - return tile.isUsingGpuMemory ? 0 : 1; - } - }, - - getMinMaxForHeatmap_: function(tiles, heatmapType) { - var range = new tr.b.Range(); - if (heatmapType == TILE_HEATMAP_TYPE.USING_GPU_MEMORY) { - range.addValue(0); - range.addValue(1); - return range; - } - - for (var i = 0; i < tiles.length; ++i) { - var value = this.getValueForHeatmap_(tiles[i], heatmapType); - if (value === undefined) - continue; - range.addValue(value); - } - if (range.range === 0) - range.addValue(1); - return range; - }, - - computeHeatmapColors_: function(tiles, minMax, heatmapType) { - var min = minMax.min; - var max = minMax.max; - - var color = function(value) { - var hue = 120 * (1 - (value - min) / (max - min)); - if (hue < 0) - hue = 0; - return 'hsla(' + hue + ', 100%, 50%, 0.5)'; - }; - - var values = []; - for (var i = 0; i < tiles.length; ++i) { - var tile = tiles[i]; - var value = this.getValueForHeatmap_(tile, heatmapType); - var res = { - value: value, - color: value !== undefined ? color(value) : undefined - }; - values.push(res); - } - - return values; - }, - - appendTilesWithScaleQuads_: function( - quads, layer, layerQuad, scale, heatmapType) { - var lthi = this.layerTreeImpl_.layerTreeHostImpl; - - var tiles = []; - for (var i = 0; i < lthi.activeTiles.length; ++i) { - var tile = lthi.activeTiles[i]; - - if (Math.abs(tile.contentsScale - scale) > 1e-6) - continue; - - // TODO(vmpstr): Make the stiching of tiles and layers a part of - // tile construction (issue 346) - if (layer.layerId != tile.layerId) - continue; - - tiles.push(tile); - } - - var minMax = - this.getMinMaxForHeatmap_(lthi.activeTiles, heatmapType); - var heatmapResult = - this.computeHeatmapColors_(tiles, minMax, heatmapType); - - for (var i = 0; i < tiles.length; ++i) { - var tile = tiles[i]; - var rect = tile.layerRect; - if (!tile.layerRect) - continue; - var unitRect = rect.asUVRectInside(layer.bounds); - var quad = layerQuad.projectUnitRect(unitRect); - - quad.backgroundColor = 'rgba(0, 0, 0, 0)'; - quad.stackingGroupId = layerQuad.stackingGroupId; - - var type = tile.getTypeForLayer(layer); - quad.borderColor = tr.e.cc.tileBorder[type].color; - quad.borderWidth = tr.e.cc.tileBorder[type].width; - - quad.backgroundColor = heatmapResult[i].color; - var data = { - tileType: type - }; - if (heatmapType !== TILE_HEATMAP_TYPE.NONE) - data[heatmapType] = heatmapResult[i].value; - quad.selectionToSetIfClicked = new cc.TileSelection(tile, data); - quads.push(quad); - } - }, - - appendHighlightQuadsForLayer_: function( - quads, layer, layerQuad, highlights) { - highlights.forEach(function(highlight) { - var rect = highlight.rect; - - var unitRect = rect.asUVRectInside(layer.bounds); - var quad = layerQuad.projectUnitRect(unitRect); - - var colorId = ColorScheme.getColorIdForGeneralPurposeString( - highlight.colorKey); - colorId += ColorScheme.properties.brightenedOffsets[0]; - - var color = ColorScheme.colors[colorId]; - - var quadForDrawing = quad.clone(); - quadForDrawing.backgroundColor = color.withAlpha(0.5).toString(); - quadForDrawing.borderColor = color.withAlpha(1.0).darken().toString(); - quadForDrawing.stackingGroupId = layerQuad.stackingGroupId; - quads.push(quadForDrawing); - - }, this); - }, - - generateRenderPassQuads: function() { - if (!this.layerTreeImpl.layerTreeHostImpl.args.frame) - return []; - var renderPasses = this.renderPasses; - if (!renderPasses) - return []; - - var quads = []; - for (var i = 0; i < renderPasses.length; ++i) { - var quadList = renderPasses[i].quadList; - for (var j = 0; j < quadList.length; ++j) { - var drawQuad = quadList[j]; - var quad = drawQuad.rectAsTargetSpaceQuad.clone(); - quad.borderColor = 'rgb(170, 204, 238)'; - quad.borderWidth = 2; - quad.stackingGroupId = i; - quads.push(quad); - } - } - return quads; - }, - - generateLayerQuads: function() { - this.updateContentsPending_ = false; - - // Generate the quads for the view. - var layers = this.layers; - var quads = []; - var nextStackingGroupId = 0; - var alreadyVisitedLayerIds = {}; - - - var selectionHighlightsByLayerId; - if (this.selection) - selectionHighlightsByLayerId = this.selection.highlightsByLayerId; - else - selectionHighlightsByLayerId = {}; - - var extraHighlightsByLayerId = this.extraHighlightsByLayerId || {}; - - for (var i = 1; i <= layers.length; i++) { - // Generate quads back-to-front. - var layer = layers[layers.length - i]; - alreadyVisitedLayerIds[layer.layerId] = true; - if (layer.objectInstance.name == 'cc::NinePatchLayerImpl') - continue; - - var layerQuad = layer.layerQuad.clone(); - if (layer.usingGpuRasterization) { - var pixelRatio = window.devicePixelRatio || 1; - layerQuad.borderWidth = 2.0 * pixelRatio; - layerQuad.borderColor = 'rgba(154,205,50,0.75)'; - } else { - layerQuad.borderColor = 'rgba(0,0,0,0.75)'; - } - layerQuad.stackingGroupId = nextStackingGroupId++; - layerQuad.selectionToSetIfClicked = new cc.LayerSelection(layer); - layerQuad.layer = layer; - if (this.showOtherLayers && this.selectedLayer == layer) - layerQuad.upperBorderColor = 'rgb(156,189,45)'; - - if (this.showAnimationBounds) - this.appendAnimationQuads_(quads, layer, layerQuad); - - this.appendImageQuads_(quads, layer, layerQuad); - quads.push(layerQuad); - - - if (this.showInvalidations) - this.appendInvalidationQuads_(quads, layer, layerQuad); - if (this.showUnrecordedRegion) - this.appendUnrecordedRegionQuads_(quads, layer, layerQuad); - if (this.showBottlenecks) - this.appendBottleneckQuads_(quads, layer, layerQuad, - layerQuad.stackingGroupId); - if (this.showLayoutRects) - this.appendLayoutRectQuads_(quads, layer, layerQuad); - - if (this.howToShowTiles === 'coverage') { - this.appendTileCoverageRectQuads_( - quads, layer, layerQuad, this.tileHeatmapType); - } else if (this.howToShowTiles !== 'none') { - this.appendTilesWithScaleQuads_( - quads, layer, layerQuad, - this.howToShowTiles, this.tileHeatmapType); - } - - var highlights; - highlights = extraHighlightsByLayerId[layer.layerId]; - if (highlights) { - this.appendHighlightQuadsForLayer_( - quads, layer, layerQuad, highlights); - } - - highlights = selectionHighlightsByLayerId[layer.layerId]; - if (highlights) { - this.appendHighlightQuadsForLayer_( - quads, layer, layerQuad, highlights); - } - } - - this.layerTreeImpl.iterLayers(function(layer, depth, isMask, isReplica) { - if (!this.showOtherLayers && this.selectedLayer != layer) - return; - if (alreadyVisitedLayerIds[layer.layerId]) - return; - var layerQuad = layer.layerQuad; - var stackingGroupId = nextStackingGroupId++; - if (this.showBottlenecks) - this.appendBottleneckQuads_(quads, layer, layerQuad, stackingGroupId); - }, this); - - var tracedInputLatencies = this.layerTreeImpl.tracedInputLatencies; - if (this.showInputEvents && tracedInputLatencies) { - for (var i = 0; i < tracedInputLatencies.length; i++) { - var coordinatesArray = tracedInputLatencies[i].args.data.coordinates; - for (var j = 0; j < coordinatesArray.length; j++) { - var inputQuad = tr.b.Quad.fromXYWH( - coordinatesArray[j].x - 25, - coordinatesArray[j].y - 25, - 50, - 50); - inputQuad.borderColor = 'rgba(0, 0, 0, 0)'; - inputQuad.imageData = this.inputEventImageData_; - quads.push(inputQuad); - } - } - } - - return quads; - }, - - updateInfoBar_: function(infoBarMessages) { - if (infoBarMessages.length) { - this.infoBar_.removeAllButtons(); - this.infoBar_.message = 'Some problems were encountered...'; - this.infoBar_.addButton('More info...', function(e) { - var overlay = new tr.ui.b.Overlay(); - overlay.textContent = ''; - infoBarMessages.forEach(function(message) { - var title = document.createElement('h3'); - title.textContent = message.header; - - var details = document.createElement('div'); - details.textContent = message.details; - - overlay.appendChild(title); - overlay.appendChild(details); - }); - overlay.visible = true; - - e.stopPropagation(); - return false; - }); - this.infoBar_.visible = true; - } else { - this.infoBar_.removeAllButtons(); - this.infoBar_.message = ''; - this.infoBar_.visible = false; - } - }, - - getWhatRasterized_: function() { - var lthi = this.layerTreeImpl_.layerTreeHostImpl; - var renderProcess = lthi.objectInstance.parent; - var tasks = []; - for (var event of renderProcess.getDescendantEvents()) { - if (!(event instanceof tr.model.Slice)) - continue; - - var tile = tr.e.cc.getTileFromRasterTaskSlice(event); - if (tile === undefined) - continue; - - if (tile.containingSnapshot == lthi) - tasks.push(event); - } - return tasks; - }, - - updateWhatRasterizedLinkState_: function() { - var tasks = this.getWhatRasterized_(); - if (tasks.length) { - this.whatRasterizedLink_.textContent = tasks.length + ' raster tasks'; - this.whatRasterizedLink_.style.display = ''; - } else { - this.whatRasterizedLink_.textContent = ''; - this.whatRasterizedLink_.style.display = 'none'; - } - }, - - onWhatRasterizedLinkClicked_: function() { - var tasks = this.getWhatRasterized_(); - var event = new tr.model.RequestSelectionChangeEvent(); - event.selection = new tr.model.EventSet(tasks); - this.dispatchEvent(event); - } - }; - - return { - LayerTreeQuadStackView: LayerTreeQuadStackView - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/layer_tree_quad_stack_view_test.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/layer_tree_quad_stack_view_test.html deleted file mode 100644 index 50c6477c142..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/layer_tree_quad_stack_view_test.html +++ /dev/null @@ -1,49 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/extras/importer/trace_event_importer.html"> -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/ui/extras/chrome/cc/cc.html"> -<link rel="import" href="/tracing/ui/extras/chrome/cc/layer_tree_quad_stack_view.html"> - -<script src="/tracing/extras/chrome/cc/layer_tree_host_impl_test_data.js"> -</script> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - test('tileCoverageRectCount', function() { - var m = tr.c.TestUtils.newModelWithEvents([g_catLTHIEvents]); - var p = m.processes[1]; - - var instance = p.objects.getAllInstancesNamed('cc::LayerTreeHostImpl')[0]; - var lthi = instance.snapshots[0]; - var numLayers = lthi.activeTree.renderSurfaceLayerList.length; - var layer = lthi.activeTree.renderSurfaceLayerList[numLayers - 1]; - - var view = new tr.ui.e.chrome.cc.LayerTreeQuadStackView(); - view.layerTreeImpl = lthi.activeTree; - view.selection = new tr.ui.e.chrome.cc.LayerSelection(layer); - view.howToShowTiles = 'none'; - view.showInvalidations = false; - view.showContents = false; - view.showOtherLAyers = false; - - // There should be some quads drawn with all "show" checkboxes off, - // but that number can change with new features added. - var aQuads = view.generateLayerQuads(); - view.howToShowTiles = 'coverage'; - var bQuads = view.generateLayerQuads(); - var numCoverageRects = bQuads.length - aQuads.length; - - // We know we have 5 coverage rects in lthi cats. - assert.equal(numCoverageRects, 5); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/layer_view.css b/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/layer_view.css deleted file mode 100644 index 612dbc2eb9a..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/layer_view.css +++ /dev/null @@ -1,31 +0,0 @@ -/* Copyright (c) 2013 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -* /deep/ tr-ui-e-chrome-cc-layer-view { - -webkit-flex-direction: column; - display: -webkit-flex; - left: 0; - position: relative; - top: 0; -} - -* /deep/ tr-ui-e-chrome-cc-layer-view > - tr-ui-e-chrome-cc-layer-tree-quad-stack-view { - -webkit-flex: 1 1 100%; - -webkit-flex-direction: column; - min-height: 0; - display: -webkit-flex; - width: 100%; -} - -* /deep/tr-ui-e-chrome-cc- layer-view > tr-ui-e-chrome-cc-layer-view-analysis { - height: 150px; /* fixed height given by drag control */ - overflow-y: auto; -} - -* /deep/ tr-ui-e-chrome-cc-layer-view > - tr-ui-e-chrome-cc-layer-view-analysis * { - -webkit-user-select: text; -} diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/layer_view.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/layer_view.html deleted file mode 100644 index ab2a403283b..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/layer_view.html +++ /dev/null @@ -1,149 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="stylesheet" href="/tracing/ui/extras/chrome/cc/layer_view.css"> - -<link rel="import" href="/tracing/base/raf.html"> -<link rel="import" href="/tracing/base/settings.html"> -<link rel="import" href="/tracing/extras/chrome/cc/constants.html"> -<link rel="import" href="/tracing/extras/chrome/cc/picture.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/ui/base/drag_handle.html"> -<link rel="import" href="/tracing/ui/extras/chrome/cc/layer_tree_quad_stack_view.html"> - -<script> -'use strict'; - -/** - * @fileoverview LayerView coordinates graphical and analysis views of layers. - */ - -tr.exportTo('tr.ui.e.chrome.cc', function() { - var constants = tr.e.cc.constants; - - /** - * @constructor - */ - var LayerView = tr.ui.b.define('tr-ui-e-chrome-cc-layer-view'); - - LayerView.prototype = { - __proto__: HTMLUnknownElement.prototype, - - decorate: function() { - this.layerTreeQuadStackView_ = - new tr.ui.e.chrome.cc.LayerTreeQuadStackView(); - this.dragBar_ = document.createElement('tr-ui-b-drag-handle'); - this.analysisEl_ = - document.createElement('tr-ui-e-chrome-cc-layer-view-analysis'); - this.analysisEl_.addEventListener('requestSelectionChange', - this.onRequestSelectionChangeFromAnalysisEl_.bind(this)); - - this.dragBar_.target = this.analysisEl_; - - this.appendChild(this.layerTreeQuadStackView_); - this.appendChild(this.dragBar_); - this.appendChild(this.analysisEl_); - - this.layerTreeQuadStackView_.addEventListener('selection-change', - function() { - this.layerTreeQuadStackViewSelectionChanged_(); - }.bind(this)); - this.layerTreeQuadStackViewSelectionChanged_(); - }, - - get layerTreeImpl() { - return this.layerTreeQuadStackView_.layerTreeImpl; - }, - - set layerTreeImpl(newValue) { - return this.layerTreeQuadStackView_.layerTreeImpl = newValue; - }, - - set isRenderPassQuads(newValue) { - return this.layerTreeQuadStackView_.isRenderPassQuads = newValue; - }, - - get selection() { - return this.layerTreeQuadStackView_.selection; - }, - - set selection(newValue) { - this.layerTreeQuadStackView_.selection = newValue; - }, - - regenerateContent: function() { - this.layerTreeQuadStackView_.regenerateContent(); - }, - - layerTreeQuadStackViewSelectionChanged_: function() { - var selection = this.layerTreeQuadStackView_.selection; - if (selection) { - this.dragBar_.style.display = ''; - this.analysisEl_.style.display = ''; - this.analysisEl_.textContent = ''; - - var layer = selection.layer; - if (layer && layer.args && layer.args.pictures) { - this.analysisEl_.appendChild( - this.createPictureBtn_(layer.args.pictures)); - } - - var analysis = selection.createAnalysis(); - this.analysisEl_.appendChild(analysis); - } else { - this.dragBar_.style.display = 'none'; - this.analysisEl_.style.display = 'none'; - var analysis = this.analysisEl_.firstChild; - if (analysis) - this.analysisEl_.removeChild(analysis); - this.layerTreeQuadStackView_.style.height = - window.getComputedStyle(this).height; - } - tr.b.dispatchSimpleEvent(this, 'selection-change'); - }, - - createPictureBtn_: function(pictures) { - if (!(pictures instanceof Array)) - pictures = [pictures]; - - var link = document.createElement('tr-ui-a-analysis-link'); - link.selection = function() { - var layeredPicture = new tr.e.cc.LayeredPicture(pictures); - var snapshot = new tr.e.cc.PictureSnapshot(layeredPicture); - snapshot.picture = layeredPicture; - - var selection = new tr.model.EventSet(); - selection.push(snapshot); - return selection; - }; - link.textContent = 'View in Picture Debugger'; - return link; - }, - - onRequestSelectionChangeFromAnalysisEl_: function(e) { - if (!(e.selection instanceof tr.ui.e.chrome.cc.Selection)) - return; - - e.stopPropagation(); - this.selection = e.selection; - }, - - get extraHighlightsByLayerId() { - return this.layerTreeQuadStackView_.extraHighlightsByLayerId; - }, - - set extraHighlightsByLayerId(extraHighlightsByLayerId) { - this.layerTreeQuadStackView_.extraHighlightsByLayerId = - extraHighlightsByLayerId; - } - }; - - return { - LayerView: LayerView - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/layer_view_test.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/layer_view_test.html deleted file mode 100644 index a4bcab78785..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/layer_view_test.html +++ /dev/null @@ -1,55 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/extras/importer/trace_event_importer.html"> -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/ui/extras/chrome/cc/cc.html"> -<link rel="import" href="/tracing/ui/extras/chrome/cc/layer_view.html"> - -<script src="/tracing/extras/chrome/cc/layer_tree_host_impl_test_data.js"> -</script> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - test('instantiate', function() { - var m = tr.c.TestUtils.newModelWithEvents([g_catLTHIEvents]); - var p = m.processes[1]; - - var instance = p.objects.getAllInstancesNamed('cc::LayerTreeHostImpl')[0]; - var lthi = instance.snapshots[0]; - var numLayers = lthi.activeTree.renderSurfaceLayerList.length; - var layer = lthi.activeTree.renderSurfaceLayerList[numLayers - 1]; - - var view = new tr.ui.e.chrome.cc.LayerView(); - view.style.height = '500px'; - view.layerTreeImpl = lthi.activeTree; - view.selection = new tr.ui.e.chrome.cc.LayerSelection(layer); - - this.addHTMLOutput(view); - }); - - test('instantiate_withTileHighlight', function() { - var m = tr.c.TestUtils.newModelWithEvents([g_catLTHIEvents]); - var p = m.processes[1]; - - var instance = p.objects.getAllInstancesNamed('cc::LayerTreeHostImpl')[0]; - var lthi = instance.snapshots[0]; - var numLayers = lthi.activeTree.renderSurfaceLayerList.length; - var layer = lthi.activeTree.renderSurfaceLayerList[numLayers - 1]; - var tile = lthi.activeTiles[0]; - - var view = new tr.ui.e.chrome.cc.LayerView(); - view.style.height = '500px'; - view.layerTreeImpl = lthi.activeTree; - view.selection = new tr.ui.e.chrome.cc.TileSelection(tile); - this.addHTMLOutput(view); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/picture_debugger.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/picture_debugger.html deleted file mode 100644 index 28d51d16d93..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/picture_debugger.html +++ /dev/null @@ -1,495 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/base64.html"> -<link rel="import" href="/tracing/extras/chrome/cc/picture.html"> -<link rel="import" href="/tracing/ui/analysis/generic_object_view.html"> -<link rel="import" href="/tracing/ui/base/drag_handle.html"> -<link rel="import" href="/tracing/ui/base/info_bar.html"> -<link rel="import" href="/tracing/ui/base/hotkey_controller.html"> -<link rel="import" href="/tracing/ui/base/list_view.html"> -<link rel="import" href="/tracing/ui/base/mouse_mode_selector.html"> -<link rel="import" href="/tracing/ui/base/overlay.html"> -<link rel="import" href="/tracing/ui/base/utils.html"> -<link rel="import" - href="/tracing/ui/extras/chrome/cc/picture_ops_chart_summary_view.html"> -<link rel="import" href="/tracing/ui/extras/chrome/cc/picture_ops_chart_view.html"> -<link rel="import" href="/tracing/ui/extras/chrome/cc/picture_ops_list_view.html"> - -<template id="tr-ui-e-chrome-cc-picture-debugger-template"> - <style> - * /deep/ tr-ui-e-chrome-cc-picture-debugger { - -webkit-flex: 1 1 auto; - -webkit-flex-direction: row; - display: -webkit-flex; - } - - * /deep/ tr-ui-e-chrome-cc-picture-debugger > tr-ui-a-generic-object-view { - -webkit-flex-direction: column; - display: -webkit-flex; - width: 400px; - } - - * /deep/ tr-ui-e-chrome-cc-picture-debugger > left-panel { - -webkit-flex-direction: column; - display: -webkit-flex; - min-width: 300px; - } - - * /deep/ tr-ui-e-chrome-cc-picture-debugger > left-panel > picture-info { - -webkit-flex: 0 0 auto; - padding-top: 2px; - } - - * /deep/ tr-ui-e-chrome-cc-picture-debugger > left-panel > - picture-info .title { - font-weight: bold; - margin-left: 5px; - margin-right: 5px; - } - - * /deep/ tr-ui-e-chrome-cc-picture-debugger > tr-ui-b-drag-handle { - -webkit-flex: 0 0 auto; - } - - * /deep/ tr-ui-e-chrome-cc-picture-debugger .filename { - -webkit-user-select: text; - margin-left: 5px; - } - - * /deep/ tr-ui-e-chrome-cc-picture-debugger > right-panel { - -webkit-flex: 1 1 auto; - -webkit-flex-direction: column; - display: -webkit-flex; - } - - * /deep/ tr-ui-e-chrome-cc-picture-debugger > right-panel > - tr-ui-e-chrome-cc-picture-ops-chart-view { - min-height: 150px; - min-width : 0; - overflow-x: auto; - overflow-y: hidden; - } - - /*************************************************/ - - * /deep/ tr-ui-e-chrome-cc-picture-debugger raster-area { - background-color: #ddd; - min-height: 200px; - min-width: 200px; - overflow-y: auto; - padding-left: 5px; - } - </style> - - <left-panel> - <picture-info> - <div> - <span class='title'>Skia Picture</span> - <span class='size'></span> - </div> - <div> - <input class='filename' type='text' value='skpicture.skp' /> - <button class='export'>Export</button> - </div> - </picture-info> - </left-panel> - <right-panel> - <tr-ui-e-chrome-cc-picture-ops-chart-view> - </tr-ui-e-chrome-cc-picture-ops-chart-view> - <raster-area><canvas></canvas></raster-area> - </right-panel> -</template> - -<script> -'use strict'; - -tr.exportTo('tr.ui.e.chrome.cc', function() { - var THIS_DOC = document.currentScript.ownerDocument; - - /** - * PictureDebugger is a view of a PictureSnapshot for inspecting - * the picture in detail. (e.g., timing information, etc.) - * - * @constructor - */ - var PictureDebugger = tr.ui.b.define('tr-ui-e-chrome-cc-picture-debugger'); - - PictureDebugger.prototype = { - __proto__: HTMLUnknownElement.prototype, - - decorate: function() { - var node = tr.ui.b.instantiateTemplate( - '#tr-ui-e-chrome-cc-picture-debugger-template', THIS_DOC); - - this.appendChild(node); - - this.pictureAsImageData_ = undefined; - this.showOverdraw_ = false; - this.zoomScaleValue_ = 1; - - this.sizeInfo_ = this.querySelector('.size'); - this.rasterArea_ = this.querySelector('raster-area'); - this.rasterCanvas_ = this.rasterArea_.querySelector('canvas'); - this.rasterCtx_ = this.rasterCanvas_.getContext('2d'); - - this.filename_ = this.querySelector('.filename'); - - this.drawOpsChartSummaryView_ = - new tr.ui.e.chrome.cc.PictureOpsChartSummaryView(); - this.drawOpsChartView_ = new tr.ui.e.chrome.cc.PictureOpsChartView(); - this.drawOpsChartView_.addEventListener( - 'selection-changed', this.onChartBarClicked_.bind(this)); - - this.exportButton_ = this.querySelector('.export'); - this.exportButton_.addEventListener( - 'click', this.onSaveAsSkPictureClicked_.bind(this)); - - this.trackMouse_(); - - var overdrawCheckbox = tr.ui.b.createCheckBox( - this, 'showOverdraw', - 'pictureView.showOverdraw', false, - 'Show overdraw'); - - var chartCheckbox = tr.ui.b.createCheckBox( - this, 'showSummaryChart', - 'pictureView.showSummaryChart', false, - 'Show timing summary'); - - var pictureInfo = this.querySelector('picture-info'); - pictureInfo.appendChild(overdrawCheckbox); - pictureInfo.appendChild(chartCheckbox); - - this.drawOpsView_ = new tr.ui.e.chrome.cc.PictureOpsListView(); - this.drawOpsView_.addEventListener( - 'selection-changed', this.onChangeDrawOps_.bind(this)); - - var leftPanel = this.querySelector('left-panel'); - leftPanel.appendChild(this.drawOpsChartSummaryView_); - leftPanel.appendChild(this.drawOpsView_); - - var middleDragHandle = document.createElement('tr-ui-b-drag-handle'); - middleDragHandle.horizontal = false; - middleDragHandle.target = leftPanel; - - var rightPanel = this.querySelector('right-panel'); - rightPanel.replaceChild( - this.drawOpsChartView_, - rightPanel.querySelector('tr-ui-e-chrome-cc-picture-ops-chart-view')); - - this.infoBar_ = document.createElement('tr-ui-b-info-bar'); - this.rasterArea_.appendChild(this.infoBar_); - - this.insertBefore(middleDragHandle, rightPanel); - - this.picture_ = undefined; - - var hkc = document.createElement('tv-ui-b-hotkey-controller'); - hkc.addHotKey(new tr.ui.b.HotKey({ - eventType: 'keypress', - thisArg: this, - keyCode: 'h'.charCodeAt(0), - callback: function(e) { - this.moveSelectedOpBy(-1); - e.stopPropagation(); - } - })); - hkc.addHotKey(new tr.ui.b.HotKey({ - eventType: 'keypress', - thisArg: this, - keyCode: 'l'.charCodeAt(0), - callback: function(e) { - this.moveSelectedOpBy(1); - e.stopPropagation(); - } - })); - this.appendChild(hkc); - - // Add a mutation observer so that when the view is resized we can - // update the chart summary view. - this.mutationObserver_ = new MutationObserver( - this.onMutation_.bind(this)); - this.mutationObserver_.observe(leftPanel, { attributes: true }); - }, - - onMutation_: function(mutations) { - - for (var m = 0; m < mutations.length; m++) { - // A style change would indicate that the element has resized - // so we should re-render the chart. - if (mutations[m].attributeName === 'style') { - this.drawOpsChartSummaryView_.requiresRedraw = true; - this.drawOpsChartSummaryView_.updateChartContents(); - - this.drawOpsChartView_.dimensionsHaveChanged = true; - this.drawOpsChartView_.updateChartContents(); - break; - } - } - }, - - onSaveAsSkPictureClicked_: function() { - // Decode base64 data into a String - var rawData = tr.b.Base64.atob(this.picture_.getBase64SkpData()); - - // Convert this String into an Uint8Array - var length = rawData.length; - var arrayBuffer = new ArrayBuffer(length); - var uint8Array = new Uint8Array(arrayBuffer); - for (var c = 0; c < length; c++) - uint8Array[c] = rawData.charCodeAt(c); - - // Create a blob URL from the binary array. - var blob = new Blob([uint8Array], {type: 'application/octet-binary'}); - var blobUrl = window.webkitURL.createObjectURL(blob); - - // Create a link and click on it. BEST API EVAR! - var link = document.createElementNS('http://www.w3.org/1999/xhtml', 'a'); - link.href = blobUrl; - link.download = this.filename_.value; - var event = document.createEvent('MouseEvents'); - event.initMouseEvent( - 'click', true, false, window, 0, 0, 0, 0, 0, - false, false, false, false, 0, null); - link.dispatchEvent(event); - }, - - get picture() { - return this.picture_; - }, - - set picture(picture) { - this.drawOpsView_.picture = picture; - this.drawOpsChartView_.picture = picture; - this.drawOpsChartSummaryView_.picture = picture; - this.picture_ = picture; - - this.exportButton_.disabled = !this.picture_.canSave; - - if (picture) { - var size = this.getRasterCanvasSize_(); - this.rasterCanvas_.width = size.width; - this.rasterCanvas_.height = size.height; - } - - var bounds = this.rasterArea_.getBoundingClientRect(); - var selectorBounds = this.mouseModeSelector_.getBoundingClientRect(); - this.mouseModeSelector_.pos = { - x: (bounds.right - selectorBounds.width - 10), - y: bounds.top - }; - - this.rasterize_(); - - this.scheduleUpdateContents_(); - }, - - getRasterCanvasSize_: function() { - var style = window.getComputedStyle(this.rasterArea_); - var width = - Math.max(parseInt(style.width), this.picture_.layerRect.width); - var height = - Math.max(parseInt(style.height), this.picture_.layerRect.height); - - return { - width: width, - height: height - }; - }, - - scheduleUpdateContents_: function() { - if (this.updateContentsPending_) - return; - this.updateContentsPending_ = true; - tr.b.requestAnimationFrameInThisFrameIfPossible( - this.updateContents_.bind(this) - ); - }, - - updateContents_: function() { - this.updateContentsPending_ = false; - - if (this.picture_) { - this.sizeInfo_.textContent = '(' + - this.picture_.layerRect.width + ' x ' + - this.picture_.layerRect.height + ')'; - } - - this.drawOpsChartView_.updateChartContents(); - this.drawOpsChartView_.scrollSelectedItemIntoViewIfNecessary(); - - // Return if picture hasn't finished rasterizing. - if (!this.pictureAsImageData_) - return; - - this.infoBar_.visible = false; - this.infoBar_.removeAllButtons(); - if (this.pictureAsImageData_.error) { - this.infoBar_.message = 'Cannot rasterize...'; - this.infoBar_.addButton('More info...', function(e) { - var overlay = new tr.ui.b.Overlay(); - overlay.textContent = this.pictureAsImageData_.error; - overlay.visible = true; - e.stopPropagation(); - return false; - }.bind(this)); - this.infoBar_.visible = true; - } - - this.drawPicture_(); - }, - - drawPicture_: function() { - var size = this.getRasterCanvasSize_(); - if (size.width !== this.rasterCanvas_.width) - this.rasterCanvas_.width = size.width; - if (size.height !== this.rasterCanvas_.height) - this.rasterCanvas_.height = size.height; - - this.rasterCtx_.clearRect(0, 0, size.width, size.height); - - if (!this.pictureAsImageData_.imageData) - return; - - var imgCanvas = this.pictureAsImageData_.asCanvas(); - var w = imgCanvas.width; - var h = imgCanvas.height; - this.rasterCtx_.drawImage(imgCanvas, 0, 0, w, h, - 0, 0, w * this.zoomScaleValue_, - h * this.zoomScaleValue_); - }, - - rasterize_: function() { - if (this.picture_) { - this.picture_.rasterize( - { - stopIndex: this.drawOpsView_.selectedOpIndex, - showOverdraw: this.showOverdraw_ - }, - this.onRasterComplete_.bind(this)); - } - }, - - onRasterComplete_: function(pictureAsImageData) { - this.pictureAsImageData_ = pictureAsImageData; - this.scheduleUpdateContents_(); - }, - - moveSelectedOpBy: function(increment) { - if (this.selectedOpIndex === undefined) { - this.selectedOpIndex = 0; - return; - } - this.selectedOpIndex = tr.b.clamp( - this.selectedOpIndex + increment, - 0, this.numOps); - }, - - get numOps() { - return this.drawOpsView_.numOps; - }, - - get selectedOpIndex() { - return this.drawOpsView_.selectedOpIndex; - }, - - set selectedOpIndex(index) { - this.drawOpsView_.selectedOpIndex = index; - this.drawOpsChartView_.selectedOpIndex = index; - }, - - onChartBarClicked_: function(e) { - this.drawOpsView_.selectedOpIndex = - this.drawOpsChartView_.selectedOpIndex; - }, - - onChangeDrawOps_: function(e) { - this.rasterize_(); - this.scheduleUpdateContents_(); - - this.drawOpsChartView_.selectedOpIndex = - this.drawOpsView_.selectedOpIndex; - }, - - set showOverdraw(v) { - this.showOverdraw_ = v; - this.rasterize_(); - }, - - set showSummaryChart(chartShouldBeVisible) { - if (chartShouldBeVisible) - this.drawOpsChartSummaryView_.show(); - else - this.drawOpsChartSummaryView_.hide(); - }, - - trackMouse_: function() { - this.mouseModeSelector_ = document.createElement( - 'tr-ui-b-mouse-mode-selector'); - this.mouseModeSelector_.targetElement = this.rasterArea_; - this.rasterArea_.appendChild(this.mouseModeSelector_); - - this.mouseModeSelector_.supportedModeMask = - tr.ui.b.MOUSE_SELECTOR_MODE.ZOOM; - this.mouseModeSelector_.mode = tr.ui.b.MOUSE_SELECTOR_MODE.ZOOM; - this.mouseModeSelector_.defaultMode = tr.ui.b.MOUSE_SELECTOR_MODE.ZOOM; - this.mouseModeSelector_.settingsKey = 'pictureDebugger.mouseModeSelector'; - - this.mouseModeSelector_.addEventListener('beginzoom', - this.onBeginZoom_.bind(this)); - this.mouseModeSelector_.addEventListener('updatezoom', - this.onUpdateZoom_.bind(this)); - this.mouseModeSelector_.addEventListener('endzoom', - this.onEndZoom_.bind(this)); - }, - - onBeginZoom_: function(e) { - this.isZooming_ = true; - - this.lastMouseViewPos_ = this.extractRelativeMousePosition_(e); - - e.preventDefault(); - }, - - onUpdateZoom_: function(e) { - if (!this.isZooming_) - return; - - var currentMouseViewPos = this.extractRelativeMousePosition_(e); - - // Take the distance the mouse has moved and we want to zoom at about - // 1/1000th of that speed. 0.01 feels jumpy. This could possibly be tuned - // more if people feel it's too slow. - this.zoomScaleValue_ += - ((this.lastMouseViewPos_.y - currentMouseViewPos.y) * 0.001); - this.zoomScaleValue_ = Math.max(this.zoomScaleValue_, 0.1); - - this.drawPicture_(); - - this.lastMouseViewPos_ = currentMouseViewPos; - }, - - onEndZoom_: function(e) { - this.lastMouseViewPos_ = undefined; - this.isZooming_ = false; - e.preventDefault(); - }, - - extractRelativeMousePosition_: function(e) { - return { - x: e.clientX - this.rasterArea_.offsetLeft, - y: e.clientY - this.rasterArea_.offsetTop - }; - } - }; - - return { - PictureDebugger: PictureDebugger - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/picture_debugger_test.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/picture_debugger_test.html deleted file mode 100644 index 1237fb6a29c..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/picture_debugger_test.html +++ /dev/null @@ -1,32 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/extras/chrome/cc/picture.html"> -<link rel="import" href="/tracing/ui/extras/chrome/cc/picture_debugger.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - test('instantiate', function() { - var picture = new tr.e.cc.PictureSnapshot({id: '31415'}, 10, { - 'params': { - 'opaque_rect': [-15, -15, 0, 0], - 'layer_rect': [-15, -15, 46, 833] - }, - 'skp64': 'DAAAAHYEAADzAQAABwAAAAFkYWVy8AAAAAgAAB4DAAAADAAAIAAAgD8AAIA/CAAAHgMAAAAcAAADAAAAAAAAAAAAwI5EAID5QwEAAADoAAAACAAAHgMAAAAMAAAjAAAAAAAAAAAMAAAjAAAAAAAAAAAcAAADAAAAAAAAAAAAwI5EAID5QwEAAADkAAAAGAAAFQEAAAAAAAAAAAAAAADAjkQAgPlDGAAAFQIAAAAAAAAAAAAAAADAjkQAgPlDCAAAHgMAAAAcAAADAAAAAAAAAAAAwI5EAID5QwEAAADgAAAAGAAAFQMAAAAAAKBAAACgQAAAgEIAAIBCBAAAHAQAABwEAAAcBAAAHHRjYWYBAAAADVNrU3JjWGZlcm1vZGVjZnB0AAAAAHlhcmGgAAAAIHRucAMAAAAAAEBBAACAPwAAAAAAAIA/AAAAAAAAgEAAAP//ADABAAAAAAAAAEBBAACAPwAAAAAAAIA/AAAAAAAAgED/////AjABAAAAAAAAAAAAAAAAAAEAAAAEAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQEEAAIA/AAAAAAAAgD8AAAAAAACAQP8AAP8AMAEAAAAAACBmb2U=' // @suppress longLineCheck - }); - picture.preInitialize(); - picture.initialize(); - - var dbg = new tr.ui.e.chrome.cc.PictureDebugger(); - this.addHTMLOutput(dbg); - dbg.picture = picture; - dbg.style.border = '1px solid black'; - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/picture_ops_chart_summary_view.css b/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/picture_ops_chart_summary_view.css deleted file mode 100644 index fdc93e54c60..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/picture_ops_chart_summary_view.css +++ /dev/null @@ -1,18 +0,0 @@ -/* Copyright (c) 2013 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -* /deep/ tr-ui-e-chrome-cc-picture-ops-chart-summary-view { - -webkit-flex: 0 0 auto; - font-size: 0; - margin: 0; - min-height: 200px; - min-width: 200px; - overflow: hidden; - padding: 0; -} - -* /deep/ tr-ui-e-chrome-cc-picture-ops-chart-summary-view.hidden { - display: none; -} diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/picture_ops_chart_summary_view.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/picture_ops_chart_summary_view.html deleted file mode 100644 index 5ac0efb3d71..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/picture_ops_chart_summary_view.html +++ /dev/null @@ -1,472 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="stylesheet" - href="/tracing/ui/extras/chrome/cc/picture_ops_chart_summary_view.css"> - -<link rel="import" href="/tracing/ui/base/ui.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.e.chrome.cc', function() { - var OPS_TIMING_ITERATIONS = 3; - var CHART_PADDING_LEFT = 65; - var CHART_PADDING_RIGHT = 40; - var AXIS_PADDING_LEFT = 60; - var AXIS_PADDING_RIGHT = 35; - var AXIS_PADDING_TOP = 25; - var AXIS_PADDING_BOTTOM = 45; - var AXIS_LABEL_PADDING = 5; - var AXIS_TICK_SIZE = 10; - var LABEL_PADDING = 5; - var LABEL_INTERLEAVE_OFFSET = 15; - var BAR_PADDING = 5; - var VERTICAL_TICKS = 5; - var HUE_CHAR_CODE_ADJUSTMENT = 5.7; - - /** - * Provides a chart showing the cumulative time spent in Skia operations - * during picture rasterization. - * - * @constructor - */ - var PictureOpsChartSummaryView = tr.ui.b.define( - 'tr-ui-e-chrome-cc-picture-ops-chart-summary-view'); - - PictureOpsChartSummaryView.prototype = { - __proto__: HTMLUnknownElement.prototype, - - decorate: function() { - this.picture_ = undefined; - this.pictureDataProcessed_ = false; - - this.chartScale_ = window.devicePixelRatio; - - this.chart_ = document.createElement('canvas'); - this.chartCtx_ = this.chart_.getContext('2d'); - this.appendChild(this.chart_); - - this.opsTimingData_ = []; - - this.chartWidth_ = 0; - this.chartHeight_ = 0; - this.requiresRedraw_ = true; - - this.currentBarMouseOverTarget_ = null; - - this.chart_.addEventListener('mousemove', this.onMouseMove_.bind(this)); - }, - - get requiresRedraw() { - return this.requiresRedraw_; - }, - - set requiresRedraw(requiresRedraw) { - this.requiresRedraw_ = requiresRedraw; - }, - - get picture() { - return this.picture_; - }, - - set picture(picture) { - this.picture_ = picture; - this.pictureDataProcessed_ = false; - - if (this.classList.contains('hidden')) - return; - - this.processPictureData_(); - this.requiresRedraw = true; - this.updateChartContents(); - }, - - hide: function() { - this.classList.add('hidden'); - }, - - show: function() { - - this.classList.remove('hidden'); - - if (this.pictureDataProcessed_) - return; - - this.processPictureData_(); - this.requiresRedraw = true; - this.updateChartContents(); - - }, - - onMouseMove_: function(e) { - - var lastBarMouseOverTarget = this.currentBarMouseOverTarget_; - this.currentBarMouseOverTarget_ = null; - - var x = e.offsetX; - var y = e.offsetY; - - var chartLeft = CHART_PADDING_LEFT; - var chartRight = this.chartWidth_ - CHART_PADDING_RIGHT; - var chartTop = AXIS_PADDING_TOP; - var chartBottom = this.chartHeight_ - AXIS_PADDING_BOTTOM; - var chartInnerWidth = chartRight - chartLeft; - - if (x > chartLeft && x < chartRight && y > chartTop && y < chartBottom) { - - this.currentBarMouseOverTarget_ = Math.floor( - (x - chartLeft) / chartInnerWidth * this.opsTimingData_.length); - - this.currentBarMouseOverTarget_ = tr.b.clamp( - this.currentBarMouseOverTarget_, 0, this.opsTimingData_.length - 1); - - } - - if (this.currentBarMouseOverTarget_ === lastBarMouseOverTarget) - return; - - this.drawChartContents_(); - }, - - updateChartContents: function() { - - if (this.requiresRedraw) - this.updateChartDimensions_(); - - this.drawChartContents_(); - }, - - updateChartDimensions_: function() { - this.chartWidth_ = this.offsetWidth; - this.chartHeight_ = this.offsetHeight; - - // Scale up the canvas according to the devicePixelRatio, then reduce it - // down again via CSS. Finally we apply a scale to the canvas so that - // things are drawn at the correct size. - this.chart_.width = this.chartWidth_ * this.chartScale_; - this.chart_.height = this.chartHeight_ * this.chartScale_; - - this.chart_.style.width = this.chartWidth_ + 'px'; - this.chart_.style.height = this.chartHeight_ + 'px'; - - this.chartCtx_.scale(this.chartScale_, this.chartScale_); - }, - - processPictureData_: function() { - - this.resetOpsTimingData_(); - this.pictureDataProcessed_ = true; - - if (!this.picture_) - return; - - var ops = this.picture_.getOps(); - if (!ops) - return; - - ops = this.picture_.tagOpsWithTimings(ops); - - // Check that there are valid times. - if (ops[0].cmd_time === undefined) - return; - - this.collapseOpsToTimingBuckets_(ops); - }, - - drawChartContents_: function() { - - this.clearChartContents_(); - - if (this.opsTimingData_.length === 0) { - this.showNoTimingDataMessage_(); - return; - } - - this.drawChartAxes_(); - this.drawBars_(); - this.drawLineAtBottomOfChart_(); - - if (this.currentBarMouseOverTarget_ === null) - return; - - this.drawTooltip_(); - }, - - drawLineAtBottomOfChart_: function() { - this.chartCtx_.strokeStyle = '#AAA'; - this.chartCtx_.moveTo(0, this.chartHeight_ - 0.5); - this.chartCtx_.lineTo(this.chartWidth_, this.chartHeight_ - 0.5); - this.chartCtx_.stroke(); - }, - - drawTooltip_: function() { - - var tooltipData = this.opsTimingData_[this.currentBarMouseOverTarget_]; - var tooltipTitle = tooltipData.cmd_string; - var tooltipTime = tooltipData.cmd_time.toFixed(4); - - var tooltipWidth = 110; - var tooltipHeight = 40; - var chartInnerWidth = this.chartWidth_ - CHART_PADDING_RIGHT - - CHART_PADDING_LEFT; - var barWidth = chartInnerWidth / this.opsTimingData_.length; - var tooltipOffset = Math.round((tooltipWidth - barWidth) * 0.5); - - var left = CHART_PADDING_LEFT + this.currentBarMouseOverTarget_ * - barWidth - tooltipOffset; - var top = Math.round((this.chartHeight_ - tooltipHeight) * 0.5); - - this.chartCtx_.save(); - - this.chartCtx_.shadowOffsetX = 0; - this.chartCtx_.shadowOffsetY = 5; - this.chartCtx_.shadowBlur = 4; - this.chartCtx_.shadowColor = 'rgba(0,0,0,0.4)'; - - this.chartCtx_.strokeStyle = '#888'; - this.chartCtx_.fillStyle = '#EEE'; - this.chartCtx_.fillRect(left, top, tooltipWidth, tooltipHeight); - - this.chartCtx_.shadowColor = 'transparent'; - this.chartCtx_.translate(0.5, 0.5); - this.chartCtx_.strokeRect(left, top, tooltipWidth, tooltipHeight); - - this.chartCtx_.restore(); - - this.chartCtx_.fillStyle = '#222'; - this.chartCtx_.textBaseline = 'top'; - this.chartCtx_.font = '800 12px Arial'; - this.chartCtx_.fillText(tooltipTitle, left + 8, top + 8); - - this.chartCtx_.fillStyle = '#555'; - this.chartCtx_.textBaseline = 'top'; - this.chartCtx_.font = '400 italic 10px Arial'; - this.chartCtx_.fillText('Total: ' + tooltipTime + 'ms', - left + 8, top + 22); - }, - - drawBars_: function() { - - var len = this.opsTimingData_.length; - var max = this.opsTimingData_[0].cmd_time; - var min = this.opsTimingData_[len - 1].cmd_time; - - var width = this.chartWidth_ - CHART_PADDING_LEFT - CHART_PADDING_RIGHT; - var height = this.chartHeight_ - AXIS_PADDING_TOP - AXIS_PADDING_BOTTOM; - var barWidth = Math.floor(width / len); - - var opData; - var opTiming; - var opHeight; - var opLabel; - var barLeft; - - for (var b = 0; b < len; b++) { - - opData = this.opsTimingData_[b]; - opTiming = opData.cmd_time / max; - - opHeight = Math.round(Math.max(1, opTiming * height)); - opLabel = opData.cmd_string; - barLeft = CHART_PADDING_LEFT + b * barWidth; - - this.chartCtx_.fillStyle = this.getOpColor_(opLabel); - - this.chartCtx_.fillRect(barLeft + BAR_PADDING, AXIS_PADDING_TOP + - height - opHeight, barWidth - 2 * BAR_PADDING, opHeight); - } - - }, - - getOpColor_: function(opName) { - - var characters = opName.split(''); - var hue = characters.reduce(this.reduceNameToHue, 0) % 360; - - return 'hsl(' + hue + ', 30%, 50%)'; - }, - - reduceNameToHue: function(previousValue, currentValue, index, array) { - // Get the char code and apply a magic adjustment value so we get - // pretty colors from around the rainbow. - return Math.round(previousValue + currentValue.charCodeAt(0) * - HUE_CHAR_CODE_ADJUSTMENT); - }, - - drawChartAxes_: function() { - - var len = this.opsTimingData_.length; - var max = this.opsTimingData_[0].cmd_time; - var min = this.opsTimingData_[len - 1].cmd_time; - - var width = this.chartWidth_ - AXIS_PADDING_LEFT - AXIS_PADDING_RIGHT; - var height = this.chartHeight_ - AXIS_PADDING_TOP - AXIS_PADDING_BOTTOM; - - var totalBarWidth = this.chartWidth_ - CHART_PADDING_LEFT - - CHART_PADDING_RIGHT; - var barWidth = Math.floor(totalBarWidth / len); - var tickYInterval = height / (VERTICAL_TICKS - 1); - var tickYPosition = 0; - var tickValInterval = (max - min) / (VERTICAL_TICKS - 1); - var tickVal = 0; - - this.chartCtx_.fillStyle = '#333'; - this.chartCtx_.strokeStyle = '#777'; - this.chartCtx_.save(); - - // Translate half a pixel to avoid blurry lines. - this.chartCtx_.translate(0.5, 0.5); - - // Sides. - - this.chartCtx_.save(); - - this.chartCtx_.translate(AXIS_PADDING_LEFT, AXIS_PADDING_TOP); - this.chartCtx_.moveTo(0, 0); - this.chartCtx_.lineTo(0, height); - this.chartCtx_.lineTo(width, height); - - // Y-axis ticks. - this.chartCtx_.font = '10px Arial'; - this.chartCtx_.textAlign = 'right'; - this.chartCtx_.textBaseline = 'middle'; - - for (var t = 0; t < VERTICAL_TICKS; t++) { - - tickYPosition = Math.round(t * tickYInterval); - tickVal = (max - t * tickValInterval).toFixed(4); - - this.chartCtx_.moveTo(0, tickYPosition); - this.chartCtx_.lineTo(-AXIS_TICK_SIZE, tickYPosition); - this.chartCtx_.fillText(tickVal, - -AXIS_TICK_SIZE - AXIS_LABEL_PADDING, tickYPosition); - - } - - this.chartCtx_.stroke(); - - this.chartCtx_.restore(); - - - // Labels. - - this.chartCtx_.save(); - - this.chartCtx_.translate(CHART_PADDING_LEFT + Math.round(barWidth * 0.5), - AXIS_PADDING_TOP + height + LABEL_PADDING); - - this.chartCtx_.font = '10px Arial'; - this.chartCtx_.textAlign = 'center'; - this.chartCtx_.textBaseline = 'top'; - - var labelTickLeft; - var labelTickBottom; - for (var l = 0; l < len; l++) { - - labelTickLeft = Math.round(l * barWidth); - labelTickBottom = l % 2 * LABEL_INTERLEAVE_OFFSET; - - this.chartCtx_.save(); - this.chartCtx_.moveTo(labelTickLeft, -LABEL_PADDING); - this.chartCtx_.lineTo(labelTickLeft, labelTickBottom); - this.chartCtx_.stroke(); - this.chartCtx_.restore(); - - this.chartCtx_.fillText(this.opsTimingData_[l].cmd_string, - labelTickLeft, labelTickBottom); - } - - this.chartCtx_.restore(); - - this.chartCtx_.restore(); - }, - - clearChartContents_: function() { - this.chartCtx_.clearRect(0, 0, this.chartWidth_, this.chartHeight_); - }, - - showNoTimingDataMessage_: function() { - this.chartCtx_.font = '800 italic 14px Arial'; - this.chartCtx_.fillStyle = '#333'; - this.chartCtx_.textAlign = 'center'; - this.chartCtx_.textBaseline = 'middle'; - this.chartCtx_.fillText('No timing data available.', - this.chartWidth_ * 0.5, this.chartHeight_ * 0.5); - }, - - collapseOpsToTimingBuckets_: function(ops) { - - var opsTimingDataIndexHash_ = {}; - var timingData = this.opsTimingData_; - var op; - var opIndex; - - for (var i = 0; i < ops.length; i++) { - - op = ops[i]; - - if (op.cmd_time === undefined) - continue; - - // Try to locate the entry for the current operation - // based on its name. If that fails, then create one for it. - opIndex = opsTimingDataIndexHash_[op.cmd_string] || null; - - if (opIndex === null) { - timingData.push({ - cmd_time: 0, - cmd_string: op.cmd_string - }); - - opIndex = timingData.length - 1; - opsTimingDataIndexHash_[op.cmd_string] = opIndex; - } - - timingData[opIndex].cmd_time += op.cmd_time; - - } - - timingData.sort(this.sortTimingBucketsByOpTimeDescending_); - - this.collapseTimingBucketsToOther_(4); - }, - - collapseTimingBucketsToOther_: function(count) { - - var timingData = this.opsTimingData_; - var otherSource = timingData.splice(count, timingData.length - count); - var otherDestination = null; - - if (!otherSource.length) - return; - - timingData.push({ - cmd_time: 0, - cmd_string: 'Other' - }); - - otherDestination = timingData[timingData.length - 1]; - for (var i = 0; i < otherSource.length; i++) { - otherDestination.cmd_time += otherSource[i].cmd_time; - } - }, - - sortTimingBucketsByOpTimeDescending_: function(a, b) { - return b.cmd_time - a.cmd_time; - }, - - resetOpsTimingData_: function() { - this.opsTimingData_.length = 0; - } - }; - - return { - PictureOpsChartSummaryView: PictureOpsChartSummaryView - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/picture_ops_chart_view.css b/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/picture_ops_chart_view.css deleted file mode 100644 index 5f1943e5c79..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/picture_ops_chart_view.css +++ /dev/null @@ -1,18 +0,0 @@ -/* Copyright (c) 2013 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -* /deep/ tr-ui-e-chrome-cc-picture-ops-chart-view { - display: block; - height: 180px; - margin: 0; - padding: 0; - position: relative; -} - -* /deep/ tr-ui-e-chrome-cc-picture-ops-chart-view > .use-percentile-scale { - left: 0; - position: absolute; - top: 0; -} diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/picture_ops_chart_view.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/picture_ops_chart_view.html deleted file mode 100644 index a62f128e6b9..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/picture_ops_chart_view.html +++ /dev/null @@ -1,500 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="stylesheet" href="/tracing/ui/extras/chrome/cc/picture_ops_chart_view.css"> - -<link rel="import" href="/tracing/ui/base/dom_helpers.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.e.chrome.cc', function() { - var BAR_PADDING = 1; - var BAR_WIDTH = 5; - var CHART_PADDING_LEFT = 65; - var CHART_PADDING_RIGHT = 30; - var CHART_PADDING_BOTTOM = 35; - var CHART_PADDING_TOP = 20; - var AXIS_PADDING_LEFT = 55; - var AXIS_PADDING_RIGHT = 30; - var AXIS_PADDING_BOTTOM = 35; - var AXIS_PADDING_TOP = 20; - var AXIS_TICK_SIZE = 5; - var AXIS_LABEL_PADDING = 5; - var VERTICAL_TICKS = 5; - var HUE_CHAR_CODE_ADJUSTMENT = 5.7; - - /** - * Provides a chart showing the cumulative time spent in Skia operations - * during picture rasterization. - * - * @constructor - */ - var PictureOpsChartView = - tr.ui.b.define('tr-ui-e-chrome-cc-picture-ops-chart-view'); - - PictureOpsChartView.prototype = { - __proto__: HTMLUnknownElement.prototype, - - decorate: function() { - this.picture_ = undefined; - this.pictureOps_ = undefined; - this.opCosts_ = undefined; - - this.chartScale_ = window.devicePixelRatio; - - this.chart_ = document.createElement('canvas'); - this.chartCtx_ = this.chart_.getContext('2d'); - this.appendChild(this.chart_); - - this.selectedOpIndex_ = undefined; - this.chartWidth_ = 0; - this.chartHeight_ = 0; - this.dimensionsHaveChanged_ = true; - - this.currentBarMouseOverTarget_ = undefined; - - this.ninetyFifthPercentileCost_ = 0; - this.totalOpCost_ = 0; - - this.chart_.addEventListener('click', this.onClick_.bind(this)); - this.chart_.addEventListener('mousemove', this.onMouseMove_.bind(this)); - - this.usePercentileScale_ = false; - this.usePercentileScaleCheckbox_ = tr.ui.b.createCheckBox( - this, 'usePercentileScale', - 'PictureOpsChartView.usePercentileScale', false, - 'Limit to 95%-ile'); - this.usePercentileScaleCheckbox_.classList.add('use-percentile-scale'); - this.appendChild(this.usePercentileScaleCheckbox_); - }, - - get dimensionsHaveChanged() { - return this.dimensionsHaveChanged_; - }, - - set dimensionsHaveChanged(dimensionsHaveChanged) { - this.dimensionsHaveChanged_ = dimensionsHaveChanged; - }, - - get usePercentileScale() { - return this.usePercentileScale_; - }, - - set usePercentileScale(usePercentileScale) { - this.usePercentileScale_ = usePercentileScale; - this.drawChartContents_(); - }, - - get numOps() { - return this.opCosts_.length; - }, - - get selectedOpIndex() { - return this.selectedOpIndex_; - }, - - set selectedOpIndex(selectedOpIndex) { - if (selectedOpIndex < 0) throw new Error('Invalid index'); - if (selectedOpIndex >= this.numOps) throw new Error('Invalid index'); - - this.selectedOpIndex_ = selectedOpIndex; - }, - - get picture() { - return this.picture_; - }, - - set picture(picture) { - this.picture_ = picture; - this.pictureOps_ = picture.tagOpsWithTimings(picture.getOps()); - this.currentBarMouseOverTarget_ = undefined; - this.processPictureData_(); - this.dimensionsHaveChanged = true; - }, - - processPictureData_: function() { - if (this.pictureOps_ === undefined) - return; - - var totalOpCost = 0; - - // Take a copy of the picture ops data for sorting. - this.opCosts_ = this.pictureOps_.map(function(op) { - totalOpCost += op.cmd_time; - return op.cmd_time; - }); - this.opCosts_.sort(); - - var ninetyFifthPercentileCostIndex = Math.floor( - this.opCosts_.length * 0.95); - this.ninetyFifthPercentileCost_ = - this.opCosts_[ninetyFifthPercentileCostIndex]; - this.maxCost_ = this.opCosts_[this.opCosts_.length - 1]; - - this.totalOpCost_ = totalOpCost; - }, - - extractBarIndex_: function(e) { - - var index = undefined; - - if (this.pictureOps_ === undefined || - this.pictureOps_.length === 0) - return index; - - var x = e.offsetX; - var y = e.offsetY; - - var totalBarWidth = (BAR_WIDTH + BAR_PADDING) * this.pictureOps_.length; - - var chartLeft = CHART_PADDING_LEFT; - var chartTop = 0; - var chartBottom = this.chartHeight_ - CHART_PADDING_BOTTOM; - var chartRight = chartLeft + totalBarWidth; - - if (x < chartLeft || x > chartRight || y < chartTop || y > chartBottom) - return index; - - index = Math.floor((x - chartLeft) / totalBarWidth * - this.pictureOps_.length); - - index = tr.b.clamp(index, 0, this.pictureOps_.length - 1); - - return index; - }, - - onClick_: function(e) { - - var barClicked = this.extractBarIndex_(e); - - if (barClicked === undefined) - return; - - // If we click on the already selected item we should deselect. - if (barClicked === this.selectedOpIndex) - this.selectedOpIndex = undefined; - else - this.selectedOpIndex = barClicked; - - e.preventDefault(); - - tr.b.dispatchSimpleEvent(this, 'selection-changed', false); - }, - - onMouseMove_: function(e) { - - var lastBarMouseOverTarget = this.currentBarMouseOverTarget_; - this.currentBarMouseOverTarget_ = this.extractBarIndex_(e); - - if (this.currentBarMouseOverTarget_ === lastBarMouseOverTarget) - return; - - this.drawChartContents_(); - }, - - scrollSelectedItemIntoViewIfNecessary: function() { - - if (this.selectedOpIndex === undefined) - return; - - var width = this.offsetWidth; - var left = this.scrollLeft; - var right = left + width; - var targetLeft = CHART_PADDING_LEFT + - (BAR_WIDTH + BAR_PADDING) * this.selectedOpIndex; - - if (targetLeft > left && targetLeft < right) - return; - - this.scrollLeft = (targetLeft - width * 0.5); - }, - - updateChartContents: function() { - - if (this.dimensionsHaveChanged) - this.updateChartDimensions_(); - - this.drawChartContents_(); - }, - - updateChartDimensions_: function() { - - if (!this.pictureOps_) - return; - - var width = CHART_PADDING_LEFT + CHART_PADDING_RIGHT + - ((BAR_WIDTH + BAR_PADDING) * this.pictureOps_.length); - - if (width < this.offsetWidth) - width = this.offsetWidth; - - // Allow the element to be its natural size as set by flexbox, then lock - // the width in before we set the width of the canvas. - this.chartWidth_ = width; - this.chartHeight_ = this.getBoundingClientRect().height; - - // Scale up the canvas according to the devicePixelRatio, then reduce it - // down again via CSS. Finally we apply a scale to the canvas so that - // things are drawn at the correct size. - this.chart_.width = this.chartWidth_ * this.chartScale_; - this.chart_.height = this.chartHeight_ * this.chartScale_; - - this.chart_.style.width = this.chartWidth_ + 'px'; - this.chart_.style.height = this.chartHeight_ + 'px'; - - this.chartCtx_.scale(this.chartScale_, this.chartScale_); - - this.dimensionsHaveChanged = false; - }, - - drawChartContents_: function() { - - this.clearChartContents_(); - - if (this.pictureOps_ === undefined || - this.pictureOps_.length === 0 || - this.pictureOps_[0].cmd_time === undefined) { - - this.showNoTimingDataMessage_(); - return; - } - - this.drawSelection_(); - this.drawBars_(); - this.drawChartAxes_(); - this.drawLinesAtTickMarks_(); - this.drawLineAtBottomOfChart_(); - - if (this.currentBarMouseOverTarget_ === undefined) - return; - - this.drawTooltip_(); - }, - - drawSelection_: function() { - - if (this.selectedOpIndex === undefined) - return; - - var width = (BAR_WIDTH + BAR_PADDING) * this.selectedOpIndex; - this.chartCtx_.fillStyle = 'rgb(223, 235, 230)'; - this.chartCtx_.fillRect(CHART_PADDING_LEFT, CHART_PADDING_TOP, - width, this.chartHeight_ - CHART_PADDING_TOP - CHART_PADDING_BOTTOM); - }, - - drawChartAxes_: function() { - - var min = this.opCosts_[0]; - var max = this.opCosts_[this.opCosts_.length - 1]; - var height = this.chartHeight_ - AXIS_PADDING_TOP - AXIS_PADDING_BOTTOM; - - var tickYInterval = height / (VERTICAL_TICKS - 1); - var tickYPosition = 0; - var tickValInterval = (max - min) / (VERTICAL_TICKS - 1); - var tickVal = 0; - - this.chartCtx_.fillStyle = '#333'; - this.chartCtx_.strokeStyle = '#777'; - this.chartCtx_.save(); - - // Translate half a pixel to avoid blurry lines. - this.chartCtx_.translate(0.5, 0.5); - - // Sides. - this.chartCtx_.beginPath(); - this.chartCtx_.moveTo(AXIS_PADDING_LEFT, AXIS_PADDING_TOP); - this.chartCtx_.lineTo(AXIS_PADDING_LEFT, this.chartHeight_ - - AXIS_PADDING_BOTTOM); - this.chartCtx_.lineTo(this.chartWidth_ - AXIS_PADDING_RIGHT, - this.chartHeight_ - AXIS_PADDING_BOTTOM); - this.chartCtx_.stroke(); - this.chartCtx_.closePath(); - - // Y-axis ticks. - this.chartCtx_.translate(AXIS_PADDING_LEFT, AXIS_PADDING_TOP); - - this.chartCtx_.font = '10px Arial'; - this.chartCtx_.textAlign = 'right'; - this.chartCtx_.textBaseline = 'middle'; - - this.chartCtx_.beginPath(); - for (var t = 0; t < VERTICAL_TICKS; t++) { - - tickYPosition = Math.round(t * tickYInterval); - tickVal = (max - t * tickValInterval).toFixed(4); - - this.chartCtx_.moveTo(0, tickYPosition); - this.chartCtx_.lineTo(-AXIS_TICK_SIZE, tickYPosition); - this.chartCtx_.fillText(tickVal, - -AXIS_TICK_SIZE - AXIS_LABEL_PADDING, tickYPosition); - - } - - this.chartCtx_.stroke(); - this.chartCtx_.closePath(); - - this.chartCtx_.restore(); - }, - - drawLinesAtTickMarks_: function() { - - var height = this.chartHeight_ - AXIS_PADDING_TOP - AXIS_PADDING_BOTTOM; - var width = this.chartWidth_ - AXIS_PADDING_LEFT - AXIS_PADDING_RIGHT; - var tickYInterval = height / (VERTICAL_TICKS - 1); - var tickYPosition = 0; - - this.chartCtx_.save(); - - this.chartCtx_.translate(AXIS_PADDING_LEFT + 0.5, AXIS_PADDING_TOP + 0.5); - this.chartCtx_.beginPath(); - this.chartCtx_.strokeStyle = 'rgba(0,0,0,0.05)'; - - for (var t = 0; t < VERTICAL_TICKS; t++) { - tickYPosition = Math.round(t * tickYInterval); - - this.chartCtx_.moveTo(0, tickYPosition); - this.chartCtx_.lineTo(width, tickYPosition); - this.chartCtx_.stroke(); - } - - this.chartCtx_.restore(); - this.chartCtx_.closePath(); - }, - - drawLineAtBottomOfChart_: function() { - this.chartCtx_.strokeStyle = '#AAA'; - this.chartCtx_.beginPath(); - this.chartCtx_.moveTo(0, this.chartHeight_ - 0.5); - this.chartCtx_.lineTo(this.chartWidth_, this.chartHeight_ - 0.5); - this.chartCtx_.stroke(); - this.chartCtx_.closePath(); - }, - - drawTooltip_: function() { - - var tooltipData = this.pictureOps_[this.currentBarMouseOverTarget_]; - var tooltipTitle = tooltipData.cmd_string; - var tooltipTime = tooltipData.cmd_time.toFixed(4); - var toolTipTimePercentage = - ((tooltipData.cmd_time / this.totalOpCost_) * 100).toFixed(2); - - var tooltipWidth = 120; - var tooltipHeight = 40; - var chartInnerWidth = this.chartWidth_ - CHART_PADDING_RIGHT - - CHART_PADDING_LEFT; - var barWidth = BAR_WIDTH + BAR_PADDING; - var tooltipOffset = Math.round((tooltipWidth - barWidth) * 0.5); - - var left = CHART_PADDING_LEFT + this.currentBarMouseOverTarget_ * - barWidth - tooltipOffset; - var top = Math.round((this.chartHeight_ - tooltipHeight) * 0.5); - - this.chartCtx_.save(); - - this.chartCtx_.shadowOffsetX = 0; - this.chartCtx_.shadowOffsetY = 5; - this.chartCtx_.shadowBlur = 4; - this.chartCtx_.shadowColor = 'rgba(0,0,0,0.4)'; - - this.chartCtx_.strokeStyle = '#888'; - this.chartCtx_.fillStyle = '#EEE'; - this.chartCtx_.fillRect(left, top, tooltipWidth, tooltipHeight); - - this.chartCtx_.shadowColor = 'transparent'; - this.chartCtx_.translate(0.5, 0.5); - this.chartCtx_.strokeRect(left, top, tooltipWidth, tooltipHeight); - - this.chartCtx_.restore(); - - this.chartCtx_.fillStyle = '#222'; - this.chartCtx_.textAlign = 'left'; - this.chartCtx_.textBaseline = 'top'; - this.chartCtx_.font = '800 12px Arial'; - this.chartCtx_.fillText(tooltipTitle, left + 8, top + 8); - - this.chartCtx_.fillStyle = '#555'; - this.chartCtx_.font = '400 italic 10px Arial'; - this.chartCtx_.fillText(tooltipTime + 'ms (' + - toolTipTimePercentage + '%)', left + 8, top + 22); - }, - - drawBars_: function() { - - var op; - var opColor = 0; - var opHeight = 0; - var opWidth = BAR_WIDTH + BAR_PADDING; - var opHover = false; - - var bottom = this.chartHeight_ - CHART_PADDING_BOTTOM; - var maxHeight = this.chartHeight_ - CHART_PADDING_BOTTOM - - CHART_PADDING_TOP; - - var maxValue; - if (this.usePercentileScale) - maxValue = this.ninetyFifthPercentileCost_; - else - maxValue = this.maxCost_; - - for (var b = 0; b < this.pictureOps_.length; b++) { - - op = this.pictureOps_[b]; - opHeight = Math.round( - (op.cmd_time / maxValue) * maxHeight); - opHeight = Math.max(opHeight, 1); - opHover = (b === this.currentBarMouseOverTarget_); - opColor = this.getOpColor_(op.cmd_string, opHover); - - if (b === this.selectedOpIndex) - this.chartCtx_.fillStyle = '#FFFF00'; - else - this.chartCtx_.fillStyle = opColor; - - this.chartCtx_.fillRect(CHART_PADDING_LEFT + b * opWidth, - bottom - opHeight, BAR_WIDTH, opHeight); - } - - }, - - getOpColor_: function(opName, hover) { - - var characters = opName.split(''); - - var hue = characters.reduce(this.reduceNameToHue, 0) % 360; - var saturation = 30; - var lightness = hover ? '75%' : '50%'; - - return 'hsl(' + hue + ', ' + saturation + '%, ' + lightness + '%)'; - }, - - reduceNameToHue: function(previousValue, currentValue, index, array) { - // Get the char code and apply a magic adjustment value so we get - // pretty colors from around the rainbow. - return Math.round(previousValue + currentValue.charCodeAt(0) * - HUE_CHAR_CODE_ADJUSTMENT); - }, - - clearChartContents_: function() { - this.chartCtx_.clearRect(0, 0, this.chartWidth_, this.chartHeight_); - }, - - showNoTimingDataMessage_: function() { - this.chartCtx_.font = '800 italic 14px Arial'; - this.chartCtx_.fillStyle = '#333'; - this.chartCtx_.textAlign = 'center'; - this.chartCtx_.textBaseline = 'middle'; - this.chartCtx_.fillText('No timing data available.', - this.chartWidth_ * 0.5, this.chartHeight_ * 0.5); - } - }; - - return { - PictureOpsChartView: PictureOpsChartView - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/picture_ops_list_view.css b/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/picture_ops_list_view.css deleted file mode 100644 index bdd77fcd099..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/picture_ops_list_view.css +++ /dev/null @@ -1,62 +0,0 @@ -/* Copyright (c) 2013 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -* * /deep/ tr-ui-e-chrome-cc-picture-ops-list-view { - -webkit-flex-direction: column; - border-top: 1px solid grey; - display: -webkit-flex; -} - -* /deep/ tr-ui-e-chrome-cc-picture-ops-list-view > .x-list-view { - -webkit-flex: 1 1 auto; - overflow: auto; -} - -* /deep/ tr-ui-e-chrome-cc-picture-ops-list-view > .x-list-view .list-item { - border-bottom: 1px solid #555; - font-size: small; - font-weight: bold; - padding-bottom: 5px; - padding-left: 5px; -} - -* /deep/ tr-ui-e-chrome-cc-picture-ops-list-view > - .x-list-view .list-item:hover { - background-color: #f0f0f0; - cursor: pointer; -} - -* /deep/ tr-ui-e-chrome-cc-picture-ops-list-view > - .x-list-view .list-item > * { - color: #777; - font-size: x-small; - font-weight: normal; - margin-left: 1em; - max-width: 300px; /* force long strings to wrap */ -} - -* /deep/ tr-ui-e-chrome-cc-picture-ops-list-view > - .x-list-view .list-item > .elementInfo { - color: purple; - font-size: small; - font-weight: bold; -} - -* /deep/ tr-ui-e-chrome-cc-picture-ops-list-view > - .x-list-view .list-item > .time { - color: rgb(136, 0, 0); -} - -* /deep/ tr-ui-e-chrome-cc-picture-ops-list-view .x-list-view:focus > - .list-item[beforeSelection] { - background-color: rgb(171, 217, 202); - outline: 1px dotted rgba(0, 0, 0, 0.1); - outline-offset: 0; -} - -* /deep/ tr-ui-e-chrome-cc-picture-ops-list-view .x-list-view > - .list-item[beforeSelection] { - background-color: rgb(103, 199, 165); -} diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/picture_ops_list_view.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/picture_ops_list_view.html deleted file mode 100644 index 1bae14a635f..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/picture_ops_list_view.html +++ /dev/null @@ -1,238 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="stylesheet" href="/tracing/ui/extras/chrome/cc/picture_ops_list_view.css"> - -<link rel="import" href="/tracing/extras/chrome/cc/constants.html"> -<link rel="import" href="/tracing/ui/base/list_view.html"> -<link rel="import" href="/tracing/ui/base/dom_helpers.html"> -<link rel="import" href="/tracing/ui/base/utils.html"> -<link rel="import" href="/tracing/ui/extras/chrome/cc/selection.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.e.chrome.cc', function() { - var OPS_TIMING_ITERATIONS = 3; // Iterations to average op timing info over. - var ANNOTATION = 'Comment'; - var BEGIN_ANNOTATION = 'BeginCommentGroup'; - var END_ANNOTATION = 'EndCommentGroup'; - var ANNOTATION_ID = 'ID: '; - var ANNOTATION_CLASS = 'CLASS: '; - var ANNOTATION_TAG = 'TAG: '; - - var constants = tr.e.cc.constants; - - /** - * @constructor - */ - var PictureOpsListView = - tr.ui.b.define('tr-ui-e-chrome-cc-picture-ops-list-view'); - - PictureOpsListView.prototype = { - __proto__: HTMLUnknownElement.prototype, - - decorate: function() { - this.opsList_ = new tr.ui.b.ListView(); - this.appendChild(this.opsList_); - - this.selectedOp_ = undefined; - this.selectedOpIndex_ = undefined; - this.opsList_.addEventListener( - 'selection-changed', this.onSelectionChanged_.bind(this)); - - this.picture_ = undefined; - }, - - get picture() { - return this.picture_; - }, - - set picture(picture) { - this.picture_ = picture; - this.updateContents_(); - }, - - updateContents_: function() { - this.opsList_.clear(); - - if (!this.picture_) - return; - - var ops = this.picture_.getOps(); - if (!ops) - return; - - ops = this.picture_.tagOpsWithTimings(ops); - - ops = this.opsTaggedWithAnnotations_(ops); - - for (var i = 0; i < ops.length; i++) { - var op = ops[i]; - var item = document.createElement('div'); - item.opIndex = op.opIndex; - item.textContent = i + ') ' + op.cmd_string; - - // Display the element info associated with the op, if available. - if (op.elementInfo.tag || op.elementInfo.id || op.elementInfo.class) { - var elementInfo = document.createElement('span'); - elementInfo.classList.add('elementInfo'); - var tag = op.elementInfo.tag ? op.elementInfo.tag : 'unknown'; - var id = op.elementInfo.id ? 'id=' + op.elementInfo.id : undefined; - var className = op.elementInfo.class ? 'class=' + - op.elementInfo.class : undefined; - elementInfo.textContent = - '<' + tag + (id ? ' ' : '') + - (id ? id : '') + (className ? ' ' : '') + - (className ? className : '') + '>'; - item.appendChild(elementInfo); - } - - // Display the Skia params. - // FIXME: now that we have structured data, we should format it. - // (https://github.com/google/trace-viewer/issues/782) - if (op.info.length > 0) { - var infoItem = document.createElement('div'); - infoItem.textContent = JSON.stringify(op.info); - item.appendChild(infoItem); - } - - // Display the op timing, if available. - if (op.cmd_time && op.cmd_time >= 0.0001) { - var time = document.createElement('span'); - time.classList.add('time'); - var rounded = op.cmd_time.toFixed(4); - time.textContent = '(' + rounded + 'ms)'; - item.appendChild(time); - } - - this.opsList_.appendChild(item); - } - }, - - onSelectionChanged_: function(e) { - var beforeSelectedOp = true; - - // Deselect on re-selection. - if (this.opsList_.selectedElement === this.selectedOp_) { - this.opsList_.selectedElement = undefined; - beforeSelectedOp = false; - this.selectedOpIndex_ = undefined; - } - - this.selectedOp_ = this.opsList_.selectedElement; - - // Set selection on all previous ops. - var ops = this.opsList_.children; - for (var i = 0; i < ops.length; i++) { - var op = ops[i]; - if (op === this.selectedOp_) { - beforeSelectedOp = false; - this.selectedOpIndex_ = op.opIndex; - } else if (beforeSelectedOp) { - op.setAttribute('beforeSelection', 'beforeSelection'); - } else { - op.removeAttribute('beforeSelection'); - } - } - - tr.b.dispatchSimpleEvent(this, 'selection-changed', false); - }, - - get numOps() { - return this.opsList_.children.length; - }, - - get selectedOpIndex() { - return this.selectedOpIndex_; - }, - - set selectedOpIndex(s) { - this.selectedOpIndex_ = s; - - if (s === undefined) { - this.opsList_.selectedElement = this.selectedOp_; - this.onSelectionChanged_(); - } else { - if (s < 0) throw new Error('Invalid index'); - if (s >= this.numOps) throw new Error('Invalid index'); - this.opsList_.selectedElement = this.opsList_.getElementByIndex(s + 1); - tr.ui.b.scrollIntoViewIfNeeded(this.opsList_.selectedElement); - } - }, - - /** - * Return Skia operations tagged by annotation. - * - * The ops returned from Picture.getOps() contain both Skia ops and - * annotations threaded together. This function removes all annotations - * from the list and tags each op with the associated annotations. - * Additionally, the last {tag, id, class} is stored as elementInfo on - * each op. - * - * @param {Array} ops Array of Skia operations and annotations. - * @return {Array} Skia ops where op.annotations contains the associated - * annotations for a given op. - */ - opsTaggedWithAnnotations_: function(ops) { - // This algorithm works by walking all the ops and pushing any - // annotations onto a stack. When a non-annotation op is found, the - // annotations stack is traversed and stored with the op. - var annotationGroups = new Array(); - var opsWithoutAnnotations = new Array(); - for (var opIndex = 0; opIndex < ops.length; opIndex++) { - var op = ops[opIndex]; - op.opIndex = opIndex; - switch (op.cmd_string) { - case BEGIN_ANNOTATION: - annotationGroups.push(new Array()); - break; - case END_ANNOTATION: - annotationGroups.pop(); - break; - case ANNOTATION: - annotationGroups[annotationGroups.length - 1].push(op); - break; - default: - var annotations = new Array(); - var elementInfo = {}; - annotationGroups.forEach(function(annotationGroup) { - elementInfo = {}; - annotationGroup.forEach(function(annotation) { - annotation.info.forEach(function(info) { - if (info.indexOf(ANNOTATION_TAG) != -1) - elementInfo.tag = info.substring( - info.indexOf(ANNOTATION_TAG) + - ANNOTATION_TAG.length).toLowerCase(); - else if (info.indexOf(ANNOTATION_ID) != -1) - elementInfo.id = info.substring( - info.indexOf(ANNOTATION_ID) + - ANNOTATION_ID.length); - else if (info.indexOf(ANNOTATION_CLASS) != -1) - elementInfo.class = info.substring( - info.indexOf(ANNOTATION_CLASS) + - ANNOTATION_CLASS.length); - - annotations.push(info); - }); - }); - }); - op.annotations = annotations; - op.elementInfo = elementInfo; - opsWithoutAnnotations.push(op); - } - } - - return opsWithoutAnnotations; - } - }; - - return { - PictureOpsListView: PictureOpsListView - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/picture_ops_list_view_test.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/picture_ops_list_view_test.html deleted file mode 100644 index cd6679f8449..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/picture_ops_list_view_test.html +++ /dev/null @@ -1,57 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/extras/chrome/cc/picture.html"> -<link rel="import" href="/tracing/extras/importer/trace_event_importer.html"> -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/ui/extras/chrome/cc/picture_ops_list_view.html"> - -<script src="/tracing/extras/chrome/cc/layer_tree_host_impl_test_data.js"> -</script> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var PictureOpsListView = tr.ui.e.chrome.cc.PictureOpsListView; - - test('instantiate', function() { - if (!tr.e.cc.PictureSnapshot.CanRasterize()) - return; - var m = new tr.Model(g_catLTHIEvents); - var p = tr.b.dictionaryValues(m.processes)[0]; - - var instance = p.objects.getAllInstancesNamed('cc::Picture')[0]; - var snapshot = instance.snapshots[0]; - - var view = new PictureOpsListView(); - view.picture = snapshot; - assert.equal(view.opsList_.children.length, 142); - }); - - test('selection', function() { - if (!tr.e.cc.PictureSnapshot.CanRasterize()) - return; - var m = new tr.Model(g_catLTHIEvents); - var p = tr.b.dictionaryValues(m.processes)[0]; - - var instance = p.objects.getAllInstancesNamed('cc::Picture')[0]; - var snapshot = instance.snapshots[0]; - - var view = new PictureOpsListView(); - view.picture = snapshot; - var didSelectionChange = 0; - view.addEventListener('selection-changed', function() { - didSelectionChange = true; - }); - assert.isFalse(didSelectionChange); - view.opsList_.selectedElement = view.opsList_.children[3]; - assert.isTrue(didSelectionChange); - }); - -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/picture_view.css b/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/picture_view.css deleted file mode 100644 index 26893f2c6c9..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/picture_view.css +++ /dev/null @@ -1,9 +0,0 @@ -/* Copyright (c) 2013 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -* /deep/ .tr-ui-e-chrome-cc-picture-snapshot-view { - -webkit-flex: 0 1 auto !important; - display: -webkit-flex; -} diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/picture_view.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/picture_view.html deleted file mode 100644 index 74acef3e37b..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/picture_view.html +++ /dev/null @@ -1,53 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="stylesheet" href="/tracing/ui/extras/chrome/cc/picture_view.css"> - -<link rel="import" href="/tracing/extras/chrome/cc/picture.html"> -<link rel="import" href="/tracing/ui/analysis/generic_object_view.html"> -<link rel="import" href="/tracing/ui/analysis/object_snapshot_view.html"> -<link rel="import" href="/tracing/ui/extras/chrome/cc/picture_debugger.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.e.chrome.cc', function() { - /* - * Displays a picture snapshot in a human readable form. - * @constructor - */ - var PictureSnapshotView = tr.ui.b.define( - 'tr-ui-e-chrome-cc-picture-snapshot-view', - tr.ui.analysis.ObjectSnapshotView); - - PictureSnapshotView.prototype = { - __proto__: tr.ui.analysis.ObjectSnapshotView.prototype, - - decorate: function() { - this.classList.add('tr-ui-e-chrome-cc-picture-snapshot-view'); - this.pictureDebugger_ = new tr.ui.e.chrome.cc.PictureDebugger(); - this.appendChild(this.pictureDebugger_); - }, - - updateContents: function() { - if (this.objectSnapshot_ && this.pictureDebugger_) - this.pictureDebugger_.picture = this.objectSnapshot_; - } - }; - - tr.ui.analysis.ObjectSnapshotView.register( - PictureSnapshotView, - { - typeNames: ['cc::Picture', 'cc::LayeredPicture'], - showInstances: false - }); - - return { - PictureSnapshotView: PictureSnapshotView - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/raster_task_selection.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/raster_task_selection.html deleted file mode 100644 index 2838c5b63ed..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/raster_task_selection.html +++ /dev/null @@ -1,131 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/base.html"> -<link rel="import" href="/tracing/extras/chrome/cc/raster_task.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/ui/analysis/single_event_sub_view.html"> -<link rel="import" href="/tracing/ui/extras/chrome/cc/raster_task_view.html"> -<link rel="import" href="/tracing/ui/extras/chrome/cc/selection.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.e.chrome.cc', function() { - /** - * @constructor - */ - function RasterTaskSelection(selection) { - tr.ui.e.chrome.cc.Selection.call(this); - var whySupported = RasterTaskSelection.whySuported(selection); - if (!whySupported.ok) - throw new Error('Fail: ' + whySupported.why); - this.slices_ = tr.b.asArray(selection); - this.tiles_ = this.slices_.map(function(slice) { - var tile = tr.e.cc.getTileFromRasterTaskSlice(slice); - if (tile === undefined) - throw new Error('This should never happen due to .supports check.'); - return tile; - }); - } - - RasterTaskSelection.whySuported = function(selection) { - if (!(selection instanceof tr.model.EventSet)) - return {ok: false, why: 'Must be selection'}; - - if (selection.length === 0) - return {ok: false, why: 'Selection must be non empty'}; - - var referenceSnapshot = undefined; - for (var event of selection) { - if (!(event instanceof tr.model.Slice)) - return {ok: false, why: 'Not a slice'}; - - var tile = tr.e.cc.getTileFromRasterTaskSlice(event); - if (tile === undefined) - return {ok: false, why: 'No tile found'}; - - if (!referenceSnapshot) { - referenceSnapshot = tile.containingSnapshot; - } else { - if (tile.containingSnapshot != referenceSnapshot) { - return { - ok: false, - why: 'Raster tasks are from different compositor instances' - }; - } - } - } - return {ok: true}; - }; - - RasterTaskSelection.supports = function(selection) { - return RasterTaskSelection.whySuported(selection).ok; - }; - - RasterTaskSelection.prototype = { - __proto__: tr.ui.e.chrome.cc.Selection.prototype, - - get specicifity() { - return 3; - }, - - get associatedLayerId() { - var tile0 = this.tiles_[0]; - var allSameLayer = this.tiles_.every(function(tile) { - tile.layerId == tile0.layerId; - }); - if (allSameLayer) - return tile0.layerId; - return undefined; - }, - - get extraHighlightsByLayerId() { - var highlights = {}; - this.tiles_.forEach(function(tile, i) { - if (highlights[tile.layerId] === undefined) - highlights[tile.layerId] = []; - var slice = this.slices_[i]; - highlights[tile.layerId].push({ - colorKey: slice.title, - rect: tile.layerRect - }); - }, this); - return highlights; - }, - - createAnalysis: function() { - var sel = new tr.model.EventSet(); - this.slices_.forEach(function(slice) { - sel.push(slice); - }); - - var analysis; - if (sel.length == 1) - analysis = document.createElement('tr-ui-a-single-event-sub-view'); - else - analysis = document.createElement('tr-ui-e-chrome-cc-raster-task-view'); - analysis.selection = sel; - return analysis; - }, - - findEquivalent: function(lthi) { - // Raster tasks are only valid in one LTHI. - return undefined; - }, - - // RasterTaskSelection specific stuff follows. - get containingSnapshot() { - return this.tiles_[0].containingSnapshot; - } - }; - - return { - RasterTaskSelection: RasterTaskSelection - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/raster_task_selection_test.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/raster_task_selection_test.html deleted file mode 100644 index ee8e91c3c77..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/raster_task_selection_test.html +++ /dev/null @@ -1,39 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/utils.html"> -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/extras/importer/trace_event_importer.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/ui/extras/chrome/cc/raster_task_selection.html"> - -<script src="/tracing/extras/chrome/cc/layer_tree_host_impl_test_data.js"> -</script> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - test('basic', function() { - var m = tr.c.TestUtils.newModelWithEvents([g_catLTHIEvents]); - var p = m.processes[1]; - var rasterTasks = p.threads[1].sliceGroup.slices.filter(function(slice) { - return slice.title == 'RasterTask'; - }); - - var selection = new tr.model.EventSet(); - selection.push(rasterTasks[0]); - selection.push(rasterTasks[1]); - - assert.isTrue(tr.ui.e.chrome.cc.RasterTaskSelection.supports(selection)); - var selection = new tr.ui.e.chrome.cc.RasterTaskSelection(selection); - var highlights = selection.extraHighlightsByLayerId; - assert.equal(tr.b.dictionaryLength(highlights), 1); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/raster_task_view.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/raster_task_view.html deleted file mode 100644 index b4020840303..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/raster_task_view.html +++ /dev/null @@ -1,216 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> -<link rel="import" href="/tracing/extras/chrome/cc/raster_task.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/ui/analysis/analysis_sub_view.html"> -<link rel="import" href="/tracing/ui/base/table.html"> -<link rel="import" href="/tracing/ui/extras/chrome/cc/selection.html"> -<link rel="import" href="/tracing/value/ui/scalar_span.html"> -<link rel="import" href="/tracing/value/unit.html"> - -<polymer-element name="tr-ui-e-chrome-cc-raster-task-view"> - <template> - <style> - :host { - display: flex; - flex-direction: column; - } - #heading { - flex: 0 0 auto; - } - </style> - - <div id="heading"> - Rasterization costs in - <tr-ui-a-analysis-link id="link"></tr-ui-a-analysis-link> - </div> - <tr-ui-b-table id="content"></tr-ui-b-table> - </template> - - <script> - 'use strict'; - Polymer({ - created: function() { - this.selection_ = undefined; - }, - - set selection(selection) { - this.selection_ = selection; - - this.updateContents_(); - }, - - updateColumns_: function(hadCpuDurations) { - var timeSpanConfig = { - unit: tr.v.Unit.byName.timeDurationInMs, - ownerDocument: this.ownerDocument - }; - - var columns = [ - { - title: 'Layer', - value: function(row) { - if (row.isTotals) - return 'Totals'; - if (row.layer) { - var linkEl = document.createElement('tr-ui-a-analysis-link'); - linkEl.setSelectionAndContent( - function() { - return new tr.ui.e.chrome.cc.LayerSelection(costs.layer); - }, - 'Layer ' + row.layerId); - return linkEl; - } else { - return 'Layer ' + row.layerId; - } - }, - width: '250px' - }, - { - title: 'Num Tiles', - value: function(row) { return row.numTiles; }, - cmp: function(a, b) { return a.numTiles - b.numTiles; } - }, - { - title: 'Num Analysis Tasks', - value: function(row) { return row.numAnalysisTasks; }, - cmp: function(a, b) { - return a.numAnalysisTasks - b.numAnalysisTasks; - } - }, - { - title: 'Num Raster Tasks', - value: function(row) { return row.numRasterTasks; }, - cmp: function(a, b) { return a.numRasterTasks - b.numRasterTasks; } - }, - { - title: 'Wall Duration (ms)', - value: function(row) { - return tr.v.ui.createScalarSpan(row.duration, timeSpanConfig); - }, - cmp: function(a, b) { return a.duration - b.duration; } - } - ]; - - if (hadCpuDurations) { - columns.push({ - title: 'CPU Duration (ms)', - value: function(row) { - return tr.v.ui.createScalarSpan(row.cpuDuration, timeSpanConfig); - }, - cmp: function(a, b) { return a.cpuDuration - b.cpuDuration; } - }); - } - - var colWidthPercentage; - if (columns.length == 1) - colWidthPercentage = '100%'; - else - colWidthPercentage = (100 / (columns.length - 1)).toFixed(3) + '%'; - - for (var i = 1; i < columns.length; i++) - columns[i].width = colWidthPercentage; - - this.$.content.tableColumns = columns; - this.$.content.sortColumnIndex = columns.length - 1; - }, - - updateContents_: function() { - var table = this.$.content; - - if (this.selection_.length === 0) { - this.$.link.setSelectionAndContent(undefined, ''); - table.tableRows = []; - table.footerRows = []; - table.rebuild(); - return; - } - - // LTHI link. - var lthi = tr.e.cc.getTileFromRasterTaskSlice( - this.selection_[0]).containingSnapshot; - this.$.link.setSelectionAndContent(function() { - return new tr.model.EventSet(lthi); - }, lthi.userFriendlyName); - - // Get costs by layer. - var costsByLayerId = {}; - function getCurrentCostsForLayerId(tile) { - var layerId = tile.layerId; - var lthi = tile.containingSnapshot; - var layer; - if (lthi.activeTree) - layer = lthi.activeTree.findLayerWithId(layerId); - if (layer === undefined && lthi.pendingTree) - layer = lthi.pendingTree.findLayerWithId(layerId); - if (costsByLayerId[layerId] === undefined) { - costsByLayerId[layerId] = { - layerId: layerId, - layer: layer, - numTiles: 0, - numAnalysisTasks: 0, - numRasterTasks: 0, - duration: 0, - cpuDuration: 0 - }; - } - return costsByLayerId[layerId]; - } - - var totalDuration = 0; - var totalCpuDuration = 0; - var totalNumAnalyzeTasks = 0; - var totalNumRasterizeTasks = 0; - var hadCpuDurations = false; - - var tilesThatWeHaveSeen = {}; - - this.selection_.forEach(function(slice) { - var tile = tr.e.cc.getTileFromRasterTaskSlice(slice); - var curCosts = getCurrentCostsForLayerId(tile); - - if (!tilesThatWeHaveSeen[tile.objectInstance.id]) { - tilesThatWeHaveSeen[tile.objectInstance.id] = true; - curCosts.numTiles += 1; - } - - if (tr.e.cc.isSliceDoingAnalysis(slice)) { - curCosts.numAnalysisTasks += 1; - totalNumAnalyzeTasks += 1; - } else { - curCosts.numRasterTasks += 1; - totalNumRasterizeTasks += 1; - } - curCosts.duration += slice.duration; - totalDuration += slice.duration; - if (slice.cpuDuration !== undefined) { - curCosts.cpuDuration += slice.cpuDuration; - totalCpuDuration += slice.cpuDuration; - hadCpuDurations = true; - } - }); - - // Apply to the table. - this.updateColumns_(hadCpuDurations); - table.tableRows = tr.b.dictionaryValues(costsByLayerId); - table.rebuild(); - - // Footer. - table.footerRows = [ - { - isTotals: true, - numTiles: tr.b.dictionaryLength(tilesThatWeHaveSeen), - numAnalysisTasks: totalNumAnalyzeTasks, - numRasterTasks: totalNumRasterizeTasks, - duration: totalDuration, - cpuDuration: totalCpuDuration - } - ]; - } - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/raster_task_view_test.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/raster_task_view_test.html deleted file mode 100644 index be771775cb7..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/raster_task_view_test.html +++ /dev/null @@ -1,70 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/event_target.html"> -<link rel="import" href="/tracing/base/utils.html"> -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/extras/importer/trace_event_importer.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/ui/analysis/analysis_view.html"> -<link rel="import" href="/tracing/ui/base/deep_utils.html"> -<link rel="import" href="/tracing/ui/brushing_state_controller.html"> -<link rel="import" href="/tracing/ui/extras/chrome/cc/layer_tree_host_impl_view.html"> -<link rel="import" href="/tracing/ui/extras/chrome/cc/raster_task_selection.html"> -<link rel="import" href="/tracing/ui/extras/chrome/cc/raster_task_view.html"> - -<script src="/tracing/extras/chrome/cc/layer_tree_host_impl_test_data.js"> -</script> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - function createSelection() { - var m = tr.c.TestUtils.newModelWithEvents([g_catLTHIEvents]); - var p = m.processes[1]; - var rasterTasks = p.threads[1].sliceGroup.slices.filter(function(slice) { - return slice.title == 'RasterTask' || slice.title == 'AnalyzeTask'; - }); - - var selection = new tr.model.EventSet(); - selection.model = m; - - selection.push(rasterTasks[0]); - selection.push(rasterTasks[1]); - return selection; - } - - test('basic', function() { - var selection = createSelection(); - var view = document.createElement('tr-ui-e-chrome-cc-raster-task-view'); - view.selection = selection; - this.addHTMLOutput(view); - }); - - test('analysisViewIntegration', function() { - var selection = createSelection(); - - var timelineView = {model: selection.model}; - var brushingStateController = - new tr.c.BrushingStateController(timelineView); - - var analysisEl = document.createElement('tr-ui-a-analysis-view'); - analysisEl.brushingStateController = brushingStateController; - brushingStateController.changeSelectionFromTimeline(selection); - - assert.isDefined(analysisEl.querySelector( - 'tr-ui-e-chrome-cc-raster-task-view')); - - var sv = tr.b.findDeepElementMatching( - analysisEl, 'tr-ui-a-multi-thread-slice-sub-view'); - assert.isTrue(sv.requiresTallView); - this.addHTMLOutput(analysisEl); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/selection.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/selection.html deleted file mode 100644 index a2f1e2521f4..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/selection.html +++ /dev/null @@ -1,302 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/analysis/generic_object_view.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.e.chrome.cc', function() { - function Selection() { - this.selectionToSetIfClicked = undefined; - }; - Selection.prototype = { - /** - * When two things are picked in the UI, one must occasionally tie-break - * between them to decide what was really clicked. Things with higher - * specicifity will win. - */ - get specicifity() { - throw new Error('Not implemented'); - }, - - /** - * If a selection is related to a specific layer, then this returns the - * layerId of that layer. If the selection is not related to a layer, for - * example if the device viewport is selected, then this returns undefined. - */ - get associatedLayerId() { - throw new Error('Not implemented'); - }, - - /** - * If a selection is related to a specific render pass, then this returns - * the layerId of that layer. If the selection is not related to a layer, - * for example if the device viewport is selected, then this returns - * undefined. - */ - get associatedRenderPassId() { - throw new Error('Not implemented'); - }, - - - get highlightsByLayerId() { - return {}; - }, - - /** - * Called when the selection is made active in the layer view. Must return - * an HTMLElement that explains this selection in detail. - */ - createAnalysis: function() { - throw new Error('Not implemented'); - }, - - /** - * Should try to create the equivalent selection in the provided LTHI, - * or undefined if it can't be done. - */ - findEquivalent: function(lthi) { - throw new Error('Not implemented'); - } - }; - - /** - * @constructor - */ - function RenderPassSelection(renderPass, renderPassId) { - if (!renderPass || (renderPassId === undefined)) - throw new Error('Render pass (with id) is required'); - this.renderPass_ = renderPass; - this.renderPassId_ = renderPassId; - } - - RenderPassSelection.prototype = { - __proto__: Selection.prototype, - - get specicifity() { - return 1; - }, - - get associatedLayerId() { - return undefined; - }, - - get associatedRenderPassId() { - return this.renderPassId_; - }, - - get renderPass() { - return this.renderPass_; - }, - - createAnalysis: function() { - var dataView = document.createElement( - 'tr-ui-a-generic-object-view-with-label'); - dataView.label = 'RenderPass ' + this.renderPassId_; - dataView.object = this.renderPass_.args; - return dataView; - }, - - get title() { - return this.renderPass_.objectInstance.typeName; - } - }; - - /** - * @constructor - */ - function LayerSelection(layer) { - if (!layer) - throw new Error('Layer is required'); - this.layer_ = layer; - } - - LayerSelection.prototype = { - __proto__: Selection.prototype, - - get specicifity() { - return 1; - }, - - get associatedLayerId() { - return this.layer_.layerId; - }, - - get associatedRenderPassId() { - return undefined; - }, - - get layer() { - return this.layer_; - }, - - createAnalysis: function() { - var dataView = document.createElement( - 'tr-ui-a-generic-object-view-with-label'); - dataView.label = 'Layer ' + this.layer_.layerId; - if (this.layer_.usingGpuRasterization) - dataView.label += ' (GPU-rasterized)'; - dataView.object = this.layer_.args; - return dataView; - }, - - get title() { - return this.layer_.objectInstance.typeName; - }, - - findEquivalent: function(lthi) { - var layer = lthi.activeTree.findLayerWithId(this.layer_.layerId) || - lthi.pendingTree.findLayerWithId(this.layer_.layerId); - if (!layer) - return undefined; - return new LayerSelection(layer); - } - }; - - /** - * @constructor - */ - function TileSelection(tile, opt_data) { - this.tile_ = tile; - this.data_ = opt_data || {}; - } - - TileSelection.prototype = { - __proto__: Selection.prototype, - - get specicifity() { - return 2; - }, - - get associatedLayerId() { - return this.tile_.layerId; - }, - - get highlightsByLayerId() { - var highlights = {}; - highlights[this.tile_.layerId] = [ - { - colorKey: this.tile_.objectInstance.typeName, - rect: this.tile_.layerRect - } - ]; - return highlights; - }, - - createAnalysis: function() { - var analysis = document.createElement( - 'tr-ui-a-generic-object-view-with-label'); - analysis.label = 'Tile ' + this.tile_.objectInstance.id + ' on layer ' + - this.tile_.layerId; - if (this.data_) { - analysis.object = { - moreInfo: this.data_, - tileArgs: this.tile_.args - }; - } else { - analysis.object = this.tile_.args; - } - return analysis; - }, - - findEquivalent: function(lthi) { - var tileInstance = this.tile_.tileInstance; - if (lthi.ts < tileInstance.creationTs || - lthi.ts >= tileInstance.deletionTs) - return undefined; - var tileSnapshot = tileInstance.getSnapshotAt(lthi.ts); - if (!tileSnapshot) - return undefined; - return new TileSelection(tileSnapshot); - } - }; - - /** - * @constructor - */ - function LayerRectSelection(layer, rectType, rect, opt_data) { - this.layer_ = layer; - this.rectType_ = rectType; - this.rect_ = rect; - this.data_ = opt_data !== undefined ? opt_data : rect; - } - - LayerRectSelection.prototype = { - __proto__: Selection.prototype, - - get specicifity() { - return 2; - }, - - get associatedLayerId() { - return this.layer_.layerId; - }, - - - get highlightsByLayerId() { - var highlights = {}; - highlights[this.layer_.layerId] = [ - { - colorKey: this.rectType_, - rect: this.rect_ - } - ]; - return highlights; - }, - - createAnalysis: function() { - var analysis = document.createElement( - 'tr-ui-a-generic-object-view-with-label'); - analysis.label = this.rectType_ + ' on layer ' + this.layer_.layerId; - analysis.object = this.data_; - return analysis; - }, - - findEquivalent: function(lthi) { - return undefined; - } - }; - - /** - * @constructor - */ - function AnimationRectSelection(layer, rect) { - this.layer_ = layer; - this.rect_ = rect; - } - - AnimationRectSelection.prototype = { - __proto__: Selection.prototype, - - get specicifity() { - return 0; - }, - - get associatedLayerId() { - return this.layer_.layerId; - }, - - createAnalysis: function() { - var analysis = document.createElement( - 'tr-ui-a-generic-object-view-with-label'); - analysis.label = 'Animation Bounds of layer ' + this.layer_.layerId; - analysis.object = this.rect_; - return analysis; - } - }; - - return { - Selection: Selection, - RenderPassSelection: RenderPassSelection, - LayerSelection: LayerSelection, - TileSelection: TileSelection, - LayerRectSelection: LayerRectSelection, - AnimationRectSelection: AnimationRectSelection - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/tile_view.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/tile_view.html deleted file mode 100644 index 2c556c67a7b..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/cc/tile_view.html +++ /dev/null @@ -1,57 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/extras/chrome/cc/tile.html"> -<link rel="import" href="/tracing/ui/analysis/generic_object_view.html"> -<link rel="import" href="/tracing/ui/analysis/object_snapshot_view.html"> - -<script> - -'use strict'; - -tr.exportTo('tr.ui.e.chrome.cc', function() { - /* - * Displays a tile in a human readable form. - * @constructor - */ - var TileSnapshotView = tr.ui.b.define( - 'tr-ui-e-chrome-cc-tile-snapshot-view', - tr.ui.analysis.ObjectSnapshotView); - - TileSnapshotView.prototype = { - __proto__: tr.ui.analysis.ObjectSnapshotView.prototype, - - decorate: function() { - this.classList.add('tr-ui-e-chrome-cc-tile-snapshot-view'); - this.layerTreeView_ = - new tr.ui.e.chrome.cc.LayerTreeHostImplSnapshotView(); - this.appendChild(this.layerTreeView_); - }, - - updateContents: function() { - var tile = this.objectSnapshot_; - var layerTreeHostImpl = tile.containingSnapshot; - if (!layerTreeHostImpl) - return; - - this.layerTreeView_.objectSnapshot = layerTreeHostImpl; - this.layerTreeView_.selection = new tr.ui.e.chrome.cc.TileSelection(tile); - } - }; - - tr.ui.analysis.ObjectSnapshotView.register( - TileSnapshotView, - { - typeName: 'cc::Tile', - showInTrackView: false - }); - - return { - TileSnapshotView: TileSnapshotView - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/gpu/gpu.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/gpu/gpu.html deleted file mode 100644 index 93811e10bff..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/gpu/gpu.html +++ /dev/null @@ -1,10 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/extras/chrome/gpu/state.html"> -<link rel="import" href="/tracing/extras/chrome/gpu/gpu_async_slice.html"> -<link rel="import" href="/tracing/ui/extras/chrome/gpu/state_view.html"> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/gpu/images/checkerboard.png b/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/gpu/images/checkerboard.png Binary files differdeleted file mode 100644 index 8ea9bc726bb..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/gpu/images/checkerboard.png +++ /dev/null diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/gpu/state_view.css b/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/gpu/state_view.css deleted file mode 100644 index 466dbb56585..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/gpu/state_view.css +++ /dev/null @@ -1,15 +0,0 @@ -/* Copyright (c) 2013 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -.tr-ui-e-chrome-gpu-state-snapshot-view { - background: url('./images/checkerboard.png'); - display: -webkit-flex; - overflow: auto; -} - -.tr-ui-e-chrome-gpu-state-snapshot-view img { - display: block; - margin: 16px auto 16px auto; -} diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/gpu/state_view.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/gpu/state_view.html deleted file mode 100644 index 77bb005fcf3..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome/gpu/state_view.html +++ /dev/null @@ -1,48 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="stylesheet" href="/tracing/ui/extras/chrome/gpu/state_view.css"> - -<link rel="import" href="/tracing/ui/analysis/object_snapshot_view.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.e.chrome.gpu', function() { - /* - * Displays a GPU state snapshot in a human readable form. - * @constructor - */ - var StateSnapshotView = tr.ui.b.define( - 'tr-ui-e-chrome-gpu-state-snapshot-view', - tr.ui.analysis.ObjectSnapshotView); - - StateSnapshotView.prototype = { - __proto__: tr.ui.analysis.ObjectSnapshotView.prototype, - - decorate: function() { - this.classList.add('tr-ui-e-chrome-gpu-state-snapshot-view'); - this.screenshotImage_ = document.createElement('img'); - this.appendChild(this.screenshotImage_); - }, - - updateContents: function() { - if (this.objectSnapshot_ && this.objectSnapshot_.screenshot) { - this.screenshotImage_.src = 'data:image/png;base64,' + - this.objectSnapshot_.screenshot; - } - } - }; - tr.ui.analysis.ObjectSnapshotView.register( - StateSnapshotView, - {typeName: 'gpu::State'}); - - return { - StateSnapshotView: StateSnapshotView - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome_config.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome_config.html deleted file mode 100644 index cd9fb3f91c4..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/chrome_config.html +++ /dev/null @@ -1,24 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<!-- -The chrome config is heavily used: - - chrome://tracing, - - trace2html, which in turn implies - - adb_profile_chrome - - telemetry ---> - -<link rel="import" href="/tracing/extras/chrome_config.html"> -<link rel="import" href="/tracing/ui/base/ui.html"> -<link rel="import" href="/tracing/ui/extras/chrome/cc/cc.html"> -<link rel="import" href="/tracing/ui/extras/chrome/gpu/gpu.html"> -<link rel="import" href="/tracing/ui/extras/side_panel/frame_data_side_panel.html"> -<link rel="import" href="/tracing/ui/extras/side_panel/input_latency_side_panel.html"> -<link rel="import" href="/tracing/ui/extras/side_panel/time_summary_side_panel.html"> -<link rel="import" href="/tracing/ui/extras/system_stats/system_stats.html"> -<link rel="import" href="/tracing/ui/timeline_view.html"> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/deep_reports/html_results.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/deep_reports/html_results.html deleted file mode 100644 index a515ac4123f..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/deep_reports/html_results.html +++ /dev/null @@ -1,117 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/base/table.html"> - -<!-- -This class tries to (simply) copy the telemetry Results object, but outputs -directly to an HTML table. It takes things that look like Telemetry values, -and updates the table internally. ---> -<polymer-element name="tr-ui-e-deep-reports-html-results"> - <template> - <style> - :host { - display: flex; - } - </style> - <tr-ui-b-table id="table"></tr-ui-b-table> - </template> - <script> - 'use strict'; - - Polymer({ - created: function() { - this.hasColumnNamed_ = {}; - this.pageToRowMap_ = new WeakMap(); - }, - - ready: function() { - var table = this.$.table; - table.tableColumns = [ - { - title: 'Label', - value: function(row) { return row.label; }, - width: '350px' - } - ]; - this.clear(); - }, - - clear: function() { - this.$.table.tableRows = []; - }, - - addColumnIfNeeded_: function(columnName) { - if (this.hasColumnNamed_[columnName]) - return; - this.hasColumnNamed_[columnName] = true; - - var column = { - title: columnName, - value: function(row) { - if (row[columnName] === undefined) - return ''; - return row[columnName]; - } - }; - - var columns = this.$.table.tableColumns; - columns.push(column); - - // Update widths. - var colWidthPercentage; - if (columns.length == 1) - colWidthPercentage = '100%'; - else - colWidthPercentage = (100 / (columns.length - 1)).toFixed(3) + '%'; - - for (var i = 1; i < columns.length; i++) - columns[i].width = colWidthPercentage; - - this.$.table.tableColumns = columns; - }, - - getRowForPage_: function(page) { - if (!this.pageToRowMap_.has(page)) { - var i = page.url.lastIndexOf('/'); - var baseName = page.url.substring(i + 1); - - var link = document.createElement('a'); - link.href = 'trace_viewer.html#' + page.url; - link.textContent = baseName; - - var row = { - label: link, - value: '', - subRows: [], - isExpanded: true - }; - this.$.table.tableRows.push(row); - this.pageToRowMap_.set(page, row); - - // Kick table rebuild. - this.$.table.tableRows = this.$.table.tableRows; - } - return this.pageToRowMap_.get(page); - }, - - addValue: function(value) { - /* Value is expected to be a scalar telemetry-style Value. */ - if (value.type !== 'scalar') - throw new Error('wat'); - - this.addColumnIfNeeded_(value.name); - var rowForPage = this.getRowForPage_(value.page); - rowForPage[value.name] = value.value; - - // Kick table rebuild. - this.$.table.tableRows = this.$.table.tableRows; - } - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/deep_reports/main.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/deep_reports/main.html deleted file mode 100644 index 88af3f292d3..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/deep_reports/main.html +++ /dev/null @@ -1,65 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/base.html"> -<link rel="import" href="/tracing/base/iteration_helpers.html"> -<link rel="import" href="/tracing/base/xhr.html"> -<link rel="import" href="/tracing/ui/extras/deep_reports/scalar_value.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.e.deep_reports', function() { - /** - * Runs deep reports on the provided files, and pushes telemetry-style - * values to the results object. - */ - function main(results, filesInDir) { - var lastP = new Promise(function(resolve) { resolve(); }); - - filesInDir.forEach(function(filename) { - // TODO(nduca): Make this like telemetry page. - var page = { - url: filename - }; - lastP = lastP.then(function() { - return loadModelFromFileAsync(filename); - }); - lastP = lastP.then(function(model) { - processModel(results, page, model); - }); - }); - return lastP; - } - - function loadModelFromFileAsync(filename) { - return tr.b.getAsync(filename).then(function(trace) { - var io = new tr.ImportOptions(); - io.shiftWorldToZero = true; - io.pruneEmptyContainers = false; - - var m = new tr.Model(); - try { - m.importTraces([trace], io); - } catch (e) { - throw new Error('While loading ' + filename + ' got: ' + e.toString()); - } - return m; - }); - } - - function processModel(results, page, model) { - results.addValue( - new tr.ui.e.deep_reports.ScalarValue( - page, 'numRailIRs', 'ms', model.userModel.expectations.length)); - } - - return { - main: main - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/deep_reports/scalar_value.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/deep_reports/scalar_value.html deleted file mode 100644 index 7dcd2bc36c9..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/deep_reports/scalar_value.html +++ /dev/null @@ -1,42 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/base.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.e.deep_reports', function() { - function ScalarValue(page, name, units, value, - opt_important, opt_description) { - this.type = 'scalar'; - this.page = page; - this.name = name; - this.units = units; - this.value = value; - this.important = opt_important !== undefined ? opt_important : false; - this.description = opt_description || ''; - } - ScalarValue.fromDict = function(page, dict) { - if (dict.type !== 'scalar') - throw new Error('wat'); - var v = new ScalarValue(page, dict.name, dict.units, dict.value); - v.important = dict.important; - v.description = dict.description; - v.value = dict.value; - return v; - } - - ScalarValue.prototype = { - - }; - - return { - ScalarValue: ScalarValue - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/drive/comment_element.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/drive/comment_element.html deleted file mode 100644 index 180f2ce97b4..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/drive/comment_element.html +++ /dev/null @@ -1,71 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<polymer-element name="tr-ui-e-drive-comment-element" attributes="comment"> - <template> - <style> - :host { - display: block; - } - #comment-area { - display: flex; - flex-direction: column; - border-top: 1px solid #e8e8e8; - background-color: white; - padding: 6px; - margin-bottom: 4px; - box-shadow: 0 1px 3px rgba(0,0,0,0.3); - border-radius: 2px; - font-size: small; - } - #comment-header { - display: flex; - flex-direction: row; - align-items: center; - margin-bottom: 8px; - } - #comment-header-text { - display: flex; - flex-direction: column; - padding-left: 10px; - } - #comment-img { - width: 32px; - height: 32px; - } - #comment-text-author { - padding-bottom: 2px; - } - #comment-date { - color: #777; - font-size: 11px; - } - #comment-content { - word-wrap: break-word; - } - </style> - <div id="comment-area"> - <div id="comment-header"> - <img id="comment-img" src="{{ comment.author.picture.url }}" /> - <div id="comment-header-text"> - <div id="comment-text-author">{{ comment.author.displayName }}</div> - <div id="comment-date">{{ createdDate }}</div> - </div> - </div> - <div id="comment-content">{{ comment.anchor ? '⚓ ' : '' }} - {{ comment.content }}</div> - </div> - </template> - <script> - 'use strict'; - Polymer({ - commentChanged: function() { - this.createdDate = new Date(this.comment.createdDate).toLocaleString(); - } - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/drive/comments_side_panel.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/drive/comments_side_panel.html deleted file mode 100644 index 3728481be17..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/drive/comments_side_panel.html +++ /dev/null @@ -1,180 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/extras/drive/comment_element.html"> - -<polymer-element name='tr-ui-e-drive-comments-side-panel' - extends='tr-ui-side-panel'> - <template> - <style> - :host { - flex-direction: column; - display: flex; - width: 290px; - overflow-y: scroll; - overflow-x: hidden; - background-color: #eee; - } - toolbar { - flex: 0 0 auto; - border-bottom: 1px solid black; - display: flex; - } - result-area { - flex: 1 1 auto; - display: block; - min-height: 0; - padding: 4px; - } - #comments-textarea-container { - display: flex; - } - #commentinput { - width: 100%; - } - </style> - - <toolbar id='toolbar'></toolbar> - <result-area id='result_area'> - <template repeat="{{ comment in comments_ }}"> - <tr-ui-e-drive-comment-element comment="{{comment}}" - on-click="{{commentClick}}"> - </tr-ui-e-drive-comment-element> - </template> - <div id="comments-textarea-container"> - <textarea id="commentinput" on-focus='{{textAreaFocus}}' - on-blur='{{textAreaBlur}}' - on-keypress="{{textareaKeypress}}"></textarea> - </div> - </result-area> - </template> - - <script> - 'use strict'; - - Polymer({ - ready: function() { - this.rangeOfInterest_ = new tr.b.Range(); - this.selection_ = undefined; - this.comments_ = []; - this.annotationFromComment_ = undefined; - this.textAreaFocused = false; - }, - - setCommentProvider: function(commentProvider) { - this.commentProvider_ = commentProvider; - }, - - attached: function() { - if (this.commentProvider_ === undefined) { - this.commentProvider_ = - new tr.ui.e.drive.analysis.DefaultCommentProvider(); - } - this.commentProvider_.attachToElement(this); - }, - - detached: function() { - this.commentProvider_.detachFromElement(); - }, - - commentClick: function(event, detail, sender) { - var anchor = sender.comment.anchor; - if (anchor === undefined) - return; - - var uiState = - JSON.parse(anchor).a[0][tr.ui.e.drive.constants.ANCHOR_NAME]; - - var myEvent = new CustomEvent('navigateToUIState', { detail: - new tr.ui.b.UIState(new tr.model.Location(uiState.location.xWorld, - uiState.location.yComponents), - uiState.scaleX) - }); - document.dispatchEvent(myEvent); - - if (this.annotationFromComment_) - this.model.removeAnnotation(this.annotationFromComment_); - var loc = new tr.model.Location(uiState.location.xWorld, - uiState.location.yComponents); - - var text = sender.comment.author.displayName + ': ' + - sender.comment.content; - this.annotationFromComment_ = - new tr.model.CommentBoxAnnotation(loc, text); - this.model.addAnnotation(this.annotationFromComment_); - }, - - textareaKeypress: function(event, detail, sender) { - // Check for return key. - if (event.keyCode === 13 && !event.ctrlKey) { - this.commentProvider_.addComment(this.$.commentinput.value); - this.$.commentinput.value = ''; - } - event.stopPropagation(); - return true; - }, - - textAreaFocus: function(event) { - this.textAreaFocused = true; - }, - - textAreaBlur: function(event) { - this.textAreaFocused = false; - }, - - get rangeOfInterest() { - return this.rangeOfInterest_; - }, - - set rangeOfInterest(rangeOfInterest) { - this.rangeOfInterest_ = rangeOfInterest; - this.updateContents_(); - }, - - get currentRangeOfInterest() { - if (this.rangeOfInterest_.isEmpty) - return this.model_.bounds; - else - return this.rangeOfInterest_; - }, - - get model() { - return this.model_; - }, - - set model(model) { - this.model_ = model; - this.updateContents_(); - }, - - set selection(selection) { - this.selection_ = selection; - }, - - updateContents_: function() { - this.commentProvider_.updateComments(); - }, - - supportsModel: function(m) { - if (m === undefined) { - return { - supported: false, - reason: 'Unknown tracing model' - }; - } - return { - supported: true - }; - }, - - get textLabel() { - return 'Comments'; - } - }); - - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/drive/comments_side_panel_test.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/drive/comments_side_panel_test.html deleted file mode 100644 index bca061a876d..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/drive/comments_side_panel_test.html +++ /dev/null @@ -1,71 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/extras/drive/comments_side_panel.html"> -<link rel="import" href="/tracing/core/test_utils.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - function StubCommentProvider() { - this.addDummyComment('Lorem ipsum dolor sit amet'); - this.addDummyComment('consectetur adipiscing elit'); - this.addDummyComment('sed do eiusmod tempor incididunt ut labore et ' + - 'dolore magna aliqua. Ut enim ad minim veniam, quis nostrud ' + - 'exercitation ullamco laboris nisi ut aliquip ex ea commodo ' + - 'consequat. Duis aute irure dolor in reprehenderit in voluptate ' + - 'velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint ' + - 'occaecat cupidatat non proident, sunt in culpa qui officia deserunt ' + - 'mollit anim id est laborum.'); - } - - StubCommentProvider.prototype = { - comments_: [], - - attachToElement: function(attachedElement) { - this.attachedElement_ = attachedElement; - this.updateComments(); - }, - - detachFromElement: function() { - }, - - updateComments: function() { - this.attachedElement_.comments_ = this.comments_; - }, - - addDummyComment: function(content) { - var newComment = { - author: { - displayName: 'Casper the Friendly Ghost', - picture: { - url: 'https://lh3.googleusercontent.com/-XdUIqdMkCWA/' + - 'AAAAAAAAAAI/AAAAAAAAAAA/4252rscbv5M/s128/photo.jpg' - } - }, - createdDate: Date.now(), - anchor: (this.comments_.length) % 2 ? 1 : 0, - content: content - }; - - this.comments_.push(newComment); - }, - - addComment: function(body) { - this.addDummyComment(body); - this.updateComments(); - } - }; - - test('instantiate', function() { - var panel = document.createElement('tr-ui-e-drive-comments-side-panel'); - panel.setCommentProvider(new StubCommentProvider); - this.addHTMLOutput(panel); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/drive/drive_comment_provider.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/drive/drive_comment_provider.html deleted file mode 100644 index c55f98a727f..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/drive/drive_comment_provider.html +++ /dev/null @@ -1,101 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/side_panel/side_panel.html"> -<link rel="import" href="/tracing/model/comment_box_annotation.html"> - -<link rel="import" href="/tracing/ui/extras/drive/comments_side_panel.html"> - -<script> -'use strict'; - -(function() { - function addDriveCommentWithUIState_(text, uiState) { - gapi.client.load('drive', 'v2', function() { - var request = gapi.client.drive.revisions.get({ - 'fileId': tr.ui.e.drive.getDriveFileId(), - 'revisionId': 'head' - }); - request.execute(function(resp) { - var anchorObject = {}; - anchorObject[tr.ui.e.drive.constants.ANCHOR_NAME] = uiState; - var anchor = { - 'r': resp.id, - 'a': [anchorObject] - }; - anchor = JSON.stringify(anchor); - gapi.client.load('drive', 'v2', function() { - var request = gapi.client.drive.comments.insert({ - 'fileId': tr.ui.e.drive.getDriveFileId(), - 'resource': {'content': text, 'anchor': anchor} - }); - request.execute(); - }); - }); - }); - }; - - function onCommentWithUIState(e) { - addDriveCommentWithUIState_(e.detail.name, e.detail.location); - }; - - document.addEventListener('commentWithUIState', - onCommentWithUIState.bind(this)); -}()); - -tr.exportTo('tr.ui.e.drive.analysis', function() { - function DefaultCommentProvider() { } - - DefaultCommentProvider.prototype = { - attachToElement: function(attachedElement) { - this.attachedElement_ = attachedElement; - this.commentsCheckTimer_ = setTimeout(this.checkForComments_.bind(this), - 5000); - }, - - detachFromElement: function() { - clearTimeout(this.commentsCheckTimer_); - }, - - checkForComments_: function() { - this.updateComments(); - this.commentsCheckTimer_ = setTimeout(this.checkForComments_.bind(this), - 5000); - }, - - updateComments: function() { - var self = this; - gapi.client.load('drive', 'v2', function() { - var request = gapi.client.drive.comments.list({ - 'fileId': tr.ui.e.drive.getDriveFileId() - }); - request.execute(function(results) { - self.attachedElement_.comments_ = results.items; - }); - }); - }, - - addComment: function(body) { - var self = this; - gapi.client.load('drive', 'v2', function() { - var request = gapi.client.drive.comments.insert({ - 'fileId': tr.ui.e.drive.getDriveFileId(), - 'resource': {'content': body} - }); - request.execute(function(resp) { - self.updateComments(); - }); - }); - } - }; - - return { - DefaultCommentProvider: DefaultCommentProvider - }; -}); - -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/drive/index.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/drive/index.html deleted file mode 100644 index 2c44cea24ff..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/drive/index.html +++ /dev/null @@ -1,462 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> -<head> - <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> - - <script type="text/javascript" src="https://apis.google.com/js/api.js"></script> - - <link rel="import" href="/components/polymer/polymer.html"> - <link rel="import" href="/tracing/ui/extras/full_config.html"> - <link rel="import" href="/tracing/ui/timeline_view.html"> - <link rel="import" href="/tracing/ui/extras/drive/drive_comment_provider.html"> - - <style> - body { - margin: 0; - padding: 0; - width: 100%; - height: 100%; - display: -webkit-flex; - -webkit-flex-direction: column; - } - body > x-timeline-view { - -webkit-flex: 1 1 auto; - overflow: hidden; - position: absolute; - top: 0px; - bottom: 0; - left: 0; - right: 0; - } - body > x-timeline-view:focus { - outline: none; - } - nav { - display: flex; - flex-direction: row; - justify-content: flex-end; - } - #navbar button { - height: 24px; - padding-bottom: 3px; - vertical-align: middle; - box-shadow: none; - background-color: #4d90fe; - background-image: -webkit-linear-gradient(top,#4d90fe,#4787ed); - border: 1px solid #3079ed; - color: #fff; - border-radius: 2px; - cursor: default; - font-size: 11px; - font-weight: bold; - text-align: center; - white-space: nowrap; - line-height: 27px; - min-width: 54px; - outline: 0px; - padding: 0 8px; - font: normal 13px arial,sans-serif; - margin: 5px; - } - #collabs { - display: flex; - flex-direction: row; - } - .collaborator-div { - display: inline-block; - vertical-align: middle; - min-height: 0; - width: 100px; - font-size: 11px; - font-weight: bold; - font: normal 13px arial,sans-serif; - margin: 10px; - } - .collaborator-img { - margin: 2px; - } - .collaborator-tooltip { - z-index: 10000; - transition: visibility 0,opacity .13s ease-in; - background-color: #2a2a2a; - border: 1px solid #fff; - color: #fff; - cursor: default; - display: block; - font-family: arial, sans-serif; - font-size: 11px; - font-weight: bold; - margin-left: -1px; - opacity: 1; - padding: 7px 9px; - word-break: break-word; - position: absolute; - } - .collaborator-tooltip-content { - color: #fff; - } - .collaborator-tooltip-arrow { - position: absolute; - top: -6px; - } - .collaborator-tooltip-arrow-before { - border-color: #fff transparent !important; - left: -6px; - border: 6px solid; - border-top-width: 0; - content: ''; - display: block; - height: 0; - position: absolute; - width: 0; - } - .collaborator-tooltip-arrow-after { - top: 1px; - border-color: #2a2a2a transparent !important; - left: -5px; - border: 5px solid; - border-top-width: 0; - content: ''; - display: block; - height: 0; - position: absolute; - width: 0; - } - - </style> - <title>Trace Viewer</title> -</head> -<body> - <nav id="navbar"> - <div id="collabs"></div> - <button id="x-drive-save-to-disk">Save to disk</button> - <button id="x-drive-save-to-drive">Save to Drive</button> - <button id="x-drive-load-from-drive">Load from Drive</button> - <button id="x-drive-share">Share</button> - </nav> - <x-timeline-view> - </x-timeline-view> - - <script> - 'use strict'; - - // Needs to be global as it's passed through the Google API as a - // GET parameter. - var onAPIClientLoaded_ = null; - - (function() { - - tr.exportTo('tr.ui.e.drive', function() { - var appId = '239864068844'; - var constants = { - APP_ID: appId, - ANCHOR_NAME: appId + '.trace_viewer', - DEVELOPER_KEY: 'AIzaSyDR-6_wL9vHg1_oz4JHk8IQAkv2_Y0Y8-M', - CLIENT_ID: '239864068844-c7gefbfdcp0j6grltulh2r88tsvl18c1.apps.' + - 'googleusercontent.com', - SCOPE: [ - 'https://www.googleapis.com/auth/drive', - 'https://www.googleapis.com/auth/drive.install', - 'https://www.googleapis.com/auth/drive.file', - 'profile' - ] - }; - - return { - getDriveFileId: function() { return driveFileId_; }, - constants: constants - }; - }); - - - var pickerApiLoaded_ = false; - var oauthToken_ = null; - - var timelineViewEl_ = null; - var driveDocument_ = null; - var shareClient_ = null; - var fileIdToLoad_ = null; - var driveFileId_ = null; - - function parseGETParameter(val) { - var result = null; - var tmp = []; - location.search.substr(1).split('&').forEach(function(item) { - tmp = item.split('='); - if (tmp[0] === val) - result = decodeURIComponent(tmp[1]); - }); - return result; - } - - // Use the Google API Loader script to load the google.picker script. - onAPIClientLoaded_ = function() { - var driveState = parseGETParameter('state'); - if (driveState != null) { - var driveStateJson = JSON.parse(driveState); - fileIdToLoad_ = String(driveStateJson.ids); - } - - gapi.load('picker', {'callback': onPickerApiLoad}); - gapi.load('auth', {'callback': function() { - onAuthApiLoad(true, onAuthResultSuccess); - setTimeout(function onRepeatAuthApiLoad() { - onAuthApiLoad(true, function() {}); - setTimeout(onRepeatAuthApiLoad, 30000); - }, 30000); - }}); - } - - function onAuthApiLoad(tryImmediate, resultCallback) { - window.gapi.auth.authorize( - {'client_id': tr.ui.e.drive.constants.CLIENT_ID, - 'scope': tr.ui.e.drive.constants.SCOPE, 'immediate': tryImmediate}, - function(authResult) { - handleAuthResult(authResult, tryImmediate, resultCallback); - }); - } - - function onPickerApiLoad() { - pickerApiLoaded_ = true; - if (fileIdToLoad_ == null) - createPicker(); - } - - function onAuthResultSuccess() { - if (fileIdToLoad_ == null) - createPicker(); - else - loadFileFromDrive(fileIdToLoad_); - } - - function handleAuthResult(authResult, wasImmediate, resultCallback) { - if (authResult && !authResult.error) { - oauthToken_ = authResult.access_token; - resultCallback(); - } else if (wasImmediate) { - onAuthApiLoad(false); - } - } - - function createPicker() { - if (pickerApiLoaded_ && oauthToken_) { - var view = new google.picker.View(google.picker.ViewId.DOCS); - view.setMimeTypes('application/json,application/octet-stream'); - var picker = new google.picker.PickerBuilder() - .enableFeature(google.picker.Feature.NAV_HIDDEN) - .enableFeature(google.picker.Feature.MULTISELECT_ENABLED) - .setAppId(tr.ui.e.drive.constants.APP_ID) - .setOAuthToken(oauthToken_) - .addView(view) - .addView(new google.picker.DocsUploadView()) - .setDeveloperKey(tr.ui.e.drive.constants.DEVELOPER_KEY) - .setCallback(pickerCallback) - .build(); - picker.setVisible(true); - } - } - - function pickerCallback(data) { - if (data.action == google.picker.Action.PICKED) { - loadFileFromDrive(data.docs[0].id); - } - } - - function initShareButton() { - shareClient_ = new gapi.drive.share.ShareClient( - tr.ui.e.drive.constants.APP_ID); - shareClient_.setItemIds([driveFileId_]); - } - - function loadFileFromDrive(fileId) { - gapi.client.load('drive', 'v2', function() { - var request = gapi.client.drive.files.get({'fileId': fileId}); - request.execute(function(resp) { downloadFile(resp); }); - driveFileId_ = fileId; - gapi.load('drive-share', initShareButton); - }); - } - - function downloadFile(file) { - if (file.downloadUrl) { - var downloadingOverlay = tr.ui.b.Overlay(); - downloadingOverlay.title = 'Downloading...'; - downloadingOverlay.userCanClose = false; - downloadingOverlay.msgEl = document.createElement('div'); - downloadingOverlay.appendChild(downloadingOverlay.msgEl); - downloadingOverlay.msgEl.style.margin = '20px'; - downloadingOverlay.update = function(msg) { - this.msgEl.textContent = msg; - } - downloadingOverlay.visible = true; - - var accessToken = gapi.auth.getToken().access_token; - var xhr = new XMLHttpRequest(); - xhr.open('GET', file.downloadUrl); - xhr.setRequestHeader('Authorization', 'Bearer ' + accessToken); - xhr.onload = function() { - downloadingOverlay.visible = false; - onDownloaded(file.title, xhr.responseText); - }; - xhr.onprogress = function(evt) { - downloadingOverlay.update( - Math.floor(evt.position * 100 / file.fileSize) + '% complete'); - }; - xhr.onerror = function() { alert('Failed downloading!'); }; - xhr.send(); - } else { - alert('No URL!'); - } - } - - function displayAllCollaborators() { - var allCollaborators = driveDocument_.getCollaborators(); - var collaboratorCount = allCollaborators.length; - var collabspan = document.getElementById('collabs'); - collabspan.innerHTML = ''; - var imageList = []; - for (var i = 0; i < collaboratorCount; i++) { - var user = allCollaborators[i]; - - var img = document.createElement('img'); - img.src = user.photoUrl; - img.alt = user.displayName; - img.height = 30; - img.width = 30; - img.className = 'collaborator-img'; - collabspan.appendChild(img); - imageList.push({'image': img, 'name': user.displayName}); - } - for (i = 0; i < imageList.length; i++) { - var collabTooltip = tr.ui.b.createDiv({ - className: 'collaborator-tooltip' - }); - var collabTooltipContent = tr.ui.b.createDiv({ - className: 'collaborator-tooltip-content' - }); - collabTooltipContent.textContent = imageList[i].name; - collabTooltip.appendChild(collabTooltipContent); - collabspan.appendChild(collabTooltip); - var collabTooltipArrow = tr.ui.b.createDiv({ - className: 'collaborator-tooltip-arrow'}); - collabTooltip.appendChild(collabTooltipArrow); - var collabTooltipArrowBefore = tr.ui.b.createDiv({ - className: 'collaborator-tooltip-arrow-before'}); - collabTooltipArrow.appendChild(collabTooltipArrowBefore); - var collabTooltipArrowAfter = tr.ui.b.createDiv({ - className: 'collaborator-tooltip-arrow-after'}); - collabTooltipArrow.appendChild(collabTooltipArrowAfter); - - var rect = imageList[i].image.getBoundingClientRect(); - collabTooltip.style.top = (rect.bottom - 6) + 'px'; - collabTooltip.style.left = - (rect.left + 16 - (collabTooltip.offsetWidth / 2)) + 'px'; - collabTooltipArrow.style.left = (collabTooltip.offsetWidth / 2) + 'px'; - collabTooltip.style.visibility = 'hidden'; - function visibilityDelegate(element, visibility) { - return function() { - element.style.visibility = visibility; - } - } - imageList[i].image.addEventListener( - 'mouseover', visibilityDelegate(collabTooltip, 'visible')); - imageList[i].image.addEventListener( - 'mouseout', visibilityDelegate(collabTooltip, 'hidden')); - } - } - - function onRealtimeFileLoaded(doc) { - if (driveDocument_) - driveDocument_.close(); - driveDocument_ = doc; - doc.addEventListener(gapi.drive.realtime.EventType.COLLABORATOR_JOINED, - displayAllCollaborators); - doc.addEventListener(gapi.drive.realtime.EventType.COLLABORATOR_LEFT, - displayAllCollaborators); - - displayAllCollaborators(doc); - } - - function onRealtimeError(e) { - alert('Error loading realtime: ' + e); - } - - function onDownloaded(filename, content) { - gapi.load('auth:client,drive-realtime,drive-share', function() { - gapi.drive.realtime.load(driveFileId_, - onRealtimeFileLoaded, - null, - onRealtimeError); - - }); - - var traces = []; - var filenames = []; - filenames.push(filename); - traces.push(content); - createViewFromTraces(filenames, traces); - } - - function createViewFromTraces(filenames, traces) { - var m = new tr.Model(); - var i = new tr.importer.Import(m); - var p = i.importTracesWithProgressDialog(traces); - p.then( - function() { - timelineViewEl_.model = m; - timelineViewEl_.updateDocumentFavicon(); - timelineViewEl_.globalMode = true; - timelineViewEl_.viewTitle = ''; - }, - function(err) { - var downloadingOverlay = new tr.ui.b.Overlay(); - downloadingOverlay.textContent = - tr.b.normalizeException(err).message; - downloadingOverlay.title = 'Import error'; - downloadingOverlay.visible = true; - }); - } - - function onSaveToDiskClicked() { - throw new Error('Not implemented'); - } - - function onSaveToDriveClicked() { - throw new Error('Not implemented'); - } - - function onLoadFromDriveClicked() { - createPicker(); - } - - function onLoad() { - timelineViewEl_ = document.querySelector('x-timeline-view'); - timelineViewEl_.globalMode = true; - var navbar = document.getElementById('navbar'); - timelineViewEl_.style.top = navbar.offsetHeight + 'px'; - tr.ui.b.decorate(timelineViewEl_, tr.ui.TimelineView); - } - - window.addEventListener('load', onLoad); - - document.getElementById('x-drive-save-to-disk').onclick = - onSaveToDiskClicked; - document.getElementById('x-drive-save-to-drive').onclick = - onSaveToDriveClicked; - document.getElementById('x-drive-load-from-drive').onclick = - onLoadFromDriveClicked; - document.getElementById('x-drive-share').onclick = function() { - shareClient_.showSettingsDialog(); - }; - - }()); - - </script> - <script type="text/javascript" - src="https://apis.google.com/js/client.js?onload=onAPIClientLoaded_"> - </script> -</body> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/full_config.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/full_config.html deleted file mode 100644 index f27fbafd1ce..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/full_config.html +++ /dev/null @@ -1,12 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<!-- The full config is all the configs slammed together. --> -<link rel="import" href="/tracing/extras/importer/gcloud_trace/gcloud_trace_importer.html"> -<link rel="import" href="/tracing/ui/extras/chrome_config.html"> -<link rel="import" href="/tracing/ui/extras/lean_config.html"> -<link rel="import" href="/tracing/ui/extras/systrace_config.html"> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/highlighter/vsync_highlighter.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/highlighter/vsync_highlighter.html deleted file mode 100644 index b804717a76a..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/highlighter/vsync_highlighter.html +++ /dev/null @@ -1,122 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/tracks/highlighter.html"> -<link rel="import" href="/tracing/ui/timeline_track_view.html"> -<link rel="import" href="/tracing/ui/timeline_viewport.html"> -<link rel="import" href="/tracing/ui/tracks/model_track.html"> - -<script> -'use strict'; - -/** - * @fileoverview Provides the VSyncHighlighter class. - */ -tr.exportTo('tr.ui.e.highlighter', function() { - - var Highlighter = tr.ui.tracks.Highlighter; - - /** - * Highlights VSync events on the model track (using "zebra" striping). - * @constructor - */ - function VSyncHighlighter(viewport) { - Highlighter.call(this, viewport); - this.times_ = []; - } - - VSyncHighlighter.VSYNC_HIGHLIGHT_COLOR = new tr.b.Color(0, 0, 255); - VSyncHighlighter.VSYNC_HIGHLIGHT_ALPHA = 0.1; - - VSyncHighlighter.VSYNC_DENSITY_TRANSPARENT = 0.20; - VSyncHighlighter.VSYNC_DENSITY_OPAQUE = 0.10; - VSyncHighlighter.VSYNC_DENSITY_RANGE = - VSyncHighlighter.VSYNC_DENSITY_TRANSPARENT - - VSyncHighlighter.VSYNC_DENSITY_OPAQUE; - - /** - * Generate a zebra striping from a list of times. - */ - VSyncHighlighter.generateStripes = function(times, minTime, maxTime) { - if (times.length === 0) - return []; - - var stripes = []; - - // Find the lowest and highest index within the viewport. - var lowIndex = tr.b.findLowIndexInSortedArray( - times, - function(time) { return time; }, - minTime); - var highIndex = lowIndex - 1; - while (times[highIndex + 1] <= maxTime) { - highIndex++; - } - - // Must start at an even index and end at an odd index. - for (var i = lowIndex - (lowIndex % 2); i <= highIndex; i += 2) { - var left = i < lowIndex ? minTime : times[i]; - var right = i + 1 > highIndex ? maxTime : times[i + 1]; - stripes.push([left, right]); - } - - return stripes; - } - - VSyncHighlighter.prototype = { - __proto__: Highlighter.prototype, - - processModel: function(model) { - this.times_ = model.device.vSyncTimestamps; - }, - - drawHighlight: function(ctx, dt, viewLWorld, viewRWorld, viewHeight) { - if (!this.viewport_.highlightVSync) { - return; - } - - var stripes = VSyncHighlighter.generateStripes( - this.times_, viewLWorld, viewRWorld); - if (stripes.length == 0) { - return; - } - - var stripeRange = stripes[stripes.length - 1][1] - stripes[0][0]; - var stripeDensity = stripes.length / (dt.scaleX * stripeRange); - var clampedStripeDensity = tr.b.clamp(stripeDensity, - VSyncHighlighter.VSYNC_DENSITY_OPAQUE, - VSyncHighlighter.VSYNC_DENSITY_TRANSPARENT); - var opacity = - (VSyncHighlighter.VSYNC_DENSITY_TRANSPARENT - clampedStripeDensity) / - VSyncHighlighter.VSYNC_DENSITY_RANGE; - if (opacity == 0) { - return; - } - - var pixelRatio = window.devicePixelRatio || 1; - var height = viewHeight * pixelRatio; - - var c = VSyncHighlighter.VSYNC_HIGHLIGHT_COLOR; - ctx.fillStyle = c.toStringWithAlphaOverride( - VSyncHighlighter.VSYNC_HIGHLIGHT_ALPHA * opacity); - - for (var i = 0; i < stripes.length; i++) { - var xLeftView = dt.xWorldToView(stripes[i][0]); - var xRightView = dt.xWorldToView(stripes[i][1]); - ctx.fillRect(xLeftView, 0, xRightView - xLeftView, height); - } - } - }; - - // Register the highlighter. - tr.ui.tracks.Highlighter.register(VSyncHighlighter); - - return { - VSyncHighlighter: VSyncHighlighter - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/highlighter/vsync_highlighter_test.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/highlighter/vsync_highlighter_test.html deleted file mode 100644 index 9e8f1779cbf..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/highlighter/vsync_highlighter_test.html +++ /dev/null @@ -1,151 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/model/thread.html"> -<link rel="import" href="/tracing/ui/extras/highlighter/vsync_highlighter.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - - var VSyncHighlighter = tr.ui.e.highlighter.VSyncHighlighter; - - var VIEW_L_WORLD = 100; - var VIEW_R_WORLD = 1000; - - function testGenerateStripes(times, expectedRanges) { - var ranges = VSyncHighlighter.generateStripes( - times, VIEW_L_WORLD, VIEW_R_WORLD); - - assert.sameDeepMembers(ranges, expectedRanges); - } - - test('generateInside', function() { - testGenerateStripes([], []); - testGenerateStripes([200, 500], [[200, 500]]); - testGenerateStripes([200, 500, 800, 900], [[200, 500], [800, 900]]); - testGenerateStripes( - [200, 500, 800, 900, 998, 999], - [[200, 500], [800, 900], [998, 999]]); - }); - - test('generateOutside', function() { - // Far left. - testGenerateStripes([0, 99], []); - testGenerateStripes([0, 10, 50, 99], []); - testGenerateStripes([0, 99, 101, 999], [[101, 999]]); - testGenerateStripes([0, 10, 50, 99, 101, 999], [[101, 999]]); - - // Far right. - testGenerateStripes([1001, 2000], []); - testGenerateStripes([1001, 2000, 3000, 4000], []); - testGenerateStripes([101, 999, 1001, 2000], [[101, 999]]); - testGenerateStripes([101, 999, 1001, 2000, 3000, 4000], [[101, 999]]); - - // Far both. - testGenerateStripes([0, 99, 1001, 2000], []); - testGenerateStripes([0, 10, 50, 99, 1001, 2000], []); - testGenerateStripes([0, 10, 50, 99, 1001, 2000, 3000, 4000], []); - testGenerateStripes([0, 99, 101, 999, 1001, 2000], [[101, 999]]); - }); - - test('generateOverlap', function() { - // Left overlap. - testGenerateStripes([0, 101], [[VIEW_L_WORLD, 101]]); - testGenerateStripes([0, 1, 2, 101], [[VIEW_L_WORLD, 101]]); - testGenerateStripes( - [2, 101, 102, 103], - [[VIEW_L_WORLD, 101], [102, 103]]); - testGenerateStripes( - [0, 1, 2, 101, 102, 103], - [[VIEW_L_WORLD, 101], [102, 103]]); - testGenerateStripes( - [0, 1, 2, 101, 102, 103, 1001, 3000], - [[VIEW_L_WORLD, 101], [102, 103]]); - - // Right overlap. - testGenerateStripes([999, 2000], [[999, VIEW_R_WORLD]]); - testGenerateStripes([999, 2000, 3000, 4000], [[999, VIEW_R_WORLD]]); - testGenerateStripes( - [997, 998, 999, 2000], - [[997, 998], [999, VIEW_R_WORLD]]); - testGenerateStripes( - [997, 998, 999, 2000, 3000, 4000], - [[997, 998], [999, VIEW_R_WORLD]]); - testGenerateStripes( - [0, 10, 997, 998, 999, 2000, 3000, 4000], - [[997, 998], [999, VIEW_R_WORLD]]); - - // Both overlap. - testGenerateStripes([0, 2000], [[VIEW_L_WORLD, VIEW_R_WORLD]]); - testGenerateStripes( - [0, 101, 999, 2000], - [[VIEW_L_WORLD, 101], [999, VIEW_R_WORLD]]); - testGenerateStripes( - [0, 101, 200, 900, 999, 2000], - [[VIEW_L_WORLD, 101], [200, 900], [999, VIEW_R_WORLD]]); - testGenerateStripes( - [0, 10, 90, 101, 999, 2000, 3000, 4000], - [[VIEW_L_WORLD, 101], [999, VIEW_R_WORLD]]); - testGenerateStripes( - [0, 10, 90, 101, 200, 900, 999, 2000, 3000, 4000], - [[VIEW_L_WORLD, 101], [200, 900], [999, VIEW_R_WORLD]]); - }); - - test('generateOdd', function() { - // One VSync. - testGenerateStripes([0], [[VIEW_L_WORLD, VIEW_R_WORLD]]); - testGenerateStripes([500], [[500, VIEW_R_WORLD]]); - testGenerateStripes([1500], []); - - // Multiple VSyncs. - testGenerateStripes([0, 10, 20], [[VIEW_L_WORLD, VIEW_R_WORLD]]); - testGenerateStripes([0, 500, 2000], [[VIEW_L_WORLD, 500]]); - testGenerateStripes([0, 10, 500], [[500, VIEW_R_WORLD]]); - testGenerateStripes([0, 10, 2000], []); - testGenerateStripes( - [0, 200, 500], - [[VIEW_L_WORLD, 200], [500, VIEW_R_WORLD]]); - testGenerateStripes( - [0, 200, 500, 900], - [[VIEW_L_WORLD, 200], [500, 900]]); - }); - - test('generateBorder', function() { - testGenerateStripes([0, VIEW_L_WORLD], [[VIEW_L_WORLD, VIEW_L_WORLD]]); - testGenerateStripes( - [VIEW_L_WORLD, VIEW_L_WORLD], - [[VIEW_L_WORLD, VIEW_L_WORLD]]); - testGenerateStripes( - [VIEW_R_WORLD, 2000], - [[VIEW_R_WORLD, VIEW_R_WORLD]]); - testGenerateStripes( - [VIEW_R_WORLD, VIEW_R_WORLD], - [[VIEW_R_WORLD, VIEW_R_WORLD]]); - testGenerateStripes( - [VIEW_L_WORLD, VIEW_R_WORLD], - [[VIEW_L_WORLD, VIEW_R_WORLD]]); - testGenerateStripes( - [VIEW_L_WORLD, 200, 500, VIEW_R_WORLD], - [[VIEW_L_WORLD, 200], [500, VIEW_R_WORLD]]); - testGenerateStripes( - [0, VIEW_L_WORLD, VIEW_R_WORLD, 2000], - [[VIEW_L_WORLD, VIEW_L_WORLD], [VIEW_R_WORLD, VIEW_R_WORLD]]); - testGenerateStripes( - [0, VIEW_L_WORLD, VIEW_R_WORLD, 2000], - [[VIEW_L_WORLD, VIEW_L_WORLD], [VIEW_R_WORLD, VIEW_R_WORLD]]); - testGenerateStripes( - [0, VIEW_L_WORLD, 200, 500, VIEW_R_WORLD, 2000], - [[VIEW_L_WORLD, VIEW_L_WORLD], [200, 500], - [VIEW_R_WORLD, VIEW_R_WORLD]]); - testGenerateStripes( - [0, 10, VIEW_L_WORLD, VIEW_R_WORLD, 2000, 3000], - [[VIEW_L_WORLD, VIEW_R_WORLD]]); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/lean_config.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/lean_config.html deleted file mode 100644 index 0197474ce45..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/lean_config.html +++ /dev/null @@ -1,16 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/extras/lean_config.html"> - -<!-- -The lean config is just enough to import uncompressed, trace-event-formatted -json blobs. ---> -<link rel="import" href="/tracing/ui/extras/highlighter/vsync_highlighter.html"> -<link rel="import" href="/tracing/ui/side_panel/file_size_stats_side_panel.html"> -<link rel="import" href="/tracing/ui/side_panel/metrics_side_panel.html"> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/side_panel/alerts_side_panel.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/side_panel/alerts_side_panel.html deleted file mode 100644 index 5cc5b6dc241..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/side_panel/alerts_side_panel.html +++ /dev/null @@ -1,161 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/statistics.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/ui/base/table.html"> -<link rel="import" href="/tracing/ui/side_panel/side_panel.html"> -<link rel="import" href="/tracing/ui/base/dom_helpers.html"> -<link rel="import" href="/tracing/ui/base/line_chart.html"> - -<polymer-element name='tr-ui-e-s-alerts-side-panel' - extends='tr-ui-side-panel'> - <template> - <style> - :host { - display: block; - width: 250px; - } - #content { - flex-direction: column; - display: flex; - } - </style> - - <div id='content'> - <toolbar id='toolbar'></toolbar> - <result-area id='result_area'></result-area> - </div> - </template> - - <script> - 'use strict'; - - Polymer({ - ready: function() { - this.rangeOfInterest_ = new tr.b.Range(); - this.selection_ = undefined; - }, - - get model() { - return this.model_; - }, - - set model(model) { - this.model_ = model; - this.updateContents_(); - }, - - set selection(selection) { - }, - - set rangeOfInterest(rangeOfInterest) { - }, - - /** - * Fires a selection event selecting all alerts of the specified - * type. - */ - selectAlertsOfType: function(alertTypeString) { - var alertsOfType = this.model_.alerts.filter(function(alert) { - return alert.title === alertTypeString; - }); - - var event = new tr.model.RequestSelectionChangeEvent(); - event.selection = new tr.model.EventSet(alertsOfType); - this.dispatchEvent(event); - }, - - /** - * Returns a map for the specified alerts where each key is the - * alert type string and each value is a list of alerts with that - * type. - */ - alertsByType_: function(alerts) { - var alertsByType = {}; - alerts.forEach(function(alert) { - if (!alertsByType[alert.title]) - alertsByType[alert.title] = []; - - alertsByType[alert.title].push(alert); - }); - return alertsByType; - }, - - alertsTableRows_: function(alertsByType) { - return Object.keys(alertsByType).map(function(key) { - return { - alertType: key, - count: alertsByType[key].length - }; - }); - }, - - alertsTableColumns_: function() { - return [ - { - title: 'Alert type', - value: function(row) { return row.alertType; }, - width: '180px' - }, - { - title: 'Count', - width: '100%', - value: function(row) { return row.count; } - } - ]; - }, - - createAlertsTable_: function(alerts) { - var alertsByType = this.alertsByType_(alerts); - - var table = document.createElement('tr-ui-b-table'); - table.tableColumns = this.alertsTableColumns_(); - table.tableRows = this.alertsTableRows_(alertsByType); - table.selectionMode = tr.ui.b.TableFormat.SelectionMode.ROW; - table.addEventListener('selection-changed', function(e) { - var row = table.selectedTableRow; - if (row) - this.selectAlertsOfType(row.alertType); - }.bind(this)); - - return table; - }, - - updateContents_: function() { - this.$.result_area.textContent = ''; - if (this.model_ === undefined) - return; - - var panel = this.createAlertsTable_(this.model_.alerts); - this.$.result_area.appendChild(panel); - }, - - supportsModel: function(m) { - if (m == undefined) { - return { - supported: false, - reason: 'Unknown tracing model' - }; - } else if (m.alerts.length === 0) { - return { - supported: false, - reason: 'No alerts in tracing model' - }; - } - - return { - supported: true - }; - }, - - get textLabel() { - return 'Alerts'; - } - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/side_panel/alerts_side_panel_test.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/side_panel/alerts_side_panel_test.html deleted file mode 100644 index 2ca6250b69e..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/side_panel/alerts_side_panel_test.html +++ /dev/null @@ -1,61 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/ui/extras/side_panel/alerts_side_panel.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var ALERT_INFO_1 = new tr.model.EventInfo( - 'Alert 1', 'Critical alert'); - var ALERT_INFO_2 = new tr.model.EventInfo( - 'Alert 2', 'Warning alert'); - - test('instantiate', function() { - var panel = document.createElement('tr-ui-e-s-alerts-side-panel'); - panel.model = createModelWithAlerts([ - new tr.model.Alert(ALERT_INFO_1, 5), - new tr.model.Alert(ALERT_INFO_2, 35) - ]); - panel.style.height = '100px'; - - this.addHTMLOutput(panel); - }); - - test('selectAlertsOfType', function() { - var panel = document.createElement('tr-ui-e-s-alerts-side-panel'); - var alerts = [ - new tr.model.Alert(ALERT_INFO_1, 1), - new tr.model.Alert(ALERT_INFO_1, 2), - new tr.model.Alert(ALERT_INFO_2, 3) - ]; - - var predicted_alerts = new tr.model.EventSet([alerts[0], alerts[1]]); - panel.model = createModelWithAlerts(alerts); - panel.style.height = '100px'; - this.addHTMLOutput(panel); - - var selectionChanged = false; - panel.addEventListener('requestSelectionChange', function(e) { - selectionChanged = true; - assert.isTrue(e.selection.equals(predicted_alerts)); - }); - panel.selectAlertsOfType(ALERT_INFO_1.title); - - assert.isTrue(selectionChanged); - }); - - function createModelWithAlerts(alerts) { - var m = new tr.Model(); - m.alerts = alerts; - return m; - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/side_panel/frame_data_side_panel.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/side_panel/frame_data_side_panel.html deleted file mode 100644 index ebaff275896..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/side_panel/frame_data_side_panel.html +++ /dev/null @@ -1,243 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright 2016 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/extras/chrome/blame_context/frame_tree_node.html"> -<link rel="import" href="/tracing/extras/chrome/blame_context/render_frame.html"> -<link rel="import" href="/tracing/extras/chrome/blame_context/top_level.html"> -<link rel="import" href="/tracing/model/helpers/chrome_model_helper.html"> -<link rel="import" href="/tracing/ui/base/table.html"> -<link rel="import" href="/tracing/ui/side_panel/side_panel.html"> -<link rel="import" href="/tracing/value/ui/scalar_span.html"> -<link rel="import" href="/tracing/value/unit.html"> - -<polymer-element name='tr-ui-e-s-frame-data-side-panel' - extends='tr-ui-side-panel'> - <template> - <style> - :host { - display: flex; - width: 600px; - flex-direction: column; - } - table-container { - display: flex; - overflow: auto; - } - </style> - <table-container> - <tr-ui-b-table id="table"></tr-ui-b-table> - </table-container> - </template> -</polymer-element> - -<script> -'use strict'; -tr.exportTo('tr.ui.e.s', function() { - var BlameContextSnapshot = tr.e.chrome.BlameContextSnapshot; - var FrameTreeNodeSnapshot = tr.e.chrome.FrameTreeNodeSnapshot; - var RenderFrameSnapshot = tr.e.chrome.RenderFrameSnapshot; - var TopLevelSnapshot = tr.e.chrome.TopLevelSnapshot; - - var BlameContextInstance = tr.e.chrome.BlameContextInstance; - var FrameTreeNodeInstance = tr.e.chrome.FrameTreeNodeInstance; - var RenderFrameInstance = tr.e.chrome.RenderFrameInstance; - var TopLevelInstance = tr.e.chrome.TopLevelInstance; - - /** - * @constructor - */ - function Row(context) { - this.type = context.objectInstance.blameContextType; - - this.contexts = [context]; - this.renderer = undefined; - if (context instanceof FrameTreeNodeSnapshot) { - if (context.renderFrame) { - this.contexts.push(context.renderFrame); - this.renderer = context.renderFrame.objectInstance.parent.pid; - } - } else if (context instanceof RenderFrameSnapshot) { - if (context.frameTreeNode) - this.contexts.push(context.frameTreeNode); - this.renderer = context.objectInstance.parent.pid; - } else if (context instanceof TopLevelSnapshot) { - this.renderer = context.objectInstance.parent.pid; - } else { - throw new Error('Unknown context type'); - } - - // TODO(xiaochengh): Handle the case where a subframe has a trivial url - // (e.g., about:blank), but inherits the origin of its parent. This is not - // needed now, but will be required if we want to group rows by origin. - this.url = context.url; - - // To be computed in batch later for efficiency. - this.eventsOfInterest = new tr.model.EventSet(this.contexts); - this.time = 0; - } - - Polymer('tr-ui-e-s-frame-data-side-panel', { - ready: function() { - this.model_ = undefined; - this.rangeOfInterest_ = new tr.b.Range(); - - // TODO(xiaochengh): Design proper grouping of the rows (by renderer - // pid, frame tree topology, site, ...) in a follow-up patch. - this.$.table.showHeader = true; - this.$.table.selectionMode = tr.ui.b.TableFormat.SelectionMode.ROW; - this.$.table.tableColumns = this.createFrameDataTableColumns_(); - - this.$.table.addEventListener('selection-changed', function(e) { - this.selectEventSet_(this.$.table.selectedTableRow.eventsOfInterest); - }.bind(this)); - }, - - selectEventSet_: function(eventSet) { - var event = new tr.model.RequestSelectionChangeEvent(); - event.selection = eventSet; - this.dispatchEvent(event); - }, - - createFrameDataTableColumns_: function() { - return [ - { - title: 'Renderer', - value: row => row.renderer, - cmp: (a, b) => a.renderer - b.renderer - }, - { - title: 'Type', - value: row => row.type - }, - // TODO(xiaochengh): Decide what details to show in the table: - // - URL seems necessary, but we may also want origin instead/both. - // - Distinguish between browser time and renderer time? - // - Distinguish between CPU time and wall clock time? - // - Memory? Network? ... - { - title: 'Time', - value: row => tr.v.ui.createScalarSpan(row.time, { - unit: tr.v.Unit.byName.timeStampInMs, - ownerDocument: this.ownerDocument - }), - cmp: (a, b) => a.time - b.time - }, - { - title: 'URL', - value: row => row.url, - cmp: (a, b) => (a.url || '').localeCompare(b.url || '') - } - ]; - }, - - createFrameDataTableRows_: function() { - if (!this.model_) - return []; - - // Gather contexts into skeletons of rows. - var rows = []; - var rowMap = {}; - tr.b.iterItems(this.model_.processes, function(pid, process) { - process.objects.iterObjectInstances(function(objectInstance) { - if (!(objectInstance instanceof BlameContextInstance)) - return; - objectInstance.snapshots.forEach(function(snapshot) { - if (rowMap[snapshot.guid]) - return; - var row = new Row(snapshot); - row.contexts.forEach(context => rowMap[context.guid] = row); - rows.push(row); - }, this); - }, this); - }, this); - - // Find slices attributed to each row. - // TODO(xiaochengh): We should implement a getter - // BlameContextSnapshot.attributedEvents, instead of process the model in - // a UI component. - tr.b.iterItems(this.model_.processes, function(pid, process) { - tr.b.iterItems(process.threads, function(tid, thread) { - thread.sliceGroup.iterSlicesInTimeRange(function(topLevelSlice) { - topLevelSlice.contexts.forEach(function(context) { - if (!context.snapshot.guid || !rowMap[context.snapshot.guid]) - return; - var row = rowMap[context.snapshot.guid]; - row.eventsOfInterest.push(topLevelSlice); - row.time += topLevelSlice.selfTime || 0; - }); - }, this.currentRangeOfInterest.min, this.currentRangeOfInterest.max); - }, this); - }, this); - - return rows; - }, - - updateContents_: function() { - this.$.table.tableRows = this.createFrameDataTableRows_(); - this.$.table.rebuild(); - }, - - supportsModel: function(m) { - if (!m) { - return { - supported: false, - reason: 'No model available.' - }; - } - - var ans = {supported: false}; - tr.b.iterItems(m.processes, function(pid, process) { - process.objects.iterObjectInstances(function(instance) { - if (instance instanceof BlameContextInstance) - ans.supported = true; - }); - }, this); - - if (!ans.supported) - ans.reason = 'No frame data available'; - return ans; - }, - - get currentRangeOfInterest() { - if (this.rangeOfInterest_.isEmpty) - return this.model_.bounds; - else - return this.rangeOfInterest_; - }, - - get rangeOfInterest() { - return this.rangeOfInterest_; - }, - - set rangeOfInterest(rangeOfInterest) { - this.rangeOfInterest_ = rangeOfInterest; - this.updateContents_(); - }, - - get selection() { - // Not applicable. - }, - - set selection(_) { - // Not applicable. - }, - - get textLabel() { - return 'Frame Data'; - }, - - get model() { - return this.model_; - }, - - set model(model) { - this.model_ = model; - this.updateContents_(); - } - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/side_panel/frame_data_side_panel_test.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/side_panel/frame_data_side_panel_test.html deleted file mode 100644 index c9ec9ff025b..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/side_panel/frame_data_side_panel_test.html +++ /dev/null @@ -1,165 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright 2016 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/extras/chrome/blame_context/frame_tree_node.html"> -<link rel="import" href="/tracing/extras/chrome/blame_context/render_frame.html"> -<link rel="import" href="/tracing/extras/chrome/blame_context/top_level.html"> -<link rel="import" href="/tracing/ui/extras/side_panel/frame_data_side_panel.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var TestUtils = tr.c.TestUtils; - - function topLevelOptions(pid, id) { - return { - pid: pid, - id: id, - cat: 'blink', - scope: 'PlatformThread', - name: 'TopLevel' - }; - } - - function renderFrameOptions(pid, id, parent) { - return { - pid: pid, - id: id, - cat: 'blink', - scope: 'RenderFrame', - name: 'RenderFrame', - args: {parent: { - id_ref: parent.id, - scope: parent.scope - }} - }; - } - - function frameTreeNodeOptions(pid, id, opt_renderFrame, opt_parentId) { - var ans = { - pid: pid, - id: id, - cat: 'navigation', - scope: 'FrameTreeNode', - name: 'FrameTreeNode', - args: {} - }; - if (opt_renderFrame) { - ans.args.renderFrame = { - id_ref: opt_renderFrame.id, - pid_ref: opt_renderFrame.pid, - scope: 'RenderFrame' - }; - } - if (opt_parentId) { - ans.args.parent = { - id_ref: opt_parentId, - scope: 'FrameTreeNode' - }; - } - return ans; - } - - /** - * Creates some independent contexts. Checks if all are present in the panel. - */ - test('basic', function() { - var panel = document.createElement('tr-ui-e-s-frame-data-side-panel'); - panel.model = TestUtils.newModel(function(model) { - TestUtils.newSnapshot(model, topLevelOptions(1, '0x1')); - TestUtils.newSnapshot(model, renderFrameOptions( - 1, '0x2', {id: '0x1', scope: 'PlatformThread'})); - TestUtils.newSnapshot(model, frameTreeNodeOptions( - 2, '0x3')); - }); - assert.lengthOf(panel.$.table.tableRows, 3); - - this.addHTMLOutput(panel); - }); - - /** - * Creates a FrameTreeNode in the browser process and a RenderFrame in a - * renderer process that are the same frame. Checks if they are merged into - * one row in the panel. - */ - test('mergeCrossProcessFrameBlameContexts', function() { - var panel = document.createElement('tr-ui-e-s-frame-data-side-panel'); - panel.model = TestUtils.newModel(function(model) { - TestUtils.newSnapshot(model, topLevelOptions(1, '0x1')); - TestUtils.newSnapshot(model, renderFrameOptions( - 1, '0x2', {id: '0x1', scope: 'PlatformThread'})); - TestUtils.newSnapshot(model, frameTreeNodeOptions( - 2, '0x3', {id: '0x2', pid: 1})); - }); - assert.lengthOf(panel.$.table.tableRows, 2); - - this.addHTMLOutput(panel); - }); - - function newAttributedSlice(model, pid, start, duration, context) { - var slice = TestUtils.newSliceEx({start: start, duration: duration}); - slice.contexts = [{type: 'FrameBlameContext', snapshot: context}]; - model.getOrCreateProcess(pid).getOrCreateThread(1).sliceGroup.pushSlice( - slice); - return slice; - } - - /** - * Changes the range of interest. Checks if the panel updates correspondingly. - */ - test('respondToRangeOfInterest', function() { - var topLevel; - var slice1; - var slice2; - var panel = document.createElement('tr-ui-e-s-frame-data-side-panel'); - panel.model = TestUtils.newModel(function(model) { - topLevel = TestUtils.newSnapshot(model, topLevelOptions(1, '0x1')); - slice1 = newAttributedSlice(model, 1, 1500, 500, topLevel); - slice2 = newAttributedSlice(model, 1, 2500, 500, topLevel); - }); - - // The default range of interest contains both slices. - assert.isTrue(panel.$.table.tableRows[0].eventsOfInterest.equals( - new tr.model.EventSet([topLevel, slice1, slice2]))); - - // The new range of interest contains only slice2. - panel.rangeOfInterest = tr.b.Range.fromExplicitRange(slice2.start, - slice2.end); - assert.isTrue(panel.$.table.tableRows[0].eventsOfInterest.equals( - new tr.model.EventSet([topLevel, slice2]))); - - this.addHTMLOutput(panel); - }); - - /** - * Selects a row in the panel. Checks if the context(s) of the row and the - * slices attributed to the row are selected. - */ - test('selectAttributedEvents', function() { - var topLevel; - var slice; - var panel = document.createElement('tr-ui-e-s-frame-data-side-panel'); - panel.model = TestUtils.newModel(function(model) { - topLevel = TestUtils.newSnapshot(model, topLevelOptions(1, '0x1')); - slice = newAttributedSlice(model, 1, 1500, 500, topLevel); - }); - - var selectionChanged = false; - panel.addEventListener('requestSelectionChange', function(e) { - selectionChanged = true; - assert.isTrue( - e.selection.equals(new tr.model.EventSet([topLevel, slice]))); - }); - panel.$.table.selectedTableRow = panel.$.table.tableRows[0]; - assert.isTrue(selectionChanged); - - this.addHTMLOutput(panel); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/side_panel/input_latency_side_panel.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/side_panel/input_latency_side_panel.html deleted file mode 100644 index 4b3a9a5917b..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/side_panel/input_latency_side_panel.html +++ /dev/null @@ -1,326 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/statistics.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/model/helpers/chrome_model_helper.html"> -<link rel="import" href="/tracing/ui/base/dom_helpers.html"> -<link rel="import" href="/tracing/ui/base/line_chart.html"> -<link rel="import" href="/tracing/ui/side_panel/side_panel.html"> - -<polymer-element name='tr-ui-e-s-input-latency-side-panel' - extends='tr-ui-side-panel'> - <template> - <style> - :host { - flex-direction: column; - display: flex; - } - toolbar { - flex: 0 0 auto; - border-bottom: 1px solid black; - display: flex; - } - result-area { - flex: 1 1 auto; - display: block; - min-height: 0; - overflow-y: auto; - } - </style> - - <toolbar id='toolbar'></toolbar> - <result-area id='result_area'></result-area> - </template> - - <script> - 'use strict'; - - Polymer({ - ready: function() { - this.rangeOfInterest_ = new tr.b.Range(); - this.frametimeType_ = tr.model.helpers.IMPL_FRAMETIME_TYPE; - this.latencyChart_ = undefined; - this.frametimeChart_ = undefined; - this.selectedProcessId_ = undefined; - this.mouseDownIndex_ = undefined; - this.curMouseIndex_ = undefined; - }, - - get model() { - return this.model_; - }, - - set model(model) { - this.model_ = model; - if (this.model_) { - this.modelHelper_ = this.model_.getOrCreateHelper( - tr.model.helpers.ChromeModelHelper); - } else { - this.modelHelper_ = undefined; - } - - this.updateToolbar_(); - this.updateContents_(); - }, - - get frametimeType() { - return this.frametimeType_; - }, - - set frametimeType(type) { - if (this.frametimeType_ === type) - return; - this.frametimeType_ = type; - this.updateContents_(); - }, - - get selectedProcessId() { - return this.selectedProcessId_; - }, - - set selectedProcessId(process) { - if (this.selectedProcessId_ === process) - return; - this.selectedProcessId_ = process; - this.updateContents_(); - }, - - set selection(selection) { - if (this.latencyChart_ === undefined) - return; - this.latencyChart_.brushedRange = selection.bounds; - }, - - // This function is for testing purpose. - setBrushedIndices: function(mouseDownIndex, curIndex) { - this.mouseDownIndex_ = mouseDownIndex; - this.curMouseIndex_ = curIndex; - this.updateBrushedRange_(); - }, - - updateBrushedRange_: function() { - if (this.latencyChart_ === undefined) - return; - - var r = new tr.b.Range(); - if (this.mouseDownIndex_ === undefined) { - this.latencyChart_.brushedRange = r; - return; - } - r = this.latencyChart_.computeBrushRangeFromIndices( - this.mouseDownIndex_, this.curMouseIndex_); - this.latencyChart_.brushedRange = r; - - // Based on the brushed range, update the selection of LatencyInfo in - // the timeline view by sending a selectionChange event. - var latencySlices = []; - for (var thread of this.model_.getAllThreads()) - for (var event of thread.getDescendantEvents()) - if (event.title.indexOf('InputLatency:') === 0) - latencySlices.push(event); - latencySlices = tr.model.helpers.getSlicesIntersectingRange( - r, latencySlices); - - var event = new tr.model.RequestSelectionChangeEvent(); - event.selection = new tr.model.EventSet(latencySlices); - this.latencyChart_.dispatchEvent(event); - }, - - registerMouseEventForLatencyChart_: function() { - this.latencyChart_.addEventListener('item-mousedown', function(e) { - this.mouseDownIndex_ = e.index; - this.curMouseIndex_ = e.index; - this.updateBrushedRange_(); - }.bind(this)); - - this.latencyChart_.addEventListener('item-mousemove', function(e) { - if (e.button == undefined) - return; - this.curMouseIndex_ = e.index; - this.updateBrushedRange_(); - }.bind(this)); - - this.latencyChart_.addEventListener('item-mouseup', function(e) { - this.curMouseIndex = e.index; - this.updateBrushedRange_(); - }.bind(this)); - }, - - updateToolbar_: function() { - var browserProcess = this.modelHelper_.browserProcess; - var labels = []; - - if (browserProcess !== undefined) { - var label_str = 'Browser: ' + browserProcess.pid; - labels.push({label: label_str, value: browserProcess.pid}); - } - - tr.b.iterItems(this.modelHelper_.rendererHelpers, - function(pid, rendererHelper) { - var rendererProcess = rendererHelper.process; - var label_str = 'Renderer: ' + rendererProcess.userFriendlyName; - labels.push({label: label_str, value: rendererProcess.userFriendlyName - }); - }, this); - - if (labels.length === 0) - return; - - this.selectedProcessId_ = labels[0].value; - var toolbarEl = this.$.toolbar; - toolbarEl.appendChild(tr.ui.b.createSelector( - this, 'frametimeType', - 'inputLatencySidePanel.frametimeType', this.frametimeType_, - [{label: 'Main Thread Frame Times', - value: tr.model.helpers.MAIN_FRAMETIME_TYPE}, - {label: 'Impl Thread Frame Times', - value: tr.model.helpers.IMPL_FRAMETIME_TYPE} - ])); - toolbarEl.appendChild(tr.ui.b.createSelector( - this, 'selectedProcessId', - 'inputLatencySidePanel.selectedProcessId', - this.selectedProcessId_, - labels)); - }, - - get currentRangeOfInterest() { - if (this.rangeOfInterest_.isEmpty) - return this.model_.bounds; - else - return this.rangeOfInterest_; - }, - - createLatencyLineChart: function(data, title) { - var chart = new tr.ui.b.LineChart(); - var width = 600; - if (document.body.clientWidth != undefined) - width = document.body.clientWidth * 0.5; - chart.setSize({width: width, height: chart.height}); - chart.chartTitle = title; - chart.data = data; - return chart; - }, - - updateContents_: function() { - var resultArea = this.$.result_area; - this.latencyChart_ = undefined; - this.frametimeChart_ = undefined; - resultArea.textContent = ''; - - if (this.modelHelper_ === undefined) - return; - - var rangeOfInterest = this.currentRangeOfInterest; - - var chromeProcess; - if (this.modelHelper_.rendererHelpers[this.selectedProcessId_]) - chromeProcess = this.modelHelper_.rendererHelpers[ - this.selectedProcessId_ - ]; - else - chromeProcess = this.modelHelper_.browserHelper; - - var frameEvents = chromeProcess.getFrameEventsInRange( - this.frametimeType, rangeOfInterest); - - var frametimeData = tr.model.helpers.getFrametimeDataFromEvents( - frameEvents); - var averageFrametime = tr.b.Statistics.mean(frametimeData, function(d) { - return d.frametime; - }); - - var latencyEvents = this.modelHelper_.browserHelper. - getLatencyEventsInRange( - rangeOfInterest); - - var latencyData = []; - latencyEvents.forEach(function(event) { - if (event.inputLatency === undefined) - return; - latencyData.push({ - x: event.start, - latency: event.inputLatency / 1000 - }); - }); - - var averageLatency = tr.b.Statistics.mean(latencyData, function(d) { - return d.latency; - }); - - // Create summary. - var latencySummaryText = document.createElement('div'); - latencySummaryText.appendChild(tr.ui.b.createSpan({ - textContent: 'Average Latency ' + averageLatency + ' ms', - bold: true})); - resultArea.appendChild(latencySummaryText); - - var frametimeSummaryText = document.createElement('div'); - frametimeSummaryText.appendChild(tr.ui.b.createSpan({ - textContent: 'Average Frame Time ' + averageFrametime + ' ms', - bold: true})); - resultArea.appendChild(frametimeSummaryText); - - if (latencyData.length !== 0) { - this.latencyChart_ = this.createLatencyLineChart( - latencyData, 'Latency Over Time'); - this.registerMouseEventForLatencyChart_(); - resultArea.appendChild(this.latencyChart_); - } - - if (frametimeData.length != 0) { - this.frametimeChart_ = this.createLatencyLineChart( - frametimeData, 'Frame Times'); - resultArea.appendChild(this.frametimeChart_); - } - }, - - get rangeOfInterest() { - return this.rangeOfInterest_; - }, - - set rangeOfInterest(rangeOfInterest) { - this.rangeOfInterest_ = rangeOfInterest; - this.updateContents_(); - }, - - supportsModel: function(m) { - if (m == undefined) { - return { - supported: false, - reason: 'Unknown tracing model' - }; - } - - if (!tr.model.helpers.ChromeModelHelper.supportsModel(m)) { - return { - supported: false, - reason: 'No Chrome browser or renderer process found' - }; - } - - var modelHelper = m.getOrCreateHelper(tr.model.helpers.ChromeModelHelper); - if (modelHelper.browserHelper && - modelHelper.browserHelper.hasLatencyEvents) { - return { - supported: true - }; - } - - return { - supported: false, - reason: 'No InputLatency events trace. Consider enabling ' + - 'benchmark" and "input" category when recording the trace' - }; - }, - - get textLabel() { - return 'Input Latency'; - } - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/side_panel/input_latency_side_panel_test.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/side_panel/input_latency_side_panel_test.html deleted file mode 100644 index 51021bd4aa3..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/side_panel/input_latency_side_panel_test.html +++ /dev/null @@ -1,143 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/extras/chrome/cc/input_latency_async_slice.html"> -<link rel="import" href="/tracing/extras/importer/trace_event_importer.html"> -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/ui/extras/side_panel/input_latency_side_panel.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - test('basic', function() { - var latencyData = [ - { - x: 1000, - latency: 16 - }, - { - x: 2000, - latency: 17 - }, - { - x: 3000, - latency: 14 - }, - { - x: 4000, - latency: 23 - } - ]; - var lc = document.createElement('tr-ui-e-s-input-latency-side-panel'); - var latencyChart = lc.createLatencyLineChart(latencyData, 'latency'); - this.addHTMLOutput(latencyChart); - - var frametimeData = [ - { - x: 1000, - frametime: 16 - }, - { - x: 2000, - frametime: 17 - }, - { - x: 3000, - frametime: 14 - }, - { - x: 4000, - frametime: 23 - } - ]; - var lc = document.createElement('tr-ui-e-s-input-latency-side-panel'); - var frametimeChart = lc.createLatencyLineChart(frametimeData, 'frametime'); - this.addHTMLOutput(frametimeChart); - }); - - test('brushedRangeChange', function() { - var events = []; - for (var i = 0; i < 10; i++) { - var start_ts = i * 10000; - var end_ts = start_ts + 1000 * (i % 2); - events.push( - { - 'cat': 'benchmark', - 'pid': 3507, - 'tid': 3507, - 'ts': start_ts, - 'ph': 'S', - 'name': 'InputLatency', - 'id': i - }); - events.push( - { - 'cat': 'benchmark', - 'pid': 3507, - 'tid': 3507, - 'ts': end_ts, - 'ph': 'T', - 'name': 'InputLatency', - 'args': {'step': 'GestureScrollUpdate'}, - 'id': i - }); - events.push( - { - 'cat': 'benchmark', - 'pid': 3507, - 'tid': 3507, - 'ts': end_ts, - 'ph': 'F', - 'name': 'InputLatency', - 'args': { - 'data': { - 'INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT': { - 'time': start_ts - }, - 'INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT': { - 'time': end_ts - } - } - }, - 'id': i - }); - } - events.push({'cat': '__metadata', - 'pid': 3507, - 'tid': 3507, - 'ts': 0, - 'ph': 'M', - 'name': 'thread_name', - 'args': {'name': 'CrBrowserMain'}}); - - var panel = document.createElement('tr-ui-e-s-input-latency-side-panel'); - this.addHTMLOutput(panel); - - var selectionChanged = false; - - panel.model = tr.c.TestUtils.newModelWithEvents([events]); - function listener(e) { - selectionChanged = true; - assert.equal(e.selection.length, 3); - var predictedStarts = [20, 31, 40]; - var i = 0; - for (var event of e.selection) - assert.equal(event.start, predictedStarts[i++]); - } - panel.ownerDocument.addEventListener('requestSelectionChange', listener); - try { - panel.setBrushedIndices(2, 4); - } finally { - panel.ownerDocument.removeEventListener( - 'requestSelectionChange', listener); - } - assert.isTrue(selectionChanged); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/side_panel/time_summary_side_panel.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/side_panel/time_summary_side_panel.html deleted file mode 100644 index a0b6d9df6b6..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/side_panel/time_summary_side_panel.html +++ /dev/null @@ -1,438 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/iteration_helpers.html"> -<link rel="import" href="/tracing/base/statistics.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/ui/base/dom_helpers.html"> -<link rel="import" href="/tracing/ui/base/pie_chart.html"> -<link rel="import" href="/tracing/ui/side_panel/side_panel.html"> -<link rel="import" href="/tracing/value/ui/scalar_span.html"> -<link rel="import" href="/tracing/value/unit.html"> - -<polymer-element name="tr-ui-e-s-time-summary-side-panel" - extends="tr-ui-side-panel"> - <template> - <style> - :host { - flex-direction: column; - display: flex; - } - toolbar { - flex: 0 0 auto; - border-bottom: 1px solid black; - display: flex; - } - result-area { - flex: 1 1 auto; - display: block; - min-height: 0; - overflow-y: auto; - } - </style> - - <toolbar id='toolbar'></toolbar> - <result-area id='result_area'></result-area> - </template> - - <script> - 'use strict'; - (function() { - var GROUP_BY_PROCESS_NAME = 'process'; - var GROUP_BY_THREAD_NAME = 'thread'; - - var WALL_TIME_GROUPING_UNIT = 'Wall time'; - var CPU_TIME_GROUPING_UNIT = 'CPU time'; - - /** - * @constructor - */ - function ResultsForGroup(model, name) { - this.model = model; - this.name = name; - this.topLevelSlices = []; - this.allSlices = []; - } - - ResultsForGroup.prototype = { - get wallTime() { - var wallSum = tr.b.Statistics.sum( - this.topLevelSlices, function(x) { return x.duration; }); - return wallSum; - }, - - get cpuTime() { - var cpuDuration = 0; - for (var i = 0; i < this.topLevelSlices.length; i++) { - var x = this.topLevelSlices[i]; - // Only report thread-duration if we have it for all events. - // - // A thread_duration of 0 is valid, so this only returns 0 if it is - // None. - if (x.cpuDuration === undefined) { - if (x.duration === undefined) - continue; - return 0; - } - cpuDuration += x.cpuDuration; - } - return cpuDuration; - }, - - appendGroupContents: function(group) { - if (group.model != this.model) - throw new Error('Models must be the same'); - - group.allSlices.forEach(function(slice) { - this.allSlices.push(slice); - }, this); - group.topLevelSlices.forEach(function(slice) { - this.topLevelSlices.push(slice); - }, this); - }, - - appendThreadSlices: function(rangeOfInterest, thread) { - var tmp = this.getSlicesIntersectingRange( - rangeOfInterest, thread.sliceGroup.slices); - tmp.forEach(function(slice) { - this.allSlices.push(slice); - }, this); - tmp = this.getSlicesIntersectingRange( - rangeOfInterest, thread.sliceGroup.topLevelSlices); - tmp.forEach(function(slice) { - this.topLevelSlices.push(slice); - }, this); - }, - - getSlicesIntersectingRange: function(rangeOfInterest, slices) { - var slicesInFilterRange = []; - for (var i = 0; i < slices.length; i++) { - var slice = slices[i]; - if (rangeOfInterest.intersectsExplicitRangeInclusive( - slice.start, slice.end)) - slicesInFilterRange.push(slice); - } - return slicesInFilterRange; - } - }; - - Polymer({ - ready: function() { - this.rangeOfInterest_ = new tr.b.Range(); - this.selection_ = undefined; - this.groupBy_ = GROUP_BY_PROCESS_NAME; - this.groupingUnit_ = CPU_TIME_GROUPING_UNIT; - this.showCpuIdleTime_ = true; - this.chart_ = undefined; - - var toolbarEl = this.$.toolbar; - this.groupBySelector_ = tr.ui.b.createSelector( - this, 'groupBy', - 'timeSummarySidePanel.groupBy', this.groupBy_, - [{label: 'Group by process', value: GROUP_BY_PROCESS_NAME}, - {label: 'Group by thread', value: GROUP_BY_THREAD_NAME} - ]); - toolbarEl.appendChild(this.groupBySelector_); - - this.groupingUnitSelector_ = tr.ui.b.createSelector( - this, 'groupingUnit', - 'timeSummarySidePanel.groupingUnit', this.groupingUnit_, - [{label: 'Wall time', value: WALL_TIME_GROUPING_UNIT}, - {label: 'CPU time', value: CPU_TIME_GROUPING_UNIT} - ]); - toolbarEl.appendChild(this.groupingUnitSelector_); - - this.showCpuIdleTimeCheckbox_ = tr.ui.b.createCheckBox( - this, 'showCpuIdleTime', - 'timeSummarySidePanel.showCpuIdleTime', this.showCpuIdleTime_, - 'Show CPU idle time'); - toolbarEl.appendChild(this.showCpuIdleTimeCheckbox_); - this.updateShowCpuIdleTimeCheckboxVisibility_(); - }, - - /** - * This function takes an array of groups and merges smaller groups into - * the provided 'Other' group item such that the remaining items are ready - * for pie-chart consumption. Otherwise, the pie chart gets overwhelmed - * with tons of little slices. - */ - trimPieChartData: function(groups, otherGroup, getValue, opt_extraValue) { - // Copy the array so it can be mutated. - groups = groups.filter(function(d) { - return getValue(d) != 0; - }); - - // Figure out total array range. - var sum = tr.b.Statistics.sum(groups, getValue); - if (opt_extraValue !== undefined) - sum += opt_extraValue; - - // Sort by value. - function compareByValue(a, b) { - return getValue(a) - getValue(b); - } - groups.sort(compareByValue); - - // Now start fusing elements until none are less than threshold in size. - var thresshold = 0.1 * sum; - while (groups.length > 1) { - var group = groups[0]; - if (getValue(group) >= thresshold) - break; - - var v = getValue(group); - if (v + getValue(otherGroup) > thresshold) - break; - - // Remove the group from the list and add it to the 'Other' group. - groups.splice(0, 1); - otherGroup.appendGroupContents(group); - } - - // Final return. - if (getValue(otherGroup) > 0) - groups.push(otherGroup); - - groups.sort(compareByValue); - - return groups; - }, - - generateResultsForGroup: function(model, name) { - return new ResultsForGroup(model, name); - }, - - createPieChartFromResultGroups: function( - groups, title, getValue, opt_extraData) { - var chart = new tr.ui.b.PieChart(); - - function pushDataForGroup(data, resultsForGroup, value) { - data.push({ - label: resultsForGroup.name, - value: value, - valueText: tr.v.Unit.byName.timeDurationInMs.format(value), - resultsForGroup: resultsForGroup - }); - } - chart.addEventListener('item-click', function(clickEvent) { - var resultsForGroup = clickEvent.data.resultsForGroup; - if (resultsForGroup === undefined) - return; - - var event = new tr.model.RequestSelectionChangeEvent(); - event.selection = new tr.model.EventSet(resultsForGroup.allSlices); - event.selection.timeSummaryGroupName = resultsForGroup.name; - chart.dispatchEvent(event); - }); - - - // Build chart data. - var data = []; - groups.forEach(function(resultsForGroup) { - var value = getValue(resultsForGroup); - if (value === 0) - return; - pushDataForGroup(data, resultsForGroup, value); - }); - if (opt_extraData) - data.push.apply(data, opt_extraData); - - chart.chartTitle = title; - chart.data = data; - return chart; - }, - - get model() { - return this.model_; - }, - - set model(model) { - this.model_ = model; - this.updateContents_(); - }, - - get groupBy() { - return groupBy_; - }, - - set groupBy(groupBy) { - this.groupBy_ = groupBy; - if (this.groupBySelector_) - this.groupBySelector_.selectedValue = groupBy; - this.updateContents_(); - }, - - get groupingUnit() { - return groupingUnit_; - }, - - set groupingUnit(groupingUnit) { - this.groupingUnit_ = groupingUnit; - if (this.groupingUnitSelector_) - this.groupingUnitSelector_.selectedValue = groupingUnit; - this.updateShowCpuIdleTimeCheckboxVisibility_(); - this.updateContents_(); - }, - - get showCpuIdleTime() { - return this.showCpuIdleTime_; - }, - - set showCpuIdleTime(showCpuIdleTime) { - this.showCpuIdleTime_ = showCpuIdleTime; - if (this.showCpuIdleTimeCheckbox_) - this.showCpuIdleTimeCheckbox_.checked = showCpuIdleTime; - this.updateContents_(); - }, - - updateShowCpuIdleTimeCheckboxVisibility_: function() { - if (!this.showCpuIdleTimeCheckbox_) - return; - var visible = this.groupingUnit_ == CPU_TIME_GROUPING_UNIT; - if (visible) - this.showCpuIdleTimeCheckbox_.style.display = ''; - else - this.showCpuIdleTimeCheckbox_.style.display = 'none'; - }, - - getGroupNameForThread_: function(thread) { - if (this.groupBy_ == GROUP_BY_THREAD_NAME) - return thread.name ? thread.name : thread.userFriendlyName; - - if (this.groupBy_ == GROUP_BY_PROCESS_NAME) - return thread.parent.userFriendlyName; - }, - - updateContents_: function() { - var resultArea = this.$.result_area; - this.chart_ = undefined; - resultArea.textContent = ''; - - if (this.model_ === undefined) - return; - - var rangeOfInterest; - if (this.rangeOfInterest_.isEmpty) - rangeOfInterest = this.model_.bounds; - else - rangeOfInterest = this.rangeOfInterest_; - - var allGroup = this.generateResultsForGroup(this.model_, 'all'); - var resultsByGroupName = {}; - this.model_.getAllThreads().forEach(function(thread) { - var groupName = this.getGroupNameForThread_(thread); - if (resultsByGroupName[groupName] === undefined) { - resultsByGroupName[groupName] = this.generateResultsForGroup( - this.model_, groupName); - } - resultsByGroupName[groupName].appendThreadSlices( - rangeOfInterest, thread); - - allGroup.appendThreadSlices(rangeOfInterest, thread); - }, this); - - // Helper function for working with the produced group. - var getValueFromGroup = function(group) { - if (this.groupingUnit_ == WALL_TIME_GROUPING_UNIT) - return group.wallTime; - return group.cpuTime; - }.bind(this); - - // Create summary. - var summaryText = document.createElement('div'); - summaryText.appendChild(tr.ui.b.createSpan({ - textContent: 'Total ' + this.groupingUnit_ + ': ', - bold: true})); - summaryText.appendChild(tr.v.ui.createScalarSpan( - getValueFromGroup(allGroup), { - unit: tr.v.Unit.byName.timeDurationInMs, - ownerDocument: this.ownerDocument - })); - resultArea.appendChild(summaryText); - - // If needed, add in the idle time. - var extraValue = 0; - var extraData = []; - if (this.showCpuIdleTime_ && - this.groupingUnit_ === CPU_TIME_GROUPING_UNIT && - this.model.kernel.bestGuessAtCpuCount !== undefined) { - var maxCpuTime = rangeOfInterest.range * - this.model.kernel.bestGuessAtCpuCount; - var idleTime = Math.max(0, maxCpuTime - allGroup.cpuTime); - extraData.push({ - label: 'CPU Idle', - value: idleTime, - valueText: tr.v.Unit.byName.timeDurationInMs.format(idleTime) - }); - extraValue += idleTime; - } - - // Create the actual chart. - var otherGroup = this.generateResultsForGroup(this.model_, 'Other'); - var groups = this.trimPieChartData( - tr.b.dictionaryValues(resultsByGroupName), - otherGroup, - getValueFromGroup, - extraValue); - - if (groups.length == 0) { - resultArea.appendChild(tr.ui.b.createSpan({textContent: 'No data'})); - return undefined; - } - - this.chart_ = this.createPieChartFromResultGroups( - groups, - this.groupingUnit_ + ' breakdown by ' + this.groupBy_, - getValueFromGroup, extraData); - resultArea.appendChild(this.chart_); - - this.chart_.addEventListener('click', function() { - var event = new tr.model.RequestSelectionChangeEvent(); - event.selection = new tr.c.EventSet([]); - this.dispatchEvent(event); - }); - this.chart_.setSize(this.chart_.getMinSize()); - }, - - get selection() { - return selection_; - }, - - set selection(selection) { - this.selection_ = selection; - - if (this.chart_ === undefined) - return; - - if (selection.timeSummaryGroupName) - this.chart_.highlightedLegendKey = selection.timeSummaryGroupName; - else - this.chart_.highlightedLegendKey = undefined; - }, - - get rangeOfInterest() { - return this.rangeOfInterest_; - }, - - set rangeOfInterest(rangeOfInterest) { - this.rangeOfInterest_ = rangeOfInterest; - this.updateContents_(); - }, - - supportsModel: function(model) { - return { - supported: false - }; - }, - - get textLabel() { - return 'Time Summary'; - } - }); - }()); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/side_panel/time_summary_side_panel_test.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/side_panel/time_summary_side_panel_test.html deleted file mode 100644 index 789093fd9b1..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/side_panel/time_summary_side_panel_test.html +++ /dev/null @@ -1,206 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/ui/extras/side_panel/time_summary_side_panel.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - function createModel(opt_options) { - var options = opt_options || {}; - var m = tr.c.TestUtils.newModelWithEvents([], { - shiftWorldToZero: false, - pruneContainers: false, - customizeModelCallback: function(m) { - if (options.provideSoftwareMeasuredCpuCount) - m.kernel.softwareMeasuredCpuCount = 2; - - var browserProcess = m.getOrCreateProcess(1); - var browserMain = browserProcess.getOrCreateThread(2); - browserMain.name = 'CrBrowserMain'; - browserMain.sliceGroup.beginSlice('cat', 'Task', 0, undefined, 0); - browserMain.sliceGroup.endSlice(10, 9); - browserMain.sliceGroup.beginSlice('cat', 'Task', 20, undefined, 10); - browserMain.sliceGroup.endSlice(30, 20); - - var rendererProcess = m.getOrCreateProcess(4); - var rendererMain = rendererProcess.getOrCreateThread(5); - rendererMain.name = 'CrRendererMain'; - rendererMain.sliceGroup.beginSlice('cat', 'Task', 0, undefined, 0); - rendererMain.sliceGroup.endSlice(30, 25); - rendererMain.sliceGroup.beginSlice('cat', 'Task', 40, undefined, 40); - rendererMain.sliceGroup.endSlice(60, 50); - } - }); - return m; - } - - test('group', function() { - var ts = document.createElement('tr-ui-e-s-time-summary-side-panel'); - var m = createModel(); - var group = ts.generateResultsForGroup(m, 'foo'); - group.appendThreadSlices(m.bounds, m.processes[1].threads[2]); - assert.equal(group.wallTime, 20); - assert.equal(group.cpuTime, 19); - }); - - test('trim', function() { - var groupData = [ - { - value: 2.854999999999997, - label: '156959' - }, - { - value: 9.948999999999998, - label: '16131' - }, - { - value: 42.314000000000725, - label: '51511' - }, - { - value: 31.06900000000028, - label: 'AudioOutputDevice' - }, - { - value: 1.418, - label: 'BrowserBlockingWorker2/50951' - }, - { - value: 0.044, - label: 'BrowserBlockingWorker3/50695' - }, - { - value: 18.52599999999993, - label: 'Chrome_ChildIOThread' - }, - { - value: 2.888, - label: 'Chrome_FileThread' - }, - { - value: 0.067, - label: 'Chrome_HistoryThread' - }, - { - value: 25.421000000000046, - label: 'Chrome_IOThread' - }, - { - value: 0.019, - label: 'Chrome_ProcessLauncherThread' - }, - { - value: 643.087999999995, - label: 'Compositor' - }, - { - value: 4.049999999999973, - label: 'CompositorRasterWorker1/22031' - }, - { - value: 50.040000000000106, - label: 'CrBrowserMain' - }, - { - value: 1256.5130000000042, - label: 'CrGpuMain' - }, - { - value: 5502.19499999999, - label: 'CrRendererMain' - }, - { - value: 15.552999999999862, - label: 'FFmpegDemuxer' - }, - { - value: 63.706000000001524, - label: 'Media' - }, - { - value: 2.7419999999999987, - label: 'PowerSaveBlocker' - }, - { - value: 0.11500000000000005, - label: 'Watchdog' - } - ]; - - var ts = document.createElement('tr-ui-e-s-time-summary-side-panel'); - - var groups = []; - var m = tr.c.TestUtils.newModelWithEvents([], { - shiftWorldToZero: false, - pruneContainers: false, - customizeModelCallback: function(m) { - var start = 0; - groupData.forEach(function(groupData) { - var group = ts.generateResultsForGroup(m, groupData.label); - - var slice = tr.c.TestUtils.newSliceEx( - {title: groupData.label, - start: start, duration: groupData.value}); - start += groupData.value; - group.allSlices.push(slice); - group.topLevelSlices.push(slice); - - groups.push(group); - }); - } - }); - - function getValueFromGroup(d) { return d.wallTime; } - - var otherGroup = ts.generateResultsForGroup(m, 'Other'); - var newGroups = ts.trimPieChartData(groups, otherGroup, getValueFromGroup); - - // Visualize the data once its trimmed. - var ce = document.createElement('tr-ui-e-s-time-summary-side-panel'); - var chart = ce.createPieChartFromResultGroups( - newGroups, 'Trimmed', getValueFromGroup); - this.addHTMLOutput(chart); - chart.setSize(chart.getMinSize()); - }); - - test('basicInWallTimeMode', function() { - var m = createModel(); - - var panel = document.createElement('tr-ui-e-s-time-summary-side-panel'); - this.addHTMLOutput(panel); - panel.model = m; - panel.groupingUnit = 'Wall time'; - panel.style.border = '1px solid black'; - }); - - test('basicInCpuTimeModeButNoCpuData', function() { - var m = createModel(); - - var panel = document.createElement('tr-ui-e-s-time-summary-side-panel'); - this.addHTMLOutput(panel); - panel.model = m; - panel.groupingUnit = 'CPU time'; - panel.style.border = '1px solid black'; - }); - - test('basicInCpuTimeModeAndCpuData', function() { - var m = createModel({ - provideSoftwareMeasuredCpuCount: true - }); - - var panel = document.createElement('tr-ui-e-s-time-summary-side-panel'); - this.addHTMLOutput(panel); - panel.model = m; - panel.groupingUnit = 'CPU time'; - panel.style.border = '1px solid black'; - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/system_stats/system_stats.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/system_stats/system_stats.html deleted file mode 100644 index 97562f96419..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/system_stats/system_stats.html +++ /dev/null @@ -1,12 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/extras/system_stats/system_stats_snapshot.html"> -<link rel="import" - href="/tracing/ui/extras/system_stats/system_stats_snapshot_view.html"> -<link rel="import" - href="/tracing/ui/extras/system_stats/system_stats_instance_track.html"> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/system_stats/system_stats_instance_track.css b/chromium/third_party/catapult/tracing/tracing/ui/extras/system_stats/system_stats_instance_track.css deleted file mode 100644 index 40096f5497c..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/system_stats/system_stats_instance_track.css +++ /dev/null @@ -1,15 +0,0 @@ -/* Copyright (c) 2013 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -.tr-ui-e-system-stats-instance-track { - height: 500px; -} - -.tr-ui-e-system-stats-instance-track ul { - list-style: none; - list-style-position: outside; - margin: 0; - overflow: hidden; -} diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/system_stats/system_stats_instance_track.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/system_stats/system_stats_instance_track.html deleted file mode 100644 index 9aa10212de6..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/system_stats/system_stats_instance_track.html +++ /dev/null @@ -1,355 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="stylesheet" - href="/tracing/ui/extras/system_stats/system_stats_instance_track.css"> - -<link rel="import" href="/tracing/base/sorted_array_utils.html"> -<link rel="import" href="/tracing/ui/tracks/stacked_bars_track.html"> -<link rel="import" href="/tracing/ui/tracks/object_instance_track.html"> -<link rel="import" href="/tracing/ui/base/event_presenter.html"> -<link rel="import" href="/tracing/ui/base/ui.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.e.system_stats', function() { - var EventPresenter = tr.ui.b.EventPresenter; - - var statCount; - - var excludedStats = {'meminfo': { - 'pswpin': 0, - 'pswpout': 0, - 'pgmajfault': 0}, - 'diskinfo': { - 'io': 0, - 'io_time': 0, - 'read_time': 0, - 'reads': 0, - 'reads_merged': 0, - 'sectors_read': 0, - 'sectors_written': 0, - 'weighted_io_time': 0, - 'write_time': 0, - 'writes': 0, - 'writes_merged': 0}, - 'swapinfo': {} - }; - - /** - * Tracks that display system stats data. - * - * @constructor - * @extends {StackedBarsTrack} - */ - - var SystemStatsInstanceTrack = tr.ui.b.define( - 'tr-ui-e-system-stats-instance-track', tr.ui.tracks.StackedBarsTrack); - - SystemStatsInstanceTrack.prototype = { - - __proto__: tr.ui.tracks.StackedBarsTrack.prototype, - - decorate: function(viewport) { - tr.ui.tracks.StackedBarsTrack.prototype.decorate.call(this, viewport); - this.classList.add('tr-ui-e-system-stats-instance-track'); - this.objectInstance_ = null; - }, - - set objectInstances(objectInstances) { - if (!objectInstances) { - this.objectInstance_ = []; - return; - } - if (objectInstances.length != 1) - throw new Error('Bad object instance count.'); - this.objectInstance_ = objectInstances[0]; - if (this.objectInstance_ !== null) { - this.computeRates_(this.objectInstance_.snapshots); - this.maxStats_ = this.computeMaxStats_( - this.objectInstance_.snapshots); - } - }, - - computeRates_: function(snapshots) { - for (var i = 0; i < snapshots.length; i++) { - var snapshot = snapshots[i]; - var stats = snapshot.getStats(); - var prevSnapshot; - var prevStats; - - if (i == 0) { - // Deltas will be zero. - prevSnapshot = snapshots[0]; - } else { - prevSnapshot = snapshots[i - 1]; - } - prevStats = prevSnapshot.getStats(); - var timeIntervalSeconds = (snapshot.ts - prevSnapshot.ts) / 1000; - // Prevent divide by zero. - if (timeIntervalSeconds == 0) - timeIntervalSeconds = 1; - - this.computeRatesRecursive_(prevStats, stats, - timeIntervalSeconds); - } - }, - - computeRatesRecursive_: function(prevStats, stats, - timeIntervalSeconds) { - for (var statName in stats) { - if (stats[statName] instanceof Object) { - this.computeRatesRecursive_(prevStats[statName], - stats[statName], - timeIntervalSeconds); - } else { - if (statName == 'sectors_read') { - stats['bytes_read_per_sec'] = (stats['sectors_read'] - - prevStats['sectors_read']) * - 512 / timeIntervalSeconds; - } - if (statName == 'sectors_written') { - stats['bytes_written_per_sec'] = - (stats['sectors_written'] - - prevStats['sectors_written']) * - 512 / timeIntervalSeconds; - } - if (statName == 'pgmajfault') { - stats['pgmajfault_per_sec'] = (stats['pgmajfault'] - - prevStats['pgmajfault']) / - timeIntervalSeconds; - } - if (statName == 'pswpin') { - stats['bytes_swpin_per_sec'] = (stats['pswpin'] - - prevStats['pswpin']) * - 1000 / timeIntervalSeconds; - } - if (statName == 'pswpout') { - stats['bytes_swpout_per_sec'] = (stats['pswpout'] - - prevStats['pswpout']) * - 1000 / timeIntervalSeconds; - } - } - } - }, - - computeMaxStats_: function(snapshots) { - var maxStats = new Object(); - statCount = 0; - - for (var i = 0; i < snapshots.length; i++) { - var snapshot = snapshots[i]; - var stats = snapshot.getStats(); - - this.computeMaxStatsRecursive_(stats, maxStats, - excludedStats); - } - - return maxStats; - }, - - computeMaxStatsRecursive_: function(stats, maxStats, excludedStats) { - for (var statName in stats) { - if (stats[statName] instanceof Object) { - if (!(statName in maxStats)) - maxStats[statName] = new Object(); - - var excludedNested; - if (excludedStats && statName in excludedStats) - excludedNested = excludedStats[statName]; - else - excludedNested = null; - - this.computeMaxStatsRecursive_(stats[statName], - maxStats[statName], - excludedNested); - } else { - if (excludedStats && statName in excludedStats) - continue; - if (!(statName in maxStats)) { - maxStats[statName] = 0; - statCount++; - } - if (stats[statName] > maxStats[statName]) - maxStats[statName] = stats[statName]; - } - } - }, - - get height() { - return window.getComputedStyle(this).height; - }, - - set height(height) { - this.style.height = height; - }, - - draw: function(type, viewLWorld, viewRWorld) { - switch (type) { - case tr.ui.tracks.DrawType.GENERAL_EVENT: - this.drawStatBars_(viewLWorld, viewRWorld); - break; - } - }, - - drawStatBars_: function(viewLWorld, viewRWorld) { - var ctx = this.context(); - var pixelRatio = window.devicePixelRatio || 1; - - var bounds = this.getBoundingClientRect(); - var width = bounds.width * pixelRatio; - var height = (bounds.height * pixelRatio) / statCount; - - // Culling parameters. - var vp = this.viewport.currentDisplayTransform; - - // Scale by the size of the largest snapshot. - var maxStats = this.maxStats_; - - var objectSnapshots = this.objectInstance_.snapshots; - var lowIndex = tr.b.findLowIndexInSortedArray( - objectSnapshots, - function(snapshot) { - return snapshot.ts; - }, - viewLWorld); - - // Assure that the stack with the left edge off screen still gets drawn - if (lowIndex > 0) - lowIndex -= 1; - - for (var i = lowIndex; i < objectSnapshots.length; ++i) { - var snapshot = objectSnapshots[i]; - var trace = snapshot.getStats(); - var currentY = height; - - var left = snapshot.ts; - if (left > viewRWorld) - break; - var leftView = vp.xWorldToView(left); - if (leftView < 0) - leftView = 0; - - // Compute the edges for the column graph bar. - var right; - if (i != objectSnapshots.length - 1) { - right = objectSnapshots[i + 1].ts; - } else { - // If this is the last snaphot of multiple snapshots, use the width of - // the previous snapshot for the width. - if (objectSnapshots.length > 1) - right = objectSnapshots[i].ts + (objectSnapshots[i].ts - - objectSnapshots[i - 1].ts); - else - // If there's only one snapshot, use max bounds as the width. - right = this.objectInstance_.parent.model.bounds.max; - } - - var rightView = vp.xWorldToView(right); - if (rightView > width) - rightView = width; - - // Floor the bounds to avoid a small gap between stacks. - leftView = Math.floor(leftView); - rightView = Math.floor(rightView); - - // Descend into nested stats. - this.drawStatBarsRecursive_(snapshot, - leftView, - rightView, - height, - trace, - maxStats, - currentY); - - if (i == lowIndex) - this.drawStatNames_(leftView, height, currentY, '', maxStats); - } - ctx.lineWidth = 1; - }, - - drawStatBarsRecursive_: function(snapshot, - leftView, - rightView, - height, - stats, - maxStats, - currentY) { - var ctx = this.context(); - - for (var statName in maxStats) { - if (stats[statName] instanceof Object) { - // Use the y-position returned from the recursive call. - currentY = this.drawStatBarsRecursive_(snapshot, - leftView, - rightView, - height, - stats[statName], - maxStats[statName], - currentY); - } else { - var maxStat = maxStats[statName]; - - // Draw a bar for the stat. The height of the bar is scaled - // against the largest value of the stat across all snapshots. - ctx.fillStyle = EventPresenter.getBarSnapshotColor( - snapshot, Math.round(currentY / height)); - - var barHeight; - - if (maxStat > 0) { - barHeight = height * Math.max(stats[statName], 0) / maxStat; - } else { - barHeight = 0; - } - - ctx.fillRect(leftView, currentY - barHeight, - Math.max(rightView - leftView, 1), barHeight); - - currentY += height; - } - } - - // Return the updated y-position. - return currentY; - }, - - drawStatNames_: function(leftView, height, currentY, prefix, maxStats) { - var ctx = this.context(); - - ctx.textAlign = 'end'; - ctx.font = '12px Arial'; - ctx.fillStyle = '#000000'; - for (var statName in maxStats) { - if (maxStats[statName] instanceof Object) { - currentY = this.drawStatNames_(leftView, height, currentY, - statName, maxStats[statName]); - } else { - var fullname = statName; - - if (prefix != '') - fullname = prefix + ' :: ' + statName; - - ctx.fillText(fullname, leftView - 10, currentY - height / 4); - currentY += height; - } - } - - return currentY; - } - }; - - tr.ui.tracks.ObjectInstanceTrack.register( - SystemStatsInstanceTrack, - {typeName: 'base::TraceEventSystemStatsMonitor::SystemStats'}); - - return { - SystemStatsInstanceTrack: SystemStatsInstanceTrack - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/system_stats/system_stats_instance_track_test.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/system_stats/system_stats_instance_track_test.html deleted file mode 100644 index 684887c2f0d..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/system_stats/system_stats_instance_track_test.html +++ /dev/null @@ -1,67 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/ui/extras/system_stats/system_stats.html"> -<link rel="import" href="/tracing/ui/timeline_viewport.html"> -<link rel="import" href="/tracing/ui/tracks/drawing_container.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var SystemStatsInstanceTrack = tr.ui.e.system_stats.SystemStatsInstanceTrack; - var Viewport = tr.ui.TimelineViewport; - - var createObjects = function() { - var objectInstance = new tr.model.ObjectInstance({}); - var snapshots = []; - - var stats1 = new Object(); - var stats2 = new Object(); - - stats1['committed_memory'] = 2000000; - stats2['committed_memory'] = 3000000; - - stats1['meminfo'] = new Object(); - stats1.meminfo['free'] = 10000; - stats2['meminfo'] = new Object(); - stats2.meminfo['free'] = 20000; - - snapshots.push(new tr.e.system_stats.SystemStatsSnapshot(objectInstance, - 10, stats1)); - snapshots.push(new tr.e.system_stats.SystemStatsSnapshot(objectInstance, - 20, stats2)); - - objectInstance.snapshots = snapshots; - - return objectInstance; - }; - - test('instantiate', function() { - var objectInstances = []; - objectInstances.push(createObjects()); - - var div = document.createElement('div'); - var viewport = new Viewport(div); - var drawingContainer = new tr.ui.tracks.DrawingContainer(viewport); - div.appendChild(drawingContainer); - - var track = new SystemStatsInstanceTrack(viewport); - track.objectInstances = objectInstances; - drawingContainer.appendChild(track); - - this.addHTMLOutput(div); - drawingContainer.invalidate(); - - track.heading = 'testBasic'; - var dt = new tr.ui.TimelineDisplayTransform(); - dt.xSetWorldBounds(0, 50, track.clientWidth); - track.viewport.setDisplayTransformImmediately(dt); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/system_stats/system_stats_snapshot_view.css b/chromium/third_party/catapult/tracing/tracing/ui/extras/system_stats/system_stats_snapshot_view.css deleted file mode 100644 index e698b15aa70..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/system_stats/system_stats_snapshot_view.css +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright (c) 2013 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -.tr-ui-e-system-stats-snapshot-view .subhead { - font-size: small; - padding-bottom: 10px; -} - -.tr-ui-e-system-stats-snapshot-view ul { - background-position: 0 5px; - background-repeat: no-repeat; - cursor: pointer; - font-family: monospace; - list-style: none; - margin: 0; - padding-left: 15px; -} - -.tr-ui-e-system-stats-snapshot-view li { - background-position: 0 5px; - background-repeat: no-repeat; - cursor: pointer; - list-style: none; - margin: 0; - padding-left: 15px; -} diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/system_stats/system_stats_snapshot_view.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/system_stats/system_stats_snapshot_view.html deleted file mode 100644 index 11421e91453..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/system_stats/system_stats_snapshot_view.html +++ /dev/null @@ -1,84 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="stylesheet" - href="/tracing/ui/extras/system_stats/system_stats_snapshot_view.css"> - -<link rel="import" href="/tracing/ui/analysis/object_snapshot_view.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.e.system_stats', function() { - /* - * Displays a system stats snapshot in a human readable form. @constructor - */ - var SystemStatsSnapshotView = tr.ui.b.define( - 'tr-ui-e-system-stats-snapshot-view', tr.ui.analysis.ObjectSnapshotView); - - SystemStatsSnapshotView.prototype = { - __proto__: tr.ui.analysis.ObjectSnapshotView.prototype, - - decorate: function() { - this.classList.add('tr-ui-e-system-stats-snapshot-view'); - }, - - updateContents: function() { - var snapshot = this.objectSnapshot_; - if (!snapshot || !snapshot.getStats()) { - this.textContent = 'No system stats snapshot found.'; - return; - } - // Clear old snapshot view. - this.textContent = ''; - - var stats = snapshot.getStats(); - this.appendChild(this.buildList_(stats)); - }, - - isFloat: function(n) { - return typeof n === 'number' && n % 1 !== 0; - }, - - /** - * Creates nested lists. - * - * @param {Object} stats The current trace system stats entry. - * @return {Element} A ul list element. - */ - buildList_: function(stats) { - var statList = document.createElement('ul'); - - for (var statName in stats) { - var statText = document.createElement('li'); - statText.textContent = '' + statName + ': '; - statList.appendChild(statText); - - if (stats[statName] instanceof Object) { - statList.appendChild(this.buildList_(stats[statName])); - } else { - if (this.isFloat(stats[statName])) - statText.textContent += stats[statName].toFixed(2); - else - statText.textContent += stats[statName]; - } - } - - return statList; - } - }; - - tr.ui.analysis.ObjectSnapshotView.register( - SystemStatsSnapshotView, - {typeName: 'base::TraceEventSystemStatsMonitor::SystemStats'}); - - return { - SystemStatsSnapshotView: SystemStatsSnapshotView - }; - -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/systrace_config.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/systrace_config.html deleted file mode 100644 index 3ba4626e1c3..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/systrace_config.html +++ /dev/null @@ -1,12 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/extras/systrace_config.html"> -<link rel="import" href="/tracing/ui/base/ui.html"> -<link rel="import" href="/tracing/ui/extras/highlighter/vsync_highlighter.html"> -<link rel="import" href="/tracing/ui/extras/side_panel/alerts_side_panel.html"> -<link rel="import" href="/tracing/ui/timeline_view.html"> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/find_control.html b/chromium/third_party/catapult/tracing/tracing/ui/find_control.html deleted file mode 100644 index 6f2c636b281..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/find_control.html +++ /dev/null @@ -1,173 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/base/hotkey_controller.html"> -<link rel="import" href="/tracing/ui/find_controller.html"> -<link rel="import" href="/tracing/ui/timeline_track_view.html"> - -<polymer-element name="tr-ui-find-control"> - <template> - <style> - :host { - -webkit-user-select: none; - display: -webkit-flex; - position: relative; - } - input { - -webkit-user-select: auto; - background-color: #f8f8f8; - border: 1px solid rgba(0, 0, 0, 0.5); - box-sizing: border-box; - margin: 0; - padding: 0; - width: 170px; - } - input:focus { - background-color: white; - } - tr-ui-b-toolbar-button { - border-left: none; - margin: 0; - } - #hitCount { - left: 0; - opacity: 0.25; - pointer-events: none; - position: absolute; - text-align: right; - top: 2px; - width: 167px; - z-index: 1; - } - #spinner { - visibility: hidden; - width: 8px; - height: 8px; - left: 154px; - pointer-events: none; - position: absolute; - top: 4px; - z-index: 1; - - border: 2px solid transparent; - border-bottom: 2px solid rgba(0, 0, 0, 0.5); - border-right: 2px solid rgba(0, 0, 0, 0.5); - border-radius: 50%; - - animation: spin 1s linear infinite; - } - @keyframes spin { 100% { transform: rotate(360deg); } } - </style> - - <input type='text' id='filter' - on-input="{{ filterTextChanged }}" - on-keydown="{{ filterKeyDown }}" - on-blur="{{ filterBlur }}" - on-focus="{{ filterFocus }}" - on-mouseup="{{ filterMouseUp }}" /> - <div id="spinner"></div> - <tr-ui-b-toolbar-button on-click="{{ findPrevious }}"> - ← - </tr-ui-b-toolbar-button> - <tr-ui-b-toolbar-button on-click="{{ findNext }}"> - → - </tr-ui-b-toolbar-button> - <div id="hitCount">0 of 0</div> - </template> - - <script> - 'use strict'; - - Polymer({ - filterKeyDown: function(e) { - if (e.keyCode === 27) { - var hkc = tr.b.getHotkeyControllerForElement(this); - if (hkc) { - hkc.childRequestsBlur(this); - } else { - this.blur(); - } - e.preventDefault(); - e.stopPropagation(); - return; - } else if (e.keyCode === 13) { - if (e.shiftKey) - this.findPrevious(); - else - this.findNext(); - } - }, - - filterBlur: function(e) { - this.updateHitCountEl(); - }, - - filterFocus: function(e) { - this.$.filter.select(); - }, - - // Prevent that the input text is deselected after focusing the find - // control with the mouse. - filterMouseUp: function(e) { - e.preventDefault(); - }, - - get controller() { - return this.controller_; - }, - - set controller(c) { - this.controller_ = c; - this.updateHitCountEl(); - }, - - focus: function() { - this.$.filter.focus(); - }, - - get hasFocus() { - return this === document.activeElement; - }, - - filterTextChanged: function() { - this.$.hitCount.textContent = ''; - this.$.spinner.style.visibility = 'visible'; - this.controller.startFiltering(this.$.filter.value).then(function() { - this.$.spinner.style.visibility = 'hidden'; - this.updateHitCountEl(); - }.bind(this)); - }, - - findNext: function() { - if (this.controller) - this.controller.findNext(); - this.updateHitCountEl(); - }, - - findPrevious: function() { - if (this.controller) - this.controller.findPrevious(); - this.updateHitCountEl(); - }, - - updateHitCountEl: function() { - if (!this.controller || this.$.filter.value.length === 0) { - this.$.hitCount.textContent = ''; - return; - } - - var n = this.controller.filterHits.length; - var i = n === 0 ? -1 : this.controller.currentHitIndex; - this.$.hitCount.textContent = (i + 1) + ' of ' + n; - }, - - setText: function(string) { - this.$.filter.value = string; - } - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/find_control_test.html b/chromium/third_party/catapult/tracing/tracing/ui/find_control_test.html deleted file mode 100644 index 192f6fe9935..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/find_control_test.html +++ /dev/null @@ -1,66 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/ui/find_control.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - test('instantiate', function() { - var ctl = document.createElement('tr-ui-find-control'); - ctl.controller = { - findNext: function() { }, - findPrevious: function() { }, - reset: function() {}, - - filterHits: ['a', 'b'], - - currentHitIndex: 0 - }; - - this.addHTMLOutput(ctl); - }); - - test('updateHitCountEl_twoResults', function() { - var ctl = document.createElement('tr-ui-find-control'); - ctl.controller = { - findNext: function() { }, - findPrevious: function() { }, - reset: function() {}, - - filterHits: ['a', 'b'], - - currentHitIndex: 0 - }; - - this.addHTMLOutput(ctl); - ctl.$.filter.value = 'test'; - ctl.updateHitCountEl(); - assert.equal(ctl.$.hitCount.textContent, '1 of 2'); - }); - - test('updateHitCountEl_emptyFilter', function() { - var ctl = document.createElement('tr-ui-find-control'); - ctl.controller = { - findNext: function() { }, - findPrevious: function() { }, - reset: function() {}, - - filterHits: ['a', 'b'], - - currentHitIndex: 0 - }; - - this.addHTMLOutput(ctl); - ctl.$.filter.value = ''; - ctl.updateHitCountEl(); - assert.equal(ctl.$.hitCount.textContent, ''); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/find_controller.html b/chromium/third_party/catapult/tracing/tracing/ui/find_controller.html deleted file mode 100644 index 4247676856b..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/find_controller.html +++ /dev/null @@ -1,154 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2012 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/task.html"> -<link rel="import" href="/tracing/core/filter.html"> -<link rel="import" href="/tracing/model/event_set.html"> - -<script> -'use strict'; - -/** - * @fileoverview FindController. - */ -tr.exportTo('tr.ui', function() { - var Task = tr.b.Task; - - function FindController(brushingStateController) { - this.brushingStateController_ = brushingStateController; - this.filterHits_ = []; - this.currentHitIndex_ = -1; - this.activePromise_ = Promise.resolve(); - this.activeTask_ = undefined; - }; - - FindController.prototype = { - __proto__: Object.prototype, - - get model() { - return this.brushingStateController_.model; - }, - - get brushingStateController() { - return this.brushingStateController_; - }, - - enqueueOperation_: function(operation) { - var task; - if (operation instanceof tr.b.Task) - task = operation; - else - task = new tr.b.Task(operation, this); - if (this.activeTask_) { - this.activeTask_ = this.activeTask_.enqueue(task); - } else { - // We're enqueuing the first task, schedule it. - this.activeTask_ = task; - this.activePromise_ = Task.RunWhenIdle(this.activeTask_); - this.activePromise_.then(function() { - this.activePromise_ = undefined; - this.activeTask_ = undefined; - }.bind(this)); - } - }, - - /** - * Updates the filter hits based on the provided |filterText|. Returns a - * promise which resolves when |filterHits| has been refreshed. - */ - startFiltering: function(filterText) { - var sc = this.brushingStateController_; - if (!sc) - return; - - // TODO(beaudoin): Cancel anything left in the task queue, without - // invalidating the promise. - this.enqueueOperation_(function() { - this.filterHits_ = []; - this.currentHitIndex_ = -1; - }.bind(this)); - - // Try constructing a UIState from the filterText. - // UIState.fromUserFriendlyString will throw an error only if the string - // is syntactically correct to a UI state string but with invalid values. - // It will return undefined if there is no syntactic match. - var stateFromString; - try { - stateFromString = sc.uiStateFromString(filterText); - } catch (e) { - this.enqueueOperation_(function() { - var overlay = new tr.ui.b.Overlay(); - overlay.textContent = e.message; - overlay.title = 'UI State Navigation Error'; - overlay.visible = true; - }); - return this.activePromise_; - } - - if (stateFromString !== undefined) { - this.enqueueOperation_( - sc.navToPosition.bind(this, stateFromString, true)); - } else { - // filterText is not a navString here -- proceed with find and filter. - if (filterText.length === 0) { - this.enqueueOperation_(sc.findTextCleared.bind(sc)); - } else { - var filter = new tr.c.FullTextFilter(filterText); - var filterHitSet = new tr.model.EventSet(); - this.enqueueOperation_(sc.addAllEventsMatchingFilterToSelectionAsTask( - filter, filterHitSet)); - this.enqueueOperation_(function() { - this.filterHits_ = filterHitSet.toArray(); - sc.findTextChangedTo(filterHitSet); - }.bind(this)); - } - } - return this.activePromise_; - }, - - /** - * Returns the most recent filter hits as an array. Call - * |startFiltering| to ensure this is up to date after the filter settings - * have been changed. - */ - get filterHits() { - return this.filterHits_; - }, - - get currentHitIndex() { - return this.currentHitIndex_; - }, - - find_: function(dir) { - var firstHit = this.currentHitIndex_ === -1; - if (firstHit && dir < 0) - this.currentHitIndex_ = 0; - - var N = this.filterHits.length; - this.currentHitIndex_ = (this.currentHitIndex_ + dir + N) % N; - - if (!this.brushingStateController_) - return; - - this.brushingStateController_.findFocusChangedTo( - new tr.model.EventSet(this.filterHits[this.currentHitIndex])); - }, - - findNext: function() { - this.find_(1); - }, - - findPrevious: function() { - this.find_(-1); - } - }; - - return { - FindController: FindController - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/find_controller_test.html b/chromium/third_party/catapult/tracing/tracing/ui/find_controller_test.html deleted file mode 100644 index f6509f88cbc..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/find_controller_test.html +++ /dev/null @@ -1,307 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/task.html"> -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/ui/find_controller.html"> -<link rel="import" href="/tracing/ui/timeline_track_view.html"> -<link rel="import" href="/tracing/ui/timeline_view.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var Task = tr.b.Task; - - /* - * Just enough of the BrushingStateController to support the tests below. - */ - function FakeBrushingStateController() { - this.addAllEventsMatchingFilterToSelectionReturnValue = []; - - this.viewport = undefined; - this.model = undefined; - this.selection = new tr.model.EventSet(); - this.findMatches = new tr.model.EventSet(); - } - - FakeBrushingStateController.prototype = { - addAllEventsMatchingFilterToSelectionAsTask: function(filter, selection) { - return new Task(function() { - var n = this.addAllEventsMatchingFilterToSelectionReturnValue.length; - for (var i = 0; i < n; i++) { - selection.push( - this.addAllEventsMatchingFilterToSelectionReturnValue[i]); - } - }, this); - }, - - uiStateFromString: function(string) { - return undefined; - }, - - findTextChangedTo: function(selection) { - this.findMatches = selection; - this.selection = new tr.model.EventSet(); - }, - - findFocusChangedTo: function(selection) { - this.selection = selection; - }, - - findTextCleared: function(selection) { - this.selection = new tr.model.EventSet(); - this.findMatches = new tr.model.EventSet(); - } - }; - - function assertArrayShallowEquals(a, b, opt_message) { - if (a.length === b.length) { - var ok = true; - for (var i = 0; i < a.length; i++) { - ok &= (a[i] === b[i]); - } - if (ok) - return; - } - - var message = opt_message || 'Expected array ' + a + ', got array ' + b; - throw new tr.b.unittest.TestError(message); - }; - - test('findControllerNoModel', function() { - var brushingStateController = new FakeBrushingStateController(); - var controller = new tr.ui.FindController(brushingStateController); - controller.findNext(); - controller.findPrevious(); - }); - - test('findControllerEmptyHit', function() { - var brushingStateController = new FakeBrushingStateController(); - var controller = new tr.ui.FindController(brushingStateController); - - brushingStateController.selection = new tr.model.EventSet(); - brushingStateController.findMatches = new tr.model.EventSet(); - controller.findNext(); - assertArrayShallowEquals([], brushingStateController.selection); - assertArrayShallowEquals([], brushingStateController.findMatches); - controller.findPrevious(); - assertArrayShallowEquals([], brushingStateController.selection); - assertArrayShallowEquals([], brushingStateController.findMatches); - }); - - test('findControllerOneHit', function() { - var brushingStateController = new FakeBrushingStateController(); - var controller = new tr.ui.FindController(brushingStateController); - - var s1 = {guid: 1}; - brushingStateController.addAllEventsMatchingFilterToSelectionReturnValue = [ - s1 - ]; - var promise = controller.startFiltering('asdf'); - promise.then(function() { - assertArrayShallowEquals([], brushingStateController.selection); - assertArrayShallowEquals([s1], brushingStateController.findMatches); - controller.findNext(); - assertArrayShallowEquals([s1], brushingStateController.selection); - assertArrayShallowEquals([s1], brushingStateController.findMatches); - controller.findNext(); - assertArrayShallowEquals([s1], brushingStateController.selection); - assertArrayShallowEquals([s1], brushingStateController.findMatches); - controller.findPrevious(); - assertArrayShallowEquals([s1], brushingStateController.selection); - assertArrayShallowEquals([s1], brushingStateController.findMatches); - }); - return promise; - }); - - test('findControllerMultipleHits', function() { - var brushingStateController = new FakeBrushingStateController(); - var controller = new tr.ui.FindController(brushingStateController); - - var s1 = {guid: 1}; - var s2 = {guid: 2}; - var s3 = {guid: 3}; - - brushingStateController.addAllEventsMatchingFilterToSelectionReturnValue = [ - s1, s2, s3 - ]; - var promise = controller.startFiltering('asdf'); - promise.then(function() { - // Loop through hits then when we wrap, try moving backward. - assertArrayShallowEquals([], brushingStateController.selection); - assertArrayShallowEquals([s1, s2, s3], - brushingStateController.findMatches); - controller.findNext(); - assertArrayShallowEquals([s1], brushingStateController.selection); - controller.findNext(); - assertArrayShallowEquals([s2], brushingStateController.selection); - controller.findNext(); - assertArrayShallowEquals([s3], brushingStateController.selection); - controller.findNext(); - assertArrayShallowEquals([s1], brushingStateController.selection); - controller.findPrevious(); - assertArrayShallowEquals([s3], brushingStateController.selection); - controller.findPrevious(); - assertArrayShallowEquals([s2], brushingStateController.selection); - assertArrayShallowEquals([s1, s2, s3], - brushingStateController.findMatches); - }); - return promise; - }); - - test('findControllerChangeFilterAfterNext', function() { - var brushingStateController = new FakeBrushingStateController(); - var controller = new tr.ui.FindController(brushingStateController); - - var s1 = {guid: 1}; - var s2 = {guid: 2}; - var s3 = {guid: 3}; - var s4 = {guid: 4}; - - brushingStateController.addAllEventsMatchingFilterToSelectionReturnValue = [ - s1, s2, s3 - ]; - var promise = controller.startFiltering('asdf'); - promise.then(function() { - // Loop through hits then when we wrap, try moving backward. - controller.findNext(); - brushingStateController. - addAllEventsMatchingFilterToSelectionReturnValue = [s4]; - - var nextPromise = controller.startFiltering('asdfsf'); - nextPromise.then(function() { - controller.findNext(); - assertArrayShallowEquals([s4], brushingStateController.selection); - }); - }); - return promise; - }); - - test('findControllerSelectsAllItemsFirst', function() { - var brushingStateController = new FakeBrushingStateController(); - var controller = new tr.ui.FindController(brushingStateController); - - var s1 = {guid: 1}; - var s2 = {guid: 2}; - var s3 = {guid: 3}; - brushingStateController.addAllEventsMatchingFilterToSelectionReturnValue = [ - s1, s2, s3 - ]; - var promise = controller.startFiltering('asdfsf'); - promise.then(function() { - assertArrayShallowEquals([], brushingStateController.selection); - assertArrayShallowEquals([s1, s2, s3], - brushingStateController.findMatches); - controller.findNext(); - assertArrayShallowEquals([s1], brushingStateController.selection); - controller.findNext(); - assertArrayShallowEquals([s2], brushingStateController.selection); - assertArrayShallowEquals([s1, s2, s3], - brushingStateController.findMatches); - }); - return promise; - }); - - test('findControllerWithRealTimeline', function() { - var model = tr.c.TestUtils.newModel(function(model) { - var p1 = model.getOrCreateProcess(1); - var t1 = p1.getOrCreateThread(1); - t1.sliceGroup.pushSlice(new tr.model.ThreadSlice( - '', 'a', 0, 1, {}, 3)); - model.t1 = t1; - }); - - var container = document.createElement('track-view-container'); - container.id = 'track_view_container'; - - var timeline = document.createElement('tr-ui-timeline-view'); - timeline.appendChild(container); - - // This is for testing only, have to make sure things link up right. - timeline.trackViewContainer_ = container; - - timeline.model = model; - - var brushingStateController = timeline.brushingStateController; - var controller = timeline.findCtl_.controller; - - // Test find with no filterText. - controller.findNext(); - - // Test find with filter txt. - var promise = controller.startFiltering('a'); - promise = promise.then(function() { - assert.equal(brushingStateController.selection.length, 0); - assert.deepEqual(tr.b.asArray(brushingStateController.findMatches), - model.t1.sliceGroup.slices); - - controller.findNext(); - assert.isTrue(brushingStateController.selection.equals( - new tr.model.EventSet(model.t1.sliceGroup.slices[0]))); - - var nextPromise = controller.startFiltering('xxx'); - nextPromise.then(function() { - assert.equal(brushingStateController.findMatches.length, 0); - assert.equal(brushingStateController.selection.length, 1); - controller.findNext(); - assert.equal(brushingStateController.selection.length, 0); - controller.findNext(); - assert.equal(brushingStateController.selection.length, 0); - }); - return nextPromise; - }); - return promise; - }); - - test('findControllerNavigation', function() { - var brushingStateController = new FakeBrushingStateController(); - var controller = new tr.ui.FindController(brushingStateController); - - var navToPositionCallCount = 0; - var findTextClearedCallCount = 0; - var fakeUIState = {}; - brushingStateController.uiStateFromString = function(string) { - if (string === '') - return undefined; - assert.equal(string, '2000@1.2x7'); - return fakeUIState; - }; - brushingStateController.navToPosition = function(uiState) { - assert.equal(uiState, fakeUIState); - navToPositionCallCount++; - }; - brushingStateController.findTextCleared = function() { - findTextClearedCallCount++; - }; - - var promise = controller.startFiltering('2000@1.2x7').then(function() { - assert.equal(navToPositionCallCount, 1); - }); - promise = promise.then(controller.startFiltering.bind(controller, '')); - promise = promise.then(function() { - assert.equal(findTextClearedCallCount, 1); - }); - return promise; - }); - - test('findControllerClearAfterSet', function() { - var brushingStateController = new FakeBrushingStateController(); - var controller = new tr.ui.FindController(brushingStateController); - var findTextChangedToCalled = false; - brushingStateController.findTextChangedTo = function(selection) { - findTextChangedToCalled = true; - }; - brushingStateController.findTextCleared = function() { - assert.equal(findTextChangedToCalled, true); - }; - controller.startFiltering('1'); - controller.startFiltering(''); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/images/chrome-left.png b/chromium/third_party/catapult/tracing/tracing/ui/images/chrome-left.png Binary files differdeleted file mode 100644 index 8eef2bf7ecc..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/images/chrome-left.png +++ /dev/null diff --git a/chromium/third_party/catapult/tracing/tracing/ui/images/chrome-mid.png b/chromium/third_party/catapult/tracing/tracing/ui/images/chrome-mid.png Binary files differdeleted file mode 100644 index c67e697de5f..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/images/chrome-mid.png +++ /dev/null diff --git a/chromium/third_party/catapult/tracing/tracing/ui/images/chrome-right.png b/chromium/third_party/catapult/tracing/tracing/ui/images/chrome-right.png Binary files differdeleted file mode 100644 index 834004a0f74..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/images/chrome-right.png +++ /dev/null diff --git a/chromium/third_party/catapult/tracing/tracing/ui/images/ui-states.png b/chromium/third_party/catapult/tracing/tracing/ui/images/ui-states.png Binary files differdeleted file mode 100644 index 83d09179817..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/images/ui-states.png +++ /dev/null diff --git a/chromium/third_party/catapult/tracing/tracing/ui/metrics_debugger_app.html b/chromium/third_party/catapult/tracing/tracing/ui/metrics_debugger_app.html deleted file mode 100644 index 5164a80d7bb..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/metrics_debugger_app.html +++ /dev/null @@ -1,131 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright 2016 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> -<link rel="import" href="/perf_insights/mre/mre_result.html"> -<link rel="import" href="/tracing/extras/full_config.html"> -<link rel="import" href="/tracing/importer/import.html"> -<link rel="import" href="/tracing/metrics/all_metrics.html"> -<link rel="import" href="/tracing/metrics/metric_map_function.html"> -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/ui/base/dom_helpers.html"> -<link rel="import" href="/tracing/ui/base/file.html"> -<link rel="import" href="/tracing/ui/base/ui.html"> - -<polymer-element name="tracing-ui-metrics-debugger-app"> - <template> - <style> - pre { - overflow: auto; - } - #bar { - display: flex; - flex-direction: row; - padding: 1px 6px; - } - </style> - - <top-left-controls id="top_left_controls"></top-left-controls> - <input id="load_trace" type="file"/> - <button id="run_metric">Run metric</button> - <div id="trace_info"></div> - <pre id="map_results"> - </pre> - </template> -</polymer-element> - -<script> -'use strict'; - -tr.exportTo('tr.ui', function() { - Polymer('tracing-ui-metrics-debugger-app', { - created: function() { - this.metrics_ = []; - tr.metrics.MetricRegistry.getAllRegisteredTypeInfos().forEach( - function(m) { - this.metrics_.push({ - label: m.constructor.name, - value: m.constructor.name - }); - }, this); - this.activeTrace_ = undefined; - this.settingsKey_ = undefined; - this.currentMetricName_ = undefined; - this.settingsKey_ = 'metrics-debugger-app-metric-name'; - }, - - ready: function() { - var metricSelector = tr.ui.b.createSelector( - this, 'currentMetricName_', - this.settingsKey_, - this.metrics_[0].value, - this.metrics_); - this.$.top_left_controls.appendChild(metricSelector); - - this.$.load_trace.addEventListener('change', function(event) { - var file = event.target.files[0]; - this.onTraceFileSelected_(file); - }.bind(this)); - this.$.run_metric.addEventListener( - 'click', function(event) { - event.stopPropagation(); - this.onRunMetricClicked_(); - }.bind(this)); - }, - - onRunMetricClicked_: function() { - if (this.activeTrace_ === undefined) { - tr.ui.b.Overlay.showError('You must load a trace first!'); - return; - } - var result = new pi.mre.MreResult(); - var model = this.activeTrace_.model; - var options = {metric: this.currentMetricName_}; - try { - tr.metrics.metricMapFunction(result, model, options); - this.$.map_results.textContent = 'Metric result:\n' + - JSON.stringify(result.asDict(), undefined, 2); - } catch (err) { - tr.ui.b.Overlay.showError('Error running metric:\n' + err.stack); - console.error(err); - } - }, - - onTraceFileSelected_: function(file) { - tr.ui.b.readFile(file).then( - function(data) { - this.setActiveTrace(file.name, data); - }.bind(this), - function(err) { - tr.ui.b.Overlay.showError('Error while loading file: ' + err); - }); - }, - - setActiveTrace: function(filename, data) { - var model = new tr.Model(); - var importOptions = new tr.importer.ImportOptions(); - importOptions.pruneEmptyContainers = false; - importOptions.showImportWarnings = true; - importOptions.trackDetailedModelStats = true; - - var i = new tr.importer.Import(model, importOptions); - i.importTracesWithProgressDialog([data]).then( - function() { - this.activeTrace_ = { - filename: filename, - model: model, - }; - this.$.trace_info.textContent = 'Trace file ' + filename + - ' is loaded.'; - }.bind(this), - function(err) { - tr.ui.b.Overlay.showError('Trace import error: ' + err); - console.error(err); - }); - }, - }); - return {}; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/scripting_control.html b/chromium/third_party/catapult/tracing/tracing/ui/scripting_control.html deleted file mode 100644 index 208cc35577e..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/scripting_control.html +++ /dev/null @@ -1,188 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/extras/tquery/tquery.html"> - -<polymer-element - name="tr-ui-scripting-control"> - <template> - <style> - :host { - flex: 1 1 auto; - } - .root { - font-family: monospace; - cursor: text; - - padding: 2px; - margin: 2px; - border: 1px solid rgba(0, 0, 0, 0.5); - background: white; - - height: 100px; - overflow-y: auto; - - transition-property: opacity, height, padding, margin; - transition-duration: .2s; - transition-timing-function: ease-out; - } - .hidden { - margin-top: 0px; - margin-bottom: 0px; - padding-top: 0px; - padding-bottom: 0px; - height: 0px; - opacity: 0; - } - .focused { - outline: auto 5px -webkit-focus-ring-color; - } - #history { - -webkit-user-select: text; - color: #777; - } - #prompt { - -webkit-user-select: text; - -webkit-user-modify: read-write-plaintext-only; - text-overflow: clip !important; - text-decoration: none !important; - } - #prompt:focus { - outline: none; - } - #prompt br { - display: none; - } - #prompt ::before { - content: ">"; - color: #468; - } - </style> - - <div id="root" class="root hidden" tabindex="0" - on-focus="{{ onConsoleFocus }}"> - <div id='history'></div> - <div id='prompt' - on-keypress="{{ promptKeyPress }}" - on-keydown="{{ promptKeyDown }}" - on-blur="{{ onConsoleBlur }}"></div> - </div> - </template> - - <script> - 'use strict'; - - Polymer({ - _isEnterKey: function(event) { - // Check if in IME. - return event.keyCode !== 229 && event.keyIdentifier === 'Enter'; - }, - - _setFocused: function(focused) { - var promptEl = this.$.prompt; - if (focused) { - promptEl.focus(); - this.$.root.classList.add('focused'); - // Move cursor to the end of any existing text. - if (promptEl.innerText.length > 0) { - var sel = window.getSelection(); - sel.collapse(promptEl.firstChild, promptEl.innerText.length); - } - } else { - promptEl.blur(); - this.$.root.classList.remove('focused'); - // Workaround for crbug.com/89026 to ensure the prompt doesn't retain - // keyboard focus. - var parent = promptEl.parentElement; - var nextEl = promptEl.nextSibling; - promptEl.remove(); - parent.insertBefore(promptEl, nextEl); - } - }, - - onConsoleFocus: function(e) { - e.stopPropagation(); - this._setFocused(true); - }, - - onConsoleBlur: function(e) { - e.stopPropagation(); - this._setFocused(false); - }, - - promptKeyDown: function(e) { - e.stopPropagation(); - if (!this._isEnterKey(e)) - return; - e.preventDefault(); - var promptEl = this.$.prompt; - var command = promptEl.innerText; - if (command.length === 0) - return; - promptEl.innerText = ''; - this.addLine_(String.fromCharCode(187) + ' ' + command); - - try { - var result = this.controller_.executeCommand(command); - } catch (e) { - result = e.stack || e.stackTrace; - } - - if (result instanceof tr.e.tquery.TQuery) { - // TODO(skyostil): Show a cool spinner. - result.ready().then(function(selection) { - this.addLine_(selection.length + ' matches'); - this.controller_.brushingStateController. - showScriptControlSelection(selection); - }.bind(this)); - } else { - this.addLine_(result); - } - promptEl.scrollIntoView(); - }, - - addLine_: function(line) { - var historyEl = this.$.history; - if (historyEl.innerText.length !== 0) - historyEl.innerText += '\n'; - historyEl.innerText += line; - }, - - promptKeyPress: function(e) { - e.stopPropagation(); - }, - - toggleVisibility: function() { - var root = this.$.root; - if (!this.visible) { - root.classList.remove('hidden'); - this._setFocused(true); - } else { - root.classList.add('hidden'); - this._setFocused(false); - } - }, - - get hasFocus() { - return this === document.activeElement; - }, - - get visible() { - var root = this.$.root; - return !root.classList.contains('hidden'); - }, - - get controller() { - return this.controller_; - }, - - set controller(c) { - this.controller_ = c; - } - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/scripting_control_test.html b/chromium/third_party/catapult/tracing/tracing/ui/scripting_control_test.html deleted file mode 100644 index a336b9f566a..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/scripting_control_test.html +++ /dev/null @@ -1,22 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/scripting_control.html"> -<link rel="import" href="/tracing/core/test_utils.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - test('instantiate', function() { - var ctl = document.createElement('tr-ui-scripting-control'); - this.addHTMLOutput(ctl); - ctl.toggleVisibility(); - }); -}); -</script> - diff --git a/chromium/third_party/catapult/tracing/tracing/ui/side_panel/file_size_stats_side_panel.html b/chromium/third_party/catapult/tracing/tracing/ui/side_panel/file_size_stats_side_panel.html deleted file mode 100644 index 6e96d27da06..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/side_panel/file_size_stats_side_panel.html +++ /dev/null @@ -1,212 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/statistics.html"> -<link rel="import" href="/tracing/ui/base/grouping_table.html"> -<link rel="import" href="/tracing/ui/base/grouping_table_groupby_picker.html"> -<link rel="import" href="/tracing/ui/base/table.html"> -<link rel="import" href="/tracing/ui/side_panel/side_panel.html"> -<link rel="import" href="/tracing/value/numeric.html"> -<link rel="import" href="/tracing/value/ui/scalar_span.html"> -<link rel="import" href="/tracing/value/unit.html"> - -<polymer-element name='tr-ui-sp-file-size-stats-side-panel' - extends='tr-ui-side-panel'> - <template> - <style> - :host { - display: flex; - flex-direction: column; - } - toolbar { - align-items: center; - background-color: rgb(236, 236, 236); - border-bottom: 1px solid #8e8e8e; - display: flex; - flex-direction: row; - flex-direction: row; - flex: 0 0 auto; - font-size: 12px; - padding: 0 10px 0 10px; - } - table-container { - display: flex; - min-height: 0px; - overflow-y: auto; - } - </style> - - <toolbar> - <span><b>Group by:</b></span> - <tr-ui-b-grouping-table-groupby-picker id="picker"> - </tr-ui-b-grouping-table-groupby-picker> - </toolbar> - <table-container> - <tr-ui-b-grouping-table id="table"></tr-ui-b-grouping-table> - </table-container> - </template> -</polymer-element> - -<script> -'use strict'; -(function() { - - Polymer('tr-ui-sp-file-size-stats-side-panel', { - ready: function() { - this.model_ = undefined; - this.selection_ = new tr.model.EventSet(); - this.$.picker.settingsKey = 'tr-ui-sp-file-size-stats-side-panel-picker'; - this.$.picker.possibleGroups = [ - { - key: 'phase', label: 'Event Type', - dataFn: function(eventStat) { return eventStat.phase; } - }, - { - key: 'category', label: 'Category', - dataFn: function(eventStat) { return eventStat.category; } - }, - { - key: 'title', label: 'Title', - dataFn: function(eventStat) { return eventStat.title; } - } - ]; - this.$.picker.defaultGroupKeys = ['phase', 'title']; - this.$.picker.addEventListener('current-groups-changed', - this.updateContents_.bind(this)); - }, - - get textLabel() { - return 'File Size Stats'; - }, - - supportsModel: function(m) { - if (!m) { - return { - supported: false, - reason: 'No stats were collected for this file.' - }; - } - - if (m.stats.allTraceEventStats.length === 0) { - return { - supported: false, - reason: 'No stats were collected for this file.' - }; - } - return { - supported: true - }; - }, - - get model() { - return this.model_; - }, - - set model(model) { - this.model_ = model; - this.updateContents_(); - }, - - get rangeOfInterest() { - return this.rangeOfInterest_; - }, - - set rangeOfInterest(rangeOfInterest) { - this.rangeOfInterest_ = rangeOfInterest; - }, - - get selection() { - return this.selection_; - }, - - set selection(selection) { - this.selection_ = selection; - }, - - createColumns_: function(stats) { - var columns = [ - { - title: 'Title', - value: function(row) { - var titleEl = document.createElement('span'); - titleEl.textContent = row.title; - titleEl.style.textOverflow = 'ellipsis'; - return titleEl; - }, - cmp: function(a, b) { - return a.title.localeCompare(b.title); - }, - width: '400px' - }, - { - title: 'Num Events', - align: tr.ui.b.TableFormat.ColumnAlignment.RIGHT, - value: function(row) { - return row.rowStats.numEvents; - }, - cmp: function(a, b) { - return a.rowStats.numEvents - b.rowStats.numEvents; - }, - width: '80px' - } - ]; - - if (stats && stats.hasEventSizesinBytes) { - columns.push({ - title: 'Bytes', - align: tr.ui.b.TableFormat.ColumnAlignment.RIGHT, - value: function(row) { - var value = new tr.v.ScalarNumeric(tr.v.Unit.byName.sizeInBytes, - row.rowStats.totalEventSizeinBytes); - var spanEl = tr.v.ui.createScalarSpan(value); - return spanEl; - }, - cmp: function(a, b) { - return a.rowStats.totalEventSizeinBytes - - b.rowStats.totalEventSizeinBytes; - }, - width: '80px' - }); - } - return columns; - }, - - updateContents_: function() { - var table = this.$.table; - - var columns = this.createColumns_(this.model.stats); - table.rowStatsConstructor = function ModelStatsRowStats(row) { - var sum = tr.b.Statistics.sum(row.data, function(x) { - return x.numEvents; - }); - var totalEventSizeinBytes = tr.b.Statistics.sum(row.data, function(x) { - return x.totalEventSizeinBytes; - }); - return { - numEvents: sum, - totalEventSizeinBytes: totalEventSizeinBytes - }; - }; - table.tableColumns = columns; - table.sortColumnIndex = 1; - table.sortDescending = true; - table.selectionMode = tr.ui.b.TableFormat.SelectionMode.ROW; - - table.groupBy = this.$.picker.currentGroups.map(function(group) { - return group.dataFn; - }); - - if (!this.model) { - table.dataToGroup = []; - } else { - table.dataToGroup = this.model.stats.allTraceEventStats; - } - this.$.table.rebuild(); - } - }); -})(); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/side_panel/file_size_stats_side_panel_test.html b/chromium/third_party/catapult/tracing/tracing/ui/side_panel/file_size_stats_side_panel_test.html deleted file mode 100644 index 75c389c83c2..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/side_panel/file_size_stats_side_panel_test.html +++ /dev/null @@ -1,36 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/ui/side_panel/file_size_stats_side_panel.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var TestUtils = tr.c.TestUtils; - - function createModel(opt_customizeModelCallback) { - return TestUtils.newModel(function(model) { - var modelStats = model.stats; - modelStats.willProcessBasicTraceEvent('X', 'cat1', 'title1'); - modelStats.willProcessBasicTraceEvent('X', 'cat1', 'title1'); - modelStats.willProcessBasicTraceEvent('X', 'cat2', 'title1'); - modelStats.willProcessBasicTraceEvent('X', 'cat2', 'title3'); - modelStats.willProcessBasicTraceEvent('Y', 'cat3', 'title3'); - }); - } - - test('instantiate', function() { - var panel = document.createElement('tr-ui-sp-file-size-stats-side-panel'); - panel.model = createModel(); - panel.style.height = '200px'; - this.addHTMLOutput(panel); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/side_panel/metrics_side_panel.html b/chromium/third_party/catapult/tracing/tracing/ui/side_panel/metrics_side_panel.html deleted file mode 100644 index 724ca970eac..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/side_panel/metrics_side_panel.html +++ /dev/null @@ -1,208 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright 2016 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/raf.html"> -<link rel="import" href="/tracing/metrics/metric_registry.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/ui/base/dom_helpers.html"> -<link rel="import" href="/tracing/ui/side_panel/side_panel.html"> -<link rel="import" href="/tracing/value/ui/value_set_table.html"> -<link rel="import" href="/tracing/value/ui/value_set_view.html"> -<link rel="import" href="/tracing/value/value_set.html"> - -<polymer-element name='tr-ui-sp-metrics-side-panel' - extends='tr-ui-side-panel'> - <template> - <style> - :host { - display: flex; - flex-direction: column; - } - </style> - - <top-left-controls id="top_left_controls"></top-left-controls> - <tr-v-ui-value-set-view id="results"></tr-v-ui-value-set-view> - </template> -</polymer-element> - -<script> -'use strict'; -tr.exportTo('tr.ui', function() { - Polymer('tr-ui-sp-metrics-side-panel', { - ready: function() { - this.model_ = undefined; - - this.rangeOfInterest_ = undefined; - this.metricLatenciesMs_ = []; - - this.metrics_ = []; - tr.metrics.MetricRegistry.getAllRegisteredTypeInfos().forEach( - function(m) { - if (m.constructor.name === 'sampleMetric') - return; - this.metrics_.push({ - label: m.constructor.name, - value: m.constructor.name - }); - }, this); - - this.settingsKey_ = 'metrics-side-panel-metric-name'; - this.currentMetricName_ = 'systemHealthMetrics'; - var metricSelector = tr.ui.b.createSelector( - this, 'currentMetricName_', - this.settingsKey_, - this.currentMetricName_, - this.metrics_); - this.$.top_left_controls.appendChild(metricSelector); - metricSelector.addEventListener('change', - this.onMetricChange_.bind(this)); - this.currentMetricTypeInfo_ = - tr.metrics.MetricRegistry.findTypeInfoWithName( - this.currentMetricName_); - - this.recomputeButton_ = tr.ui.b.createButton( - 'Recompute', this.onRecompute_, this); - this.$.top_left_controls.appendChild(this.recomputeButton_); - }, - - /** - * Return an estimate of how many milliseconds it would take to re-run the - * metric. If the metric has not been run, return undefined. - * - * @return {undefined|number} - */ - get metricLatencyMs() { - return tr.b.Statistics.mean(this.metricLatenciesMs_); - }, - - onMetricChange_: function() { - this.currentMetricTypeInfo_ = - tr.metrics.MetricRegistry.findTypeInfoWithName( - this.currentMetricName_); - this.metricLatenciesMs_ = []; - this.updateContents_(); - }, - - onRecompute_: function() { - this.updateContents_(); - }, - - get textLabel() { - return 'Metrics'; - }, - - supportsModel: function(m) { - if (!m) { - return { - supported: false, - reason: 'No model available' - }; - } - - return { - supported: true - }; - }, - - get model() { - return this.model_; - }, - - set model(model) { - this.model_ = model; - this.updateContents_(); - }, - - get selection() { - // Not applicable to metrics. - }, - - set selection(_) { - // Not applicable to metrics. - }, - - /** - * @return {undefined|!tr.b.Range} - */ - get rangeOfInterest() { - return this.rangeOfInterest_; - }, - - /** - * This may be called rapidly as the mouse is moved. - * If the metric supportsRangeOfInterest and takes less than 100ms, then it - * will be re-run immediately; otherwise, the Recompute button will be - * enabled. - * - * @param {!tr.b.Range} range - */ - set rangeOfInterest(range) { - this.rangeOfInterest_ = range; - - if (this.currentMetricTypeInfo_ && - this.currentMetricTypeInfo_.metadata.supportsRangeOfInterest) { - if ((this.metricLatencyMs === undefined) || - (this.metricLatencyMs < 100)) { - this.updateContents_(); - } else { - this.recomputeButton_.style.background = 'red'; - } - } - }, - - updateContents_: function() { - this.style.width = ''; - tr.b.requestAnimationFrame(function() { - var width = this.$.results.getBoundingClientRect().width + 15; - this.style.width = width + 'px'; - }, this); - - if (!this.model_) { - this.$.results.values = new tr.v.ValueSet([ - new tr.v.FailureValue('missing', { - description: 'Missing model', - stack: '' - }) - ]); - return; - } - - var values = new tr.v.ValueSet(); - var options = {}; - - if (this.currentMetricTypeInfo_ && - this.currentMetricTypeInfo_.metadata.supportsRangeOfInterest && - this.rangeOfInterest && - !this.rangeOfInterest.isEmpty) - options.rangeOfInterest = this.rangeOfInterest; - - var startDate = new Date(); - try { - this.currentMetricTypeInfo_.constructor(values, this.model_, options); - } catch (err) { - console.error(err.stack); - this.$.results.values = new tr.v.ValueSet([ - new tr.v.FailureValue('error', { - description: err.message, - stack: err.stack - }) - ]); - return; - } - - this.metricLatenciesMs_.push(new Date() - startDate); - while (this.metricLatenciesMs_.length > 20) - this.metricLatenciesMs_.shift(); - - this.recomputeButton_.style.background = ''; - this.$.results.values = values; - } - }); - - return {}; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/side_panel/side_panel.html b/chromium/third_party/catapult/tracing/tracing/ui/side_panel/side_panel.html deleted file mode 100644 index 1fc54ed4f0e..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/side_panel/side_panel.html +++ /dev/null @@ -1,53 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/base/ui.html"> - -<polymer-element name='tr-ui-side-panel'> - <template> - <style> - :host { - overflow: auto; - } - </style> - </template> - <script> - 'use strict'; - Polymer({ - ready: function() { - }, - - get rangeOfInterest() { - throw new Error('Not implemented'); - }, - - set rangeOfInterest(rangeOfInterest) { - throw new Error('Not implemented'); - }, - - get selection() { - throw new Error('Not implemented'); - }, - - set selection(selection) { - throw new Error('Not implemented'); - }, - - get model() { - throw new Error('Not implemented'); - }, - - set model(model) { - throw new Error('Not implemented'); - }, - - supportsModel: function(m) { - throw new Error('Not implemented'); - } - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/side_panel/side_panel_container.html b/chromium/third_party/catapult/tracing/tracing/ui/side_panel/side_panel_container.html deleted file mode 100644 index 0f3b5219ef6..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/side_panel/side_panel_container.html +++ /dev/null @@ -1,252 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/range.html"> -<link rel='import' href='/tracing/ui/base/polymer_utils.html'> -<link rel="import" href="/tracing/ui/side_panel/side_panel.html"> - -<polymer-element name='tr-ui-side-panel-container' is='HTMLUnknownElement'> - <template> - <style> - :host { - align-items: stretch; - display: -webkit-flex; - background-color: white; - } - - :host([expanded]) > active-panel-container { - -webkit-flex: 1 1 auto; - border-left: 1px solid black; - display: -webkit-flex; - } - - :host(:not([expanded])) > active-panel-container { - display: none; - } - - active-panel-container { - display: flex; - } - - tab-strip { - -webkit-flex: 0 0 auto; - -webkit-flex-direction: column; - -webkit-user-select: none; - background-color: rgb(236, 236, 236); - border-left: 1px solid black; - cursor: default; - display: -webkit-flex; - min-width: 18px; /* workaround for flexbox and writing-mode mixing bug */ - padding: 10px 0 10px 0; - font-size: 12px; - } - - tab-strip > tab-strip-label { - -webkit-writing-mode: vertical-rl; - display: inline; - margin-right: 1px; - min-height: 20px; - padding: 15px 3px 15px 1px; - } - - tab-strip > - tab-strip-label:not([enabled]) { - color: rgb(128, 128, 128); - } - - tab-strip > tab-strip-label[selected] { - background-color: white; - border: 1px solid rgb(163, 163, 163); - border-left: none; - padding: 14px 2px 14px 1px; - } - </style> - - <active-panel-container id='active_panel_container'> - <tr-ui-b-drag-handle id="side_panel_drag_handle"></tr-ui-b-drag-handle> - </active-panel-container> - <tab-strip id='tab_strip'></tab-strip> - </template> - - <script> - 'use strict'; - Polymer({ - ready: function() { - this.activePanelContainer_ = this.$.active_panel_container; - this.tabStrip_ = this.$.tab_strip; - - this.dragHandle_ = this.$.side_panel_drag_handle; - this.dragHandle_.horizontal = false; - this.rangeOfInterest_ = new tr.b.Range(); - this.brushingStateController_ = undefined; - this.onSelectionChanged_ = this.onSelectionChanged_.bind(this); - this.onModelChanged_ = this.onModelChanged_.bind(this); - }, - - get brushingStateController() { - return this.brushingStateController_; - }, - - set brushingStateController(brushingStateController) { - if (this.brushingStateController) { - this.brushingStateController_.removeEventListener( - 'change', this.onSelectionChanged_); - this.brushingStateController_.removeEventListener( - 'model-changed', this.onModelChanged_); - } - this.brushingStateController_ = brushingStateController; - if (this.brushingStateController) { - this.brushingStateController_.addEventListener( - 'change', this.onSelectionChanged_); - this.brushingStateController_.addEventListener( - 'model-changed', this.onModelChanged_); - } - }, - - get selection() { - return this.brushingStateController_.selection; - }, - - onSelectionChanged_: function() { - if (this.activePanel) - this.activePanel.selection = this.selection; - }, - - get model() { - return this.brushingStateController_.model; - }, - - onModelChanged_: function() { - this.activePanelType_ = undefined; - this.updateContents_(); - }, - - get expanded() { - this.hasAttribute('expanded'); - }, - - get activePanel() { - if (this.activePanelContainer_.children.length < 2) - return undefined; - return this.activePanelContainer_.children[1]; - }, - - get activePanelType() { - return this.activePanelType_; - }, - - set activePanelType(panelType) { - if (this.model === undefined) - throw new Error('Cannot activate panel without a model'); - - var panel = undefined; - if (panelType) - panel = document.createElement(panelType); - - if (panel !== undefined && !panel.supportsModel(this.model)) - throw new Error('Cannot activate panel: does not support this model'); - - if (this.activePanelType) { - this.getLabelElementForPanelType_( - this.activePanelType).removeAttribute('selected'); - } - - if (this.activePanel) - this.activePanelContainer_.removeChild(this.activePanel); - - if (panelType === undefined) { - this.removeAttribute('expanded'); - this.activePanelType_ = undefined; - return; - } - - this.getLabelElementForPanelType_(panelType). - setAttribute('selected', true); - this.setAttribute('expanded', true); - - this.activePanelContainer_.appendChild(panel); - this.dragHandle_.target = panel; - panel.rangeOfInterest = this.rangeOfInterest_; - panel.selection = this.selection_; - panel.model = this.model; - - this.activePanelType_ = panelType; - }, - - getPanelTypeForConstructor_: function(constructor) { - for (var i = 0; i < this.tabStrip_.children.length; i++) { - if (this.tabStrip_.children[i].panelType.constructor == constructor) - return this.tabStrip_.children[i].panelType; - } - }, - - getLabelElementForPanelType_: function(panelType) { - for (var i = 0; i < this.tabStrip_.children.length; i++) { - if (this.tabStrip_.children[i].panelType == panelType) - return this.tabStrip_.children[i]; - } - return undefined; - }, - - updateContents_: function() { - var previouslyActivePanelType = this.activePanelType; - - this.tabStrip_.textContent = ''; - var supportedPanelTypes = []; - - var panelTypes = - tr.ui.b.getPolymerElementsThatSubclass('tr-ui-side-panel'); - panelTypes.forEach(function(panelType) { - var labelEl = document.createElement('tab-strip-label'); - var panel = document.createElement(panelType); - - labelEl.textContent = panel.textLabel; - labelEl.panelType = panelType; - - var supported = panel.supportsModel(this.model); - if (this.model && supported.supported) { - supportedPanelTypes.push(panelType); - labelEl.setAttribute('enabled', true); - labelEl.addEventListener('click', function() { - this.activePanelType = - this.activePanelType === panelType ? undefined : panelType; - }.bind(this)); - } else { - labelEl.title = 'Not supported for the current trace: ' + - supported.reason; - labelEl.style.display = 'none'; - } - this.tabStrip_.appendChild(labelEl); - }, this); - - // Restore the active panel, or collapse - if (previouslyActivePanelType && - supportedPanelTypes.indexOf(previouslyActivePanelType) != -1) { - this.activePanelType = previouslyActivePanelType; - this.setAttribute('expanded', true); - } else { - if (this.activePanel) - this.activePanelContainer_.removeChild(this.activePanel); - this.removeAttribute('expanded'); - } - }, - - get rangeOfInterest() { - return this.rangeOfInterest_; - }, - - set rangeOfInterest(range) { - if (range == undefined) - throw new Error('Must not be undefined'); - this.rangeOfInterest_ = range; - if (this.activePanel) - this.activePanel.rangeOfInterest = range; - } - }); - </script> -</polymer-element> - diff --git a/chromium/third_party/catapult/tracing/tracing/ui/side_panel/side_panel_container_test.html b/chromium/third_party/catapult/tracing/tracing/ui/side_panel/side_panel_container_test.html deleted file mode 100644 index 8dc296c336a..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/side_panel/side_panel_container_test.html +++ /dev/null @@ -1,58 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/ui/extras/side_panel/time_summary_side_panel.html"> -<link rel="import" href="/tracing/ui/side_panel/side_panel.html"> -<link rel="import" href="/tracing/ui/side_panel/side_panel_container.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - function FakeBrushingStateController() { - this.addAllEventsMatchingFilterToSelectionReturnValue = []; - - this.viewport = undefined; - this.model = undefined; - this.selection = new tr.model.EventSet(); - this.highlight = new tr.model.EventSet(); - } - - FakeBrushingStateController.prototype = { - addEventListener: function(name, cb) { - } - }; - - function createModel() { - var m = tr.c.TestUtils.newModelWithEvents([], { - shiftWorldToZero: false, - pruneContainers: false, - customizeModelCallback: function(m) { - var browserProcess = m.getOrCreateProcess(1); - var browserMain = browserProcess.getOrCreateThread(2); - browserMain.sliceGroup.beginSlice('cat', 'Task', 0); - browserMain.sliceGroup.endSlice(10); - browserMain.sliceGroup.beginSlice('cat', 'Task', 20); - browserMain.sliceGroup.endSlice(30); - } - }); - return m; - } - - test('instantiateCollapsed', function() { - var brushingStateController = new FakeBrushingStateController(); - brushingStateController.model = createModel(); - - var container = document.createElement('tr-ui-side-panel-container'); - container.brushingStateController = brushingStateController; - this.addHTMLOutput(container); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/timeline_display_transform.html b/chromium/third_party/catapult/tracing/tracing/ui/timeline_display_transform.html deleted file mode 100644 index 49c10e29123..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/timeline_display_transform.html +++ /dev/null @@ -1,118 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/utils.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui', function() { - function TimelineDisplayTransform(opt_that) { - if (opt_that) { - this.set(opt_that); - return; - } - this.scaleX = 1; - this.panX = 0; - this.panY = 0; - } - - TimelineDisplayTransform.prototype = { - set: function(that) { - this.scaleX = that.scaleX; - this.panX = that.panX; - this.panY = that.panY; - }, - - clone: function() { - return new TimelineDisplayTransform(this); - }, - - equals: function(that) { - var eq = true; - if (that === undefined || that === null) - return false; - eq &= this.panX === that.panX; - eq &= this.panY === that.panY; - eq &= this.scaleX === that.scaleX; - return !!eq; - }, - - almostEquals: function(that) { - var eq = true; - if (that === undefined || that === null) - return false; - eq &= Math.abs(this.panX - that.panX) < 0.001; - eq &= Math.abs(this.panY - that.panY) < 0.001; - eq &= Math.abs(this.scaleX - that.scaleX) < 0.001; - return !!eq; - }, - - incrementPanXInViewUnits: function(xDeltaView) { - this.panX += this.xViewVectorToWorld(xDeltaView); - }, - - xPanWorldPosToViewPos: function(worldX, viewX, viewWidth) { - if (typeof viewX == 'string') { - if (viewX === 'left') { - viewX = 0; - } else if (viewX === 'center') { - viewX = viewWidth / 2; - } else if (viewX === 'right') { - viewX = viewWidth - 1; - } else { - throw new Error('viewX must be left|center|right or number.'); - } - } - this.panX = (viewX / this.scaleX) - worldX; - }, - - xPanWorldBoundsIntoView: function(worldMin, worldMax, viewWidth) { - if (this.xWorldToView(worldMin) < 0) - this.xPanWorldPosToViewPos(worldMin, 'left', viewWidth); - else if (this.xWorldToView(worldMax) > viewWidth) - this.xPanWorldPosToViewPos(worldMax, 'right', viewWidth); - }, - - xSetWorldBounds: function(worldMin, worldMax, viewWidth) { - var worldWidth = worldMax - worldMin; - var scaleX = viewWidth / worldWidth; - var panX = -worldMin; - this.setPanAndScale(panX, scaleX); - }, - - setPanAndScale: function(p, s) { - this.scaleX = s; - this.panX = p; - }, - - xWorldToView: function(x) { - return (x + this.panX) * this.scaleX; - }, - - xWorldVectorToView: function(x) { - return x * this.scaleX; - }, - - xViewToWorld: function(x) { - return (x / this.scaleX) - this.panX; - }, - - xViewVectorToWorld: function(x) { - return x / this.scaleX; - }, - - applyTransformToCanvas: function(ctx) { - ctx.transform(this.scaleX, 0, 0, 1, this.panX * this.scaleX, 0); - } - }; - - return { - TimelineDisplayTransform: TimelineDisplayTransform - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/timeline_display_transform_animations.html b/chromium/third_party/catapult/tracing/tracing/ui/timeline_display_transform_animations.html deleted file mode 100644 index 7122d9ba51c..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/timeline_display_transform_animations.html +++ /dev/null @@ -1,174 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> -<link rel="import" href="/tracing/base/utils.html"> -<link rel="import" href="/tracing/ui/base/animation.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui', function() { - var kDefaultPanAnimationDurationMs = 100.0; - - /** - * Pans a TimelineDisplayTransform by a given amount. - * @constructor - * @extends {tr.ui.b.Animation} - * @param {Number} deltaX The total amount of change to the transform's panX. - * @param {Number} deltaY The total amount of change to the transform's panY. - * @param {Number=} opt_durationMs How long the pan animation should run. - * Defaults to kDefaultPanAnimationDurationMs. - */ - function TimelineDisplayTransformPanAnimation( - deltaX, deltaY, opt_durationMs) { - this.deltaX = deltaX; - this.deltaY = deltaY; - if (opt_durationMs === undefined) - this.durationMs = kDefaultPanAnimationDurationMs; - else - this.durationMs = opt_durationMs; - - this.startPanX = undefined; - this.startPanY = undefined; - this.startTimeMs = undefined; - } - - TimelineDisplayTransformPanAnimation.prototype = { - __proto__: tr.ui.b.Animation.prototype, - - get affectsPanY() { - return this.deltaY !== 0; - }, - - canTakeOverFor: function(existingAnimation) { - return existingAnimation instanceof TimelineDisplayTransformPanAnimation; - }, - - takeOverFor: function(existing, timestamp, target) { - var remainingDeltaXOnExisting = existing.goalPanX - target.panX; - var remainingDeltaYOnExisting = existing.goalPanY - target.panY; - var remainingTimeOnExisting = timestamp - ( - existing.startTimeMs + existing.durationMs); - remainingTimeOnExisting = Math.max(remainingTimeOnExisting, 0); - - this.deltaX += remainingDeltaXOnExisting; - this.deltaY += remainingDeltaYOnExisting; - this.durationMs += remainingTimeOnExisting; - }, - - start: function(timestamp, target) { - this.startTimeMs = timestamp; - this.startPanX = target.panX; - this.startPanY = target.panY; - }, - - tick: function(timestamp, target) { - var percentDone = (timestamp - this.startTimeMs) / this.durationMs; - percentDone = tr.b.clamp(percentDone, 0, 1); - - target.panX = tr.b.lerp(percentDone, this.startPanX, this.goalPanX); - if (this.affectsPanY) - target.panY = tr.b.lerp(percentDone, this.startPanY, this.goalPanY); - return timestamp >= this.startTimeMs + this.durationMs; - }, - - get goalPanX() { - return this.startPanX + this.deltaX; - }, - - get goalPanY() { - return this.startPanY + this.deltaY; - } - }; - - /** - * Zooms in/out on a specified location in the world. - * - * Zooming in and out is all about keeping the area under the mouse cursor, - * here called the "focal point" in the same place under the zoom. If one - * simply changes the scale, the area under the mouse cursor will change. To - * keep the focal point from moving during the zoom, the pan needs to change - * in order to compensate. Thus, a ZoomTo animation is given both a focal - * point in addition to the amount by which to zoom. - * - * @constructor - * @extends {tr.ui.b.Animation} - * @param {Number} goalFocalPointXWorld The X coordinate in the world which is - * of interest. - * @param {Number} goalFocalPointXView Where on the screen the - * goalFocalPointXWorld should stay centered during the zoom. - * @param {Number} goalFocalPointY Where the panY should be when the zoom - * completes. - * @param {Number} zoomInRatioX The ratio of the current scaleX to the goal - * scaleX. - */ - function TimelineDisplayTransformZoomToAnimation( - goalFocalPointXWorld, - goalFocalPointXView, - goalFocalPointY, - zoomInRatioX, - opt_durationMs) { - this.goalFocalPointXWorld = goalFocalPointXWorld; - this.goalFocalPointXView = goalFocalPointXView; - this.goalFocalPointY = goalFocalPointY; - this.zoomInRatioX = zoomInRatioX; - if (opt_durationMs === undefined) - this.durationMs = kDefaultPanAnimationDurationMs; - else - this.durationMs = opt_durationMs; - - this.startTimeMs = undefined; - this.startScaleX = undefined; - this.goalScaleX = undefined; - this.startPanY = undefined; - } - - TimelineDisplayTransformZoomToAnimation.prototype = { - __proto__: tr.ui.b.Animation.prototype, - - get affectsPanY() { - return this.startPanY != this.goalFocalPointY; - }, - - canTakeOverFor: function(existingAnimation) { - return false; - }, - - takeOverFor: function(existingAnimation, timestamp, target) { - this.goalScaleX = target.scaleX * this.zoomInRatioX; - }, - - start: function(timestamp, target) { - this.startTimeMs = timestamp; - this.startScaleX = target.scaleX; - this.goalScaleX = this.zoomInRatioX * target.scaleX; - this.startPanY = target.panY; - }, - - tick: function(timestamp, target) { - var percentDone = (timestamp - this.startTimeMs) / this.durationMs; - percentDone = tr.b.clamp(percentDone, 0, 1); - - target.scaleX = tr.b.lerp(percentDone, this.startScaleX, this.goalScaleX); - if (this.affectsPanY) { - target.panY = tr.b.lerp( - percentDone, this.startPanY, this.goalFocalPointY); - } - - target.xPanWorldPosToViewPos( - this.goalFocalPointXWorld, this.goalFocalPointXView); - return timestamp >= this.startTimeMs + this.durationMs; - } - }; - - return { - TimelineDisplayTransformPanAnimation: - TimelineDisplayTransformPanAnimation, - TimelineDisplayTransformZoomToAnimation: - TimelineDisplayTransformZoomToAnimation - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/timeline_display_transform_animations_test.html b/chromium/third_party/catapult/tracing/tracing/ui/timeline_display_transform_animations_test.html deleted file mode 100644 index 99ca6bd8b20..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/timeline_display_transform_animations_test.html +++ /dev/null @@ -1,85 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/base/animation_controller.html"> -<link rel="import" href="/tracing/ui/timeline_display_transform.html"> -<link rel="import" href="/tracing/ui/timeline_display_transform_animations.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var TimelineDisplayTransform = tr.ui.TimelineDisplayTransform; - var TimelineDisplayTransformPanAnimation = - tr.ui.TimelineDisplayTransformPanAnimation; - var TimelineDisplayTransformZoomToAnimation = - tr.ui.TimelineDisplayTransformZoomToAnimation; - - test('panBasic', function() { - var target = new TimelineDisplayTransform(); - target.cloneAnimationState = function() { - return this.clone(); - }; - - var a = new TimelineDisplayTransformPanAnimation(10, 20, 100); - - var controller = new tr.ui.b.AnimationController(); - controller.target = target; - controller.queueAnimation(a, 0); - - assert.isTrue(a.affectsPanY); - tr.b.forcePendingRAFTasksToRun(50); - assert.isAbove(target.panX, 0); - tr.b.forcePendingRAFTasksToRun(100); - assert.isFalse(controller.hasActiveAnimation); - assert.equal(target.panX, 10); - assert.equal(target.panY, 20); - }); - - test('zoomBasic', function() { - var target = new TimelineDisplayTransform(); - target.panY = 30; - target.cloneAnimationState = function() { - return this.clone(); - }; - - var a = new TimelineDisplayTransformZoomToAnimation(10, 20, 30, 5, 100); - - var controller = new tr.ui.b.AnimationController(); - controller.target = target; - controller.queueAnimation(a, 0); - - assert.isFalse(a.affectsPanY); - tr.b.forcePendingRAFTasksToRun(100); - assert.equal(target.scaleX, 5); - }); - - test('panTakeover', function() { - var target = new TimelineDisplayTransform(); - target.cloneAnimationState = function() { - return this.clone(); - }; - - var b = new TimelineDisplayTransformPanAnimation(10, 0, 100); - var a = new TimelineDisplayTransformPanAnimation(10, 0, 100); - - var controller = new tr.ui.b.AnimationController(); - controller.target = target; - controller.queueAnimation(a, 0); - - tr.b.forcePendingRAFTasksToRun(50); - controller.queueAnimation(b, 50); - - tr.b.forcePendingRAFTasksToRun(100); - assert.isTrue(controller.hasActiveAnimation); - - tr.b.forcePendingRAFTasksToRun(150); - assert.isFalse(controller.hasActiveAnimation); - assert.equal(target.panX, 20); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/timeline_display_transform_test.html b/chromium/third_party/catapult/tracing/tracing/ui/timeline_display_transform_test.html deleted file mode 100644 index 65a9c859909..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/timeline_display_transform_test.html +++ /dev/null @@ -1,40 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/timeline_display_transform.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var TimelineDisplayTransform = tr.ui.TimelineDisplayTransform; - - test('basics', function() { - var a = new TimelineDisplayTransform(); - a.panX = 0; - a.panY = 0; - a.scaleX = 1; - - var b = new TimelineDisplayTransform(); - b.panX = 10; - b.panY = 0; - b.scaleX = 1; - - assert.isFalse(a.equals(b)); - assert.isFalse(a.almostEquals(b)); - - var c = b.clone(); - assert.isTrue(b.equals(c)); - assert.isTrue(b.almostEquals(c)); - - c.set(a); - assert.isTrue(a.equals(c)); - assert.isTrue(a.almostEquals(c)); - }); -}); -</script> - diff --git a/chromium/third_party/catapult/tracing/tracing/ui/timeline_interest_range.html b/chromium/third_party/catapult/tracing/tracing/ui/timeline_interest_range.html deleted file mode 100644 index 240104d6322..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/timeline_interest_range.html +++ /dev/null @@ -1,248 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/range.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui', function() { - /** - * @constructor - */ - function SnapIndicator(y, height) { - this.y = y; - this.height = height; - } - - /** - * The interesting part of the world. - * - * @constructor - */ - function TimelineInterestRange(vp) { - this.viewport_ = vp; - - this.range_ = new tr.b.Range(); - - this.leftSelected_ = false; - this.rightSelected_ = false; - - this.leftSnapIndicator_ = undefined; - this.rightSnapIndicator_ = undefined; - } - - TimelineInterestRange.prototype = { - get isEmpty() { - return this.range_.isEmpty; - }, - - reset: function() { - this.range_.reset(); - this.leftSelected_ = false; - this.rightSelected_ = false; - this.leftSnapIndicator_ = undefined; - this.rightSnapIndicator_ = undefined; - this.viewport_.dispatchChangeEvent(); - }, - - get min() { - return this.range_.min; - }, - - set min(min) { - this.range_.min = min; - this.viewport_.dispatchChangeEvent(); - }, - - get max() { - return this.range_.max; - }, - - set max(max) { - this.range_.max = max; - this.viewport_.dispatchChangeEvent(); - }, - - set: function(range) { - this.range_.reset(); - this.range_.addRange(range); - this.viewport_.dispatchChangeEvent(); - }, - - setMinAndMax: function(min, max) { - this.range_.min = min; - this.range_.max = max; - this.viewport_.dispatchChangeEvent(); - }, - - get range() { - return this.range_.range; - }, - - asRangeObject: function() { - var range = new tr.b.Range(); - range.addRange(this.range_); - return range; - }, - - get leftSelected() { - return this.leftSelected_; - }, - - set leftSelected(leftSelected) { - if (this.leftSelected_ == leftSelected) - return; - this.leftSelected_ = leftSelected; - this.viewport_.dispatchChangeEvent(); - }, - - get rightSelected() { - return this.rightSelected_; - }, - - set rightSelected(rightSelected) { - if (this.rightSelected_ == rightSelected) - return; - this.rightSelected_ = rightSelected; - this.viewport_.dispatchChangeEvent(); - }, - - get leftSnapIndicator() { - return this.leftSnapIndicator_; - }, - - set leftSnapIndicator(leftSnapIndicator) { - this.leftSnapIndicator_ = leftSnapIndicator; - this.viewport_.dispatchChangeEvent(); - }, - - get rightSnapIndicator() { - return this.rightSnapIndicator_; - }, - - set rightSnapIndicator(rightSnapIndicator) { - this.rightSnapIndicator_ = rightSnapIndicator; - this.viewport_.dispatchChangeEvent(); - }, - - draw: function(ctx, viewLWorld, viewRWorld) { - if (this.range_.isEmpty) - return; - var dt = this.viewport_.currentDisplayTransform; - - var markerLWorld = this.min; - var markerRWorld = this.max; - - var markerLView = Math.round(dt.xWorldToView(markerLWorld)); - var markerRView = Math.round(dt.xWorldToView(markerRWorld)); - - ctx.fillStyle = 'rgba(0, 0, 0, 0.2)'; - if (markerLWorld > viewLWorld) { - ctx.fillRect(dt.xWorldToView(viewLWorld), 0, - markerLView, ctx.canvas.height); - } - - if (markerRWorld < viewRWorld) { - ctx.fillRect(markerRView, 0, - dt.xWorldToView(viewRWorld), ctx.canvas.height); - } - - var pixelRatio = window.devicePixelRatio || 1; - ctx.lineWidth = Math.round(pixelRatio); - if (this.range_.range > 0) { - this.drawLine_(ctx, viewLWorld, viewRWorld, - ctx.canvas.height, this.min, this.leftSelected_); - this.drawLine_(ctx, viewLWorld, viewRWorld, - ctx.canvas.height, this.max, this.rightSelected_); - } else { - this.drawLine_(ctx, viewLWorld, viewRWorld, - ctx.canvas.height, this.min, - this.leftSelected_ || this.rightSelected_); - } - ctx.lineWidth = 1; - }, - - drawLine_: function(ctx, viewLWorld, viewRWorld, height, ts, selected) { - if (ts < viewLWorld || ts >= viewRWorld) - return; - - var dt = this.viewport_.currentDisplayTransform; - var viewX = Math.round(dt.xWorldToView(ts)); - - // Apply subpixel translate to get crisp lines. - // http://www.mobtowers.com/html5-canvas-crisp-lines-every-time/ - ctx.save(); - ctx.translate((Math.round(ctx.lineWidth) % 2) / 2, 0); - - ctx.beginPath(); - tr.ui.b.drawLine(ctx, viewX, 0, viewX, height); - if (selected) - ctx.strokeStyle = 'rgb(255, 0, 0)'; - else - ctx.strokeStyle = 'rgb(0, 0, 0)'; - ctx.stroke(); - - ctx.restore(); - }, - - drawIndicators: function(ctx, viewLWorld, viewRWorld) { - if (this.leftSnapIndicator_) { - this.drawIndicator_(ctx, viewLWorld, viewRWorld, - this.range_.min, - this.leftSnapIndicator_, - this.leftSelected_); - } - if (this.rightSnapIndicator_) { - this.drawIndicator_(ctx, viewLWorld, viewRWorld, - this.range_.max, - this.rightSnapIndicator_, - this.rightSelected_); - } - }, - - drawIndicator_: function(ctx, viewLWorld, viewRWorld, - xWorld, si, selected) { - var dt = this.viewport_.currentDisplayTransform; - - var viewX = Math.round(dt.xWorldToView(xWorld)); - - // Apply subpixel translate to get crisp lines. - // http://www.mobtowers.com/html5-canvas-crisp-lines-every-time/ - ctx.save(); - ctx.translate((Math.round(ctx.lineWidth) % 2) / 2, 0); - - var pixelRatio = window.devicePixelRatio || 1; - var viewY = si.y * devicePixelRatio; - var viewHeight = si.height * devicePixelRatio; - var arrowSize = 4 * pixelRatio; - - if (selected) - ctx.fillStyle = 'rgb(255, 0, 0)'; - else - ctx.fillStyle = 'rgb(0, 0, 0)'; - tr.ui.b.drawTriangle(ctx, - viewX - arrowSize * 0.75, viewY, - viewX + arrowSize * 0.75, viewY, - viewX, viewY + arrowSize); - ctx.fill(); - tr.ui.b.drawTriangle(ctx, - viewX - arrowSize * 0.75, viewY + viewHeight, - viewX + arrowSize * 0.75, viewY + viewHeight, - viewX, viewY + viewHeight - arrowSize); - ctx.fill(); - - ctx.restore(); - } - }; - - return { - SnapIndicator: SnapIndicator, - TimelineInterestRange: TimelineInterestRange - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/timeline_track_view.html b/chromium/third_party/catapult/tracing/tracing/ui/timeline_track_view.html deleted file mode 100644 index 36454ffb9e3..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/timeline_track_view.html +++ /dev/null @@ -1,1150 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2012 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/event.html"> -<link rel="import" href="/tracing/base/iteration_helpers.html"> -<link rel="import" href="/tracing/base/settings.html"> -<link rel="import" href="/tracing/base/task.html"> -<link rel="import" href="/tracing/core/filter.html"> -<link rel="import" href="/tracing/model/event.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/model/x_marker_annotation.html"> -<link rel="import" href="/tracing/ui/base/hotkey_controller.html"> -<link rel="import" href="/tracing/ui/base/mouse_mode_selector.html"> -<link rel="import" href="/tracing/ui/base/timing_tool.html"> -<link rel="import" href="/tracing/ui/base/ui.html"> -<link rel="import" href="/tracing/ui/timeline_display_transform_animations.html"> -<link rel="import" href="/tracing/ui/timeline_viewport.html"> -<link rel="import" href="/tracing/ui/tracks/drawing_container.html"> -<link rel="import" href="/tracing/ui/tracks/model_track.html"> -<link rel="import" href="/tracing/ui/tracks/ruler_track.html"> -<link rel="import" href="/tracing/value/unit.html"> - -<!-- - Interactive visualizaiton of Model objects based loosely on gantt charts. - Each thread in the Model is given a set of Tracks, one per subrow in the - thread. The TimelineTrackView class acts as a controller, creating the - individual tracks, while Tracks do actual drawing. - - Visually, the TimelineTrackView produces (prettier) visualizations like the - following: - Thread1: AAAAAAAAAA AAAAA - BBBB BB - Thread2: CCCCCC CCCCC ---> -<polymer-element name='tr-ui-timeline-track-view'> - <template> - <style> - :host { - -webkit-box-orient: vertical; - display: -webkit-box; - position: relative; - } - - :host ::content * { - -webkit-user-select: none; - cursor: default; - } - - #drag_box { - background-color: rgba(0, 0, 255, 0.25); - border: 1px solid rgb(0, 0, 96); - font-size: 75%; - position: fixed; - } - - #hint_text { - position: absolute; - bottom: 6px; - right: 6px; - font-size: 8pt; - } - </style> - <content></content> - - <div id='drag_box'></div> - <div id='hint_text'></div> - - <tv-ui-b-hotkey-controller id='hotkey_controller'> - </tv-ui-b-hotkey-controller> - </template> - - <script> - 'use strict'; - - Polymer({ - ready: function() { - this.displayTransform_ = new tr.ui.TimelineDisplayTransform(); - this.model_ = undefined; - - this.timelineView_ = undefined; - - this.viewport_ = new tr.ui.TimelineViewport(this); - this.viewportDisplayTransformAtMouseDown_ = undefined; - this.brushingStateController_ = undefined; - - this.rulerTrackContainer_ = - new tr.ui.tracks.DrawingContainer(this.viewport_); - this.appendChild(this.rulerTrackContainer_); - this.rulerTrackContainer_.invalidate(); - - this.rulerTrack_ = new tr.ui.tracks.RulerTrack(this.viewport_); - this.rulerTrackContainer_.appendChild(this.rulerTrack_); - - this.upperModelTrack_ = new tr.ui.tracks.ModelTrack(this.viewport_); - this.upperModelTrack_.upperMode = true; - this.rulerTrackContainer_.appendChild(this.upperModelTrack_); - - this.modelTrackContainer_ = - new tr.ui.tracks.DrawingContainer(this.viewport_); - this.appendChild(this.modelTrackContainer_); - this.modelTrackContainer_.style.display = 'block'; - this.modelTrackContainer_.invalidate(); - - this.viewport_.modelTrackContainer = this.modelTrackContainer_; - - this.modelTrack_ = new tr.ui.tracks.ModelTrack(this.viewport_); - this.modelTrackContainer_.appendChild(this.modelTrack_); - - this.timingTool_ = new tr.ui.b.TimingTool(this.viewport_, this); - - this.initMouseModeSelector(); - - this.hideDragBox_(); - - this.initHintText_(); - - this.onSelectionChanged_ = this.onSelectionChanged_.bind(this); - - this.onDblClick_ = this.onDblClick_.bind(this); - this.addEventListener('dblclick', this.onDblClick_); - - this.onMouseWheel_ = this.onMouseWheel_.bind(this); - this.addEventListener('mousewheel', this.onMouseWheel_); - - this.onMouseDown_ = this.onMouseDown_.bind(this); - this.addEventListener('mousedown', this.onMouseDown_); - - this.onMouseMove_ = this.onMouseMove_.bind(this); - this.addEventListener('mousemove', this.onMouseMove_); - - this.onTouchStart_ = this.onTouchStart_.bind(this); - this.addEventListener('touchstart', this.onTouchStart_); - - this.onTouchMove_ = this.onTouchMove_.bind(this); - this.addEventListener('touchmove', this.onTouchMove_); - - this.onTouchEnd_ = this.onTouchEnd_.bind(this); - this.addEventListener('touchend', this.onTouchEnd_); - - - this.addHotKeys_(); - - this.mouseViewPosAtMouseDown_ = {x: 0, y: 0}; - this.lastMouseViewPos_ = {x: 0, y: 0}; - - this.lastTouchViewPositions_ = []; - - this.alert_ = undefined; - - this.isPanningAndScanning_ = false; - this.isZooming_ = false; - }, - - initMouseModeSelector: function() { - this.mouseModeSelector_ = document.createElement( - 'tr-ui-b-mouse-mode-selector'); - this.mouseModeSelector_.targetElement = this; - this.appendChild(this.mouseModeSelector_); - - this.mouseModeSelector_.addEventListener('beginpan', - this.onBeginPanScan_.bind(this)); - this.mouseModeSelector_.addEventListener('updatepan', - this.onUpdatePanScan_.bind(this)); - this.mouseModeSelector_.addEventListener('endpan', - this.onEndPanScan_.bind(this)); - - this.mouseModeSelector_.addEventListener('beginselection', - this.onBeginSelection_.bind(this)); - this.mouseModeSelector_.addEventListener('updateselection', - this.onUpdateSelection_.bind(this)); - this.mouseModeSelector_.addEventListener('endselection', - this.onEndSelection_.bind(this)); - - this.mouseModeSelector_.addEventListener('beginzoom', - this.onBeginZoom_.bind(this)); - this.mouseModeSelector_.addEventListener('updatezoom', - this.onUpdateZoom_.bind(this)); - this.mouseModeSelector_.addEventListener('endzoom', - this.onEndZoom_.bind(this)); - - this.mouseModeSelector_.addEventListener('entertiming', - this.timingTool_.onEnterTiming.bind(this.timingTool_)); - this.mouseModeSelector_.addEventListener('begintiming', - this.timingTool_.onBeginTiming.bind(this.timingTool_)); - this.mouseModeSelector_.addEventListener('updatetiming', - this.timingTool_.onUpdateTiming.bind(this.timingTool_)); - this.mouseModeSelector_.addEventListener('endtiming', - this.timingTool_.onEndTiming.bind(this.timingTool_)); - this.mouseModeSelector_.addEventListener('exittiming', - this.timingTool_.onExitTiming.bind(this.timingTool_)); - - var m = tr.ui.b.MOUSE_SELECTOR_MODE; - this.mouseModeSelector_.supportedModeMask = - m.SELECTION | m.PANSCAN | m.ZOOM | m.TIMING; - this.mouseModeSelector_.settingsKey = - 'timelineTrackView.mouseModeSelector'; - this.mouseModeSelector_.setKeyCodeForMode(m.PANSCAN, '2'.charCodeAt(0)); - this.mouseModeSelector_.setKeyCodeForMode(m.SELECTION, '1'.charCodeAt(0)); - this.mouseModeSelector_.setKeyCodeForMode(m.ZOOM, '3'.charCodeAt(0)); - this.mouseModeSelector_.setKeyCodeForMode(m.TIMING, '4'.charCodeAt(0)); - - this.mouseModeSelector_.setModifierForAlternateMode( - m.SELECTION, tr.ui.b.MODIFIER.SHIFT); - this.mouseModeSelector_.setModifierForAlternateMode( - m.PANSCAN, tr.ui.b.MODIFIER.SPACE); - }, - - get brushingStateController() { - return this.brushingStateController_; - }, - - set brushingStateController(brushingStateController) { - if (this.brushingStateController_) { - this.brushingStateController_.removeEventListener('change', - this.onSelectionChanged_); - } - this.brushingStateController_ = brushingStateController; - if (this.brushingStateController_) { - this.brushingStateController_.addEventListener('change', - this.onSelectionChanged_); - } - }, - - set timelineView(view) { - this.timelineView_ = view; - }, - - onSelectionChanged_: function() { - this.showHintText_('Press \'m\' to mark current selection'); - this.viewport_.dispatchChangeEvent(); - }, - - set selection(selection) { - throw new Error('DO NOT CALL THIS'); - }, - - set highlight(highlight) { - throw new Error('DO NOT CALL THIS'); - }, - - detach: function() { - this.modelTrack_.detach(); - this.upperModelTrack_.detach(); - - this.viewport_.detach(); - }, - - get viewport() { - return this.viewport_; - }, - - get model() { - return this.model_; - }, - - set model(model) { - if (!model) - throw new Error('Model cannot be undefined'); - - var modelInstanceChanged = this.model_ !== model; - this.model_ = model; - this.modelTrack_.model = model; - this.upperModelTrack_.model = model; - - // Set up a reasonable viewport. - if (modelInstanceChanged) - this.viewport_.setWhenPossible(this.setInitialViewport_.bind(this)); - }, - - get hasVisibleContent() { - return this.modelTrack_.hasVisibleContent || - this.upperModelTrack_.hasVisibleContent; - }, - - setInitialViewport_: function() { - // We need the canvas size to be up-to-date at this point. We maybe in - // here before the raf fires, so the size may have not been updated since - // the canvas was resized. - this.modelTrackContainer_.updateCanvasSizeIfNeeded_(); - var w = this.modelTrackContainer_.canvas.width; - - var min; - var range; - - if (this.model_.bounds.isEmpty) { - min = 0; - range = 1000; - } else if (this.model_.bounds.range === 0) { - min = this.model_.bounds.min; - range = 1000; - } else { - min = this.model_.bounds.min; - range = this.model_.bounds.range; - } - - var boost = range * 0.15; - this.displayTransform_.set(this.viewport_.currentDisplayTransform); - this.displayTransform_.xSetWorldBounds( - min - boost, min + range + boost, w); - this.viewport_.setDisplayTransformImmediately(this.displayTransform_); - }, - - /** - * @param {Filter} filter The filter to use for finding matches. - * @param {Selection} selection The selection to add matches to. - * @return {Task} which performs the filtering. - */ - addAllEventsMatchingFilterToSelectionAsTask: function(filter, selection) { - var modelTrack = this.modelTrack_; - var firstT = modelTrack.addAllEventsMatchingFilterToSelectionAsTask( - filter, selection); - var lastT = firstT.after(function() { - this.upperModelTrack_.addAllEventsMatchingFilterToSelection( - filter, selection); - - }, this); - return firstT; - }, - - onMouseMove_: function(e) { - // Zooming requires the delta since the last mousemove so we need to avoid - // tracking it when the zoom interaction is active. - if (this.isZooming_) - return; - - this.storeLastMousePos_(e); - }, - - onTouchStart_: function(e) { - this.storeLastTouchPositions_(e); - this.focusElements_(); - }, - - onTouchMove_: function(e) { - e.preventDefault(); - this.onUpdateTransformForTouch_(e); - }, - - onTouchEnd_: function(e) { - this.storeLastTouchPositions_(e); - this.focusElements_(); - }, - - addHotKeys_: function() { - this.addKeyDownHotKeys_(); - this.addKeyPressHotKeys_(); - }, - - addKeyPressHotKeys_: function() { - var addBinding = function(dict) { - dict.eventType = 'keypress'; - dict.useCapture = false; - dict.thisArg = this; - var binding = new tr.ui.b.HotKey(dict); - this.$.hotkey_controller.addHotKey(binding); - }.bind(this); - - addBinding({ - keyCodes: ['w'.charCodeAt(0), ','.charCodeAt(0)], - callback: function(e) { - this.zoomBy_(1.5, true); - e.stopPropagation(); - } - }); - - addBinding({ - keyCodes: ['s'.charCodeAt(0), 'o'.charCodeAt(0)], - callback: function(e) { - this.zoomBy_(1 / 1.5, true); - e.stopPropagation(); - } - }); - - addBinding({ - keyCode: 'g'.charCodeAt(0), - callback: function(e) { - this.onGridToggle_(true); - e.stopPropagation(); - } - }); - - addBinding({ - keyCode: 'G'.charCodeAt(0), - callback: function(e) { - this.onGridToggle_(false); - e.stopPropagation(); - } - }); - - addBinding({ - keyCodes: ['W'.charCodeAt(0), '<'.charCodeAt(0)], - callback: function(e) { - this.zoomBy_(10, true); - e.stopPropagation(); - } - }); - - addBinding({ - keyCodes: ['S'.charCodeAt(0), 'O'.charCodeAt(0)], - callback: function(e) { - this.zoomBy_(1 / 10, true); - e.stopPropagation(); - } - }); - - addBinding({ - keyCode: 'a'.charCodeAt(0), - callback: function(e) { - this.queueSmoothPan_(this.viewWidth_ * 0.3, 0); - e.stopPropagation(); - } - }); - - addBinding({ - keyCodes: ['d'.charCodeAt(0), 'e'.charCodeAt(0)], - callback: function(e) { - this.queueSmoothPan_(this.viewWidth_ * -0.3, 0); - e.stopPropagation(); - } - }); - - addBinding({ - keyCode: 'A'.charCodeAt(0), - callback: function(e) { - this.queueSmoothPan_(viewWidth * 0.5, 0); - e.stopPropagation(); - } - }); - - addBinding({ - keyCode: 'D'.charCodeAt(0), - callback: function(e) { - this.queueSmoothPan_(viewWidth * -0.5, 0); - e.stopPropagation(); - } - }); - - addBinding({ - keyCode: '0'.charCodeAt(0), - callback: function(e) { - this.setInitialViewport_(); - e.stopPropagation(); - } - }); - - addBinding({ - keyCode: 'f'.charCodeAt(0), - callback: function(e) { - this.zoomToSelection(); - e.stopPropagation(); - } - }); - - addBinding({ - keyCode: 'm'.charCodeAt(0), - callback: function(e) { - this.setCurrentSelectionAsInterestRange_(); - e.stopPropagation(); - } - }); - - addBinding({ - keyCode: 'p'.charCodeAt(0), - callback: function(e) { - this.selectPowerSamplesInCurrentTimeRange_(); - e.stopPropagation(); - } - }); - - addBinding({ - keyCode: 'h'.charCodeAt(0), - callback: function(e) { - this.toggleHighDetails_(); - e.stopPropagation(); - } - }); - }, - - get viewWidth_() { - return this.modelTrackContainer_.canvas.clientWidth; - }, - - addKeyDownHotKeys_: function() { - var addBinding = function(dict) { - dict.eventType = 'keydown'; - dict.useCapture = false; - dict.thisArg = this; - var binding = new tr.ui.b.HotKey(dict); - this.$.hotkey_controller.addHotKey(binding); - }.bind(this); - - addBinding({ - keyCode: 37, // Left arrow. - callback: function(e) { - var curSel = this.brushingStateController_.selection; - var sel = this.viewport.getShiftedSelection(curSel, -1); - - if (sel) { - this.brushingStateController.changeSelectionFromTimeline(sel); - this.panToSelection(); - } else { - this.queueSmoothPan_(this.viewWidth_ * 0.3, 0); - } - e.preventDefault(); - e.stopPropagation(); - } - }); - - addBinding({ - keyCode: 39, // Right arrow. - callback: function(e) { - var curSel = this.brushingStateController_.selection; - var sel = this.viewport.getShiftedSelection(curSel, 1); - if (sel) { - this.brushingStateController.changeSelectionFromTimeline(sel); - this.panToSelection(); - } else { - this.queueSmoothPan_(-this.viewWidth_ * 0.3, 0); - } - e.preventDefault(); - e.stopPropagation(); - } - }); - }, - - onDblClick_: function(e) { - if (this.mouseModeSelector_.mode !== - tr.ui.b.MOUSE_SELECTOR_MODE.SELECTION) - return; - - var curSelection = this.brushingStateController_.selection; - if (!curSelection.length || !tr.b.getOnlyElement(curSelection).title) - return; - - var selection = new tr.model.EventSet(); - var filter = new tr.c.ExactTitleFilter( - tr.b.getOnlyElement(curSelection).title); - this.modelTrack_.addAllEventsMatchingFilterToSelection(filter, - selection); - - this.brushingStateController.changeSelectionFromTimeline(selection); - }, - - onMouseWheel_: function(e) { - if (!e.altKey) - return; - - var delta = e.wheelDelta / 120; - var zoomScale = Math.pow(1.5, delta); - this.zoomBy_(zoomScale); - e.preventDefault(); - }, - - onMouseDown_: function(e) { - if (this.mouseModeSelector_.mode !== - tr.ui.b.MOUSE_SELECTOR_MODE.SELECTION) - return; - - // Mouse down must start on ruler track for crosshair guide lines to draw. - if (e.target !== this.rulerTrack_) - return; - - // Make sure we don't start a selection drag event here. - this.dragBeginEvent_ = undefined; - - // Remove nav string marker if it exists, since we're clearing the - // find control box. - if (this.xNavStringMarker_) { - this.model.removeAnnotation(this.xNavStringMarker_); - this.xNavStringMarker_ = undefined; - } - - var dt = this.viewport_.currentDisplayTransform; - tr.ui.b.trackMouseMovesUntilMouseUp(function(e) { // Mouse move handler. - // If mouse event is on ruler, don't do anything. - if (e.target === this.rulerTrack_) - return; - - var relativePosition = this.extractRelativeMousePosition_(e); - var loc = tr.model.Location.fromViewCoordinates( - this.viewport_, relativePosition.x, relativePosition.y); - // Not all points on the timeline represents a valid location. - // ex. process header tracks, letter dot tracks. - if (!loc) - return; - - if (this.guideLineAnnotation_ === undefined) { - this.guideLineAnnotation_ = - new tr.model.XMarkerAnnotation(loc.xWorld); - this.model.addAnnotation(this.guideLineAnnotation_); - } else { - this.guideLineAnnotation_.timestamp = loc.xWorld; - this.modelTrackContainer_.invalidate(); - } - - // Set the findcontrol's text to nav string of current state. - var state = new tr.ui.b.UIState(loc, - this.viewport_.currentDisplayTransform.scaleX); - this.timelineView_.setFindCtlText( - state.toUserFriendlyString(this.viewport_)); - }.bind(this), - undefined, // Mouse up handler. - function onKeyUpDuringDrag() { - if (this.dragBeginEvent_) { - this.setDragBoxPosition_(this.dragBoxXStart_, this.dragBoxYStart_, - this.dragBoxXEnd_, this.dragBoxYEnd_); - } - }.bind(this)); - }, - - queueSmoothPan_: function(viewDeltaX, deltaY) { - var deltaX = this.viewport_.currentDisplayTransform.xViewVectorToWorld( - viewDeltaX); - var animation = new tr.ui.TimelineDisplayTransformPanAnimation( - deltaX, deltaY); - this.viewport_.queueDisplayTransformAnimation(animation); - }, - - /** - * Zoom in or out on the timeline by the given scale factor. - * @param {Number} scale The scale factor to apply. If <1, zooms out. - * @param {boolean} Whether to change the zoom level smoothly. - */ - zoomBy_: function(scale, smooth) { - if (scale <= 0) { - return; - } - - smooth = !!smooth; - var vp = this.viewport_; - var pixelRatio = window.devicePixelRatio || 1; - - var goalFocalPointXView = this.lastMouseViewPos_.x * pixelRatio; - var goalFocalPointXWorld = vp.currentDisplayTransform.xViewToWorld( - goalFocalPointXView); - if (smooth) { - var animation = new tr.ui.TimelineDisplayTransformZoomToAnimation( - goalFocalPointXWorld, goalFocalPointXView, - vp.currentDisplayTransform.panY, - scale); - vp.queueDisplayTransformAnimation(animation); - } else { - this.displayTransform_.set(vp.currentDisplayTransform); - this.displayTransform_.scaleX *= scale; - this.displayTransform_.xPanWorldPosToViewPos( - goalFocalPointXWorld, goalFocalPointXView, this.viewWidth_); - vp.setDisplayTransformImmediately(this.displayTransform_); - } - }, - - /** - * Zoom into the current selection. - */ - zoomToSelection: function() { - if (!this.brushingStateController.selectionOfInterest.length) - return; - - var bounds = this.brushingStateController.selectionOfInterest.bounds; - if (!bounds.range) - return; - - var worldCenter = bounds.center; - var viewCenter = this.modelTrackContainer_.canvas.width / 2; - var adjustedWorldRange = bounds.range * 1.25; - var newScale = this.modelTrackContainer_.canvas.width / - adjustedWorldRange; - var zoomInRatio = newScale / - this.viewport_.currentDisplayTransform.scaleX; - - var animation = new tr.ui.TimelineDisplayTransformZoomToAnimation( - worldCenter, viewCenter, - this.viewport_.currentDisplayTransform.panY, - zoomInRatio); - this.viewport_.queueDisplayTransformAnimation(animation); - }, - - /** - * Pan the view so the current selection becomes visible. - */ - panToSelection: function() { - if (!this.brushingStateController.selectionOfInterest.length) - return; - - var bounds = this.brushingStateController.selectionOfInterest.bounds; - var worldCenter = bounds.center; - var viewWidth = this.viewWidth_; - - var dt = this.viewport_.currentDisplayTransform; - if (false && !bounds.range) { - if (dt.xWorldToView(bounds.center) < 0 || - dt.xWorldToView(bounds.center) > viewWidth) { - this.displayTransform_.set(dt); - this.displayTransform_.xPanWorldPosToViewPos( - worldCenter, 'center', viewWidth); - var deltaX = this.displayTransform_.panX - dt.panX; - var animation = new tr.ui.TimelineDisplayTransformPanAnimation( - deltaX, 0); - this.viewport_.queueDisplayTransformAnimation(animation); - } - return; - } - - this.displayTransform_.set(dt); - this.displayTransform_.xPanWorldBoundsIntoView( - bounds.min, - bounds.max, - viewWidth); - var deltaX = this.displayTransform_.panX - dt.panX; - var animation = new tr.ui.TimelineDisplayTransformPanAnimation( - deltaX, 0); - this.viewport_.queueDisplayTransformAnimation(animation); - }, - - navToPosition: function(uiState, showNavLine) { - var location = uiState.location; - var scaleX = uiState.scaleX; - var track = location.getContainingTrack(this.viewport_); - - var worldCenter = location.xWorld; - var viewCenter = this.modelTrackContainer_.canvas.width / 5; - var zoomInRatio = scaleX / - this.viewport_.currentDisplayTransform.scaleX; - - // Vertically scroll so track is in view. - track.scrollIntoViewIfNeeded(); - - // Perform zoom and panX animation. - var animation = new tr.ui.TimelineDisplayTransformZoomToAnimation( - worldCenter, viewCenter, - this.viewport_.currentDisplayTransform.panY, - zoomInRatio); - this.viewport_.queueDisplayTransformAnimation(animation); - - if (!showNavLine) - return; - // Add an X Marker Annotation at the specified timestamp. - if (this.xNavStringMarker_) - this.model.removeAnnotation(this.xNavStringMarker_); - this.xNavStringMarker_ = - new tr.model.XMarkerAnnotation(worldCenter); - this.model.addAnnotation(this.xNavStringMarker_); - }, - - selectPowerSamplesInCurrentTimeRange_: function() { - var selectionBounds = this.brushingStateController_.selection.bounds; - if (this.model.device.powerSeries && !selectionBounds.empty) { - var events = this.model.device.powerSeries.getSamplesWithinRange( - selectionBounds.min, selectionBounds.max); - var selection = new tr.model.EventSet(events); - this.brushingStateController_.changeSelectionFromTimeline(selection); - } - }, - - setCurrentSelectionAsInterestRange_: function() { - var selectionBounds = this.brushingStateController_.selection.bounds; - if (selectionBounds.empty) { - this.viewport_.interestRange.reset(); - return; - } - - if (this.viewport_.interestRange.min == selectionBounds.min && - this.viewport_.interestRange.max == selectionBounds.max) - this.viewport_.interestRange.reset(); - else - this.viewport_.interestRange.set(selectionBounds); - }, - - toggleHighDetails_: function() { - this.viewport_.highDetails = !this.viewport_.highDetails; - }, - - hideDragBox_: function() { - this.$.drag_box.style.left = '-1000px'; - this.$.drag_box.style.top = '-1000px'; - this.$.drag_box.style.width = 0; - this.$.drag_box.style.height = 0; - }, - - setDragBoxPosition_: function(xStart, yStart, xEnd, yEnd) { - var loY = Math.min(yStart, yEnd); - var hiY = Math.max(yStart, yEnd); - var loX = Math.min(xStart, xEnd); - var hiX = Math.max(xStart, xEnd); - var modelTrackRect = this.modelTrack_.getBoundingClientRect(); - var dragRect = {left: loX, top: loY, width: hiX - loX, height: hiY - loY}; - - dragRect.right = dragRect.left + dragRect.width; - dragRect.bottom = dragRect.top + dragRect.height; - - var modelTrackContainerRect = - this.modelTrackContainer_.getBoundingClientRect(); - var clipRect = { - left: modelTrackContainerRect.left, - top: modelTrackContainerRect.top, - right: modelTrackContainerRect.right, - bottom: modelTrackContainerRect.bottom - }; - - var headingWidth = window.getComputedStyle( - this.querySelector('tr-ui-heading')).width; - var trackTitleWidth = parseInt(headingWidth); - clipRect.left = clipRect.left + trackTitleWidth; - - var intersectRect_ = function(r1, r2) { - if (r2.left > r1.right || r2.right < r1.left || - r2.top > r1.bottom || r2.bottom < r1.top) - return false; - - var results = {}; - results.left = Math.max(r1.left, r2.left); - results.top = Math.max(r1.top, r2.top); - results.right = Math.min(r1.right, r2.right); - results.bottom = Math.min(r1.bottom, r2.bottom); - results.width = results.right - results.left; - results.height = results.bottom - results.top; - return results; - }; - - // TODO(dsinclair): intersectRect_ can return false (which should actually - // be undefined) but we use finalDragBox without checking the return value - // which could potentially blowup. Fix this ..... - var finalDragBox = intersectRect_(clipRect, dragRect); - - this.$.drag_box.style.left = finalDragBox.left + 'px'; - this.$.drag_box.style.width = finalDragBox.width + 'px'; - this.$.drag_box.style.top = finalDragBox.top + 'px'; - this.$.drag_box.style.height = finalDragBox.height + 'px'; - this.$.drag_box.style.whiteSpace = 'nowrap'; - - var pixelRatio = window.devicePixelRatio || 1; - var canv = this.modelTrackContainer_.canvas; - var dt = this.viewport_.currentDisplayTransform; - var loWX = dt.xViewToWorld( - (loX - canv.offsetLeft) * pixelRatio); - var hiWX = dt.xViewToWorld( - (hiX - canv.offsetLeft) * pixelRatio); - - this.$.drag_box.textContent = - tr.v.Unit.byName.timeDurationInMs.format(hiWX - loWX); - - var e = new tr.b.Event('selectionChanging'); - e.loWX = loWX; - e.hiWX = hiWX; - this.dispatchEvent(e); - }, - - onGridToggle_: function(left) { - var selection = this.brushingStateController_.selection; - var tb = left ? selection.bounds.min : selection.bounds.max; - - // Toggle the grid off if the grid is on, the marker position is the same - // and the same element is selected (same timebase). - if (this.viewport_.gridEnabled && - this.viewport_.gridSide === left && - this.viewport_.gridInitialTimebase === tb) { - this.viewport_.gridside = undefined; - this.viewport_.gridEnabled = false; - this.viewport_.gridInitialTimebase = undefined; - return; - } - - // Shift the timebase left until its just left of model_.bounds.min. - var numIntervalsSinceStart = Math.ceil((tb - this.model_.bounds.min) / - this.viewport_.gridStep_); - - this.viewport_.gridEnabled = true; - this.viewport_.gridSide = left; - this.viewport_.gridInitialTimebase = tb; - this.viewport_.gridTimebase = tb - - (numIntervalsSinceStart + 1) * this.viewport_.gridStep_; - }, - - storeLastMousePos_: function(e) { - this.lastMouseViewPos_ = this.extractRelativeMousePosition_(e); - }, - - storeLastTouchPositions_: function(e) { - this.lastTouchViewPositions_ = this.extractRelativeTouchPositions_(e); - }, - - extractRelativeMousePosition_: function(e) { - var canv = this.modelTrackContainer_.canvas; - return { - x: e.clientX - canv.offsetLeft, - y: e.clientY - canv.offsetTop - }; - }, - - extractRelativeTouchPositions_: function(e) { - var canv = this.modelTrackContainer_.canvas; - - var touches = []; - for (var i = 0; i < e.touches.length; ++i) { - touches.push({ - x: e.touches[i].clientX - canv.offsetLeft, - y: e.touches[i].clientY - canv.offsetTop - }); - } - return touches; - }, - - storeInitialMouseDownPos_: function(e) { - - var position = this.extractRelativeMousePosition_(e); - - this.mouseViewPosAtMouseDown_.x = position.x; - this.mouseViewPosAtMouseDown_.y = position.y; - }, - - focusElements_: function() { - this.$.hotkey_controller.childRequestsGeneralFocus(this); - }, - - storeInitialInteractionPositionsAndFocus_: function(e) { - - this.storeInitialMouseDownPos_(e); - this.storeLastMousePos_(e); - - this.focusElements_(); - }, - - onBeginPanScan_: function(e) { - var vp = this.viewport_; - this.viewportDisplayTransformAtMouseDown_ = - vp.currentDisplayTransform.clone(); - this.isPanningAndScanning_ = true; - - this.storeInitialInteractionPositionsAndFocus_(e); - e.preventDefault(); - }, - - onUpdatePanScan_: function(e) { - if (!this.isPanningAndScanning_) - return; - - var viewWidth = this.viewWidth_; - - var pixelRatio = window.devicePixelRatio || 1; - var xDeltaView = pixelRatio * (this.lastMouseViewPos_.x - - this.mouseViewPosAtMouseDown_.x); - - var yDelta = this.lastMouseViewPos_.y - - this.mouseViewPosAtMouseDown_.y; - - this.displayTransform_.set(this.viewportDisplayTransformAtMouseDown_); - this.displayTransform_.incrementPanXInViewUnits(xDeltaView); - this.displayTransform_.panY -= yDelta; - this.viewport_.setDisplayTransformImmediately(this.displayTransform_); - - e.preventDefault(); - e.stopPropagation(); - - this.storeLastMousePos_(e); - }, - - onEndPanScan_: function(e) { - this.isPanningAndScanning_ = false; - - this.storeLastMousePos_(e); - - if (!e.isClick) - e.preventDefault(); - }, - - onBeginSelection_: function(e) { - var canv = this.modelTrackContainer_.canvas; - var rect = this.modelTrack_.getBoundingClientRect(); - var canvRect = canv.getBoundingClientRect(); - - var inside = rect && - e.clientX >= rect.left && - e.clientX < rect.right && - e.clientY >= rect.top && - e.clientY < rect.bottom && - e.clientX >= canvRect.left && - e.clientX < canvRect.right; - - if (!inside) - return; - - this.dragBeginEvent_ = e; - - this.storeInitialInteractionPositionsAndFocus_(e); - e.preventDefault(); - }, - - onUpdateSelection_: function(e) { - if (!this.dragBeginEvent_) - return; - - // Update the drag box - this.dragBoxXStart_ = this.dragBeginEvent_.clientX; - this.dragBoxXEnd_ = e.clientX; - this.dragBoxYStart_ = this.dragBeginEvent_.clientY; - this.dragBoxYEnd_ = e.clientY; - this.setDragBoxPosition_(this.dragBoxXStart_, this.dragBoxYStart_, - this.dragBoxXEnd_, this.dragBoxYEnd_); - - }, - - onEndSelection_: function(e) { - e.preventDefault(); - - if (!this.dragBeginEvent_) - return; - - // Stop the dragging. - this.hideDragBox_(); - var eDown = this.dragBeginEvent_; - this.dragBeginEvent_ = undefined; - - // Figure out extents of the drag. - var loY = Math.min(eDown.clientY, e.clientY); - var hiY = Math.max(eDown.clientY, e.clientY); - var loX = Math.min(eDown.clientX, e.clientX); - var hiX = Math.max(eDown.clientX, e.clientX); - - // Convert to worldspace. - var canv = this.modelTrackContainer_.canvas; - var worldOffset = canv.getBoundingClientRect().left; - var loVX = loX - worldOffset; - var hiVX = hiX - worldOffset; - - // Figure out what has been selected. - var selection = new tr.model.EventSet(); - if (eDown.appendSelection) { - var previousSelection = this.brushingStateController_.selection; - if (previousSelection !== undefined) - selection.addEventSet(previousSelection); - } - this.modelTrack_.addIntersectingEventsInRangeToSelection( - loVX, hiVX, loY, hiY, selection); - - // Activate the new selection. - this.brushingStateController_.changeSelectionFromTimeline(selection); - }, - - onBeginZoom_: function(e) { - this.isZooming_ = true; - - this.storeInitialInteractionPositionsAndFocus_(e); - e.preventDefault(); - }, - - onUpdateZoom_: function(e) { - if (!this.isZooming_) - return; - var newPosition = this.extractRelativeMousePosition_(e); - - var zoomScaleValue = 1 + (this.lastMouseViewPos_.y - - newPosition.y) * 0.01; - - this.zoomBy_(zoomScaleValue, false); - this.storeLastMousePos_(e); - }, - - onEndZoom_: function(e) { - this.isZooming_ = false; - - if (!e.isClick) - e.preventDefault(); - }, - - computeTouchCenter_: function(positions) { - var xSum = 0; - var ySum = 0; - for (var i = 0; i < positions.length; ++i) { - xSum += positions[i].x; - ySum += positions[i].y; - } - return { - x: xSum / positions.length, - y: ySum / positions.length - }; - }, - - computeTouchSpan_: function(positions) { - var xMin = Number.MAX_VALUE; - var yMin = Number.MAX_VALUE; - var xMax = Number.MIN_VALUE; - var yMax = Number.MIN_VALUE; - for (var i = 0; i < positions.length; ++i) { - xMin = Math.min(xMin, positions[i].x); - yMin = Math.min(yMin, positions[i].y); - xMax = Math.max(xMax, positions[i].x); - yMax = Math.max(yMax, positions[i].y); - } - return Math.sqrt((xMin - xMax) * (xMin - xMax) + - (yMin - yMax) * (yMin - yMax)); - }, - - onUpdateTransformForTouch_: function(e) { - var newPositions = this.extractRelativeTouchPositions_(e); - var currentPositions = this.lastTouchViewPositions_; - - var newCenter = this.computeTouchCenter_(newPositions); - var currentCenter = this.computeTouchCenter_(currentPositions); - - var newSpan = this.computeTouchSpan_(newPositions); - var currentSpan = this.computeTouchSpan_(currentPositions); - - var vp = this.viewport_; - var viewWidth = this.viewWidth_; - var pixelRatio = window.devicePixelRatio || 1; - - var xDelta = pixelRatio * (newCenter.x - currentCenter.x); - var yDelta = newCenter.y - currentCenter.y; - var zoomScaleValue = currentSpan > 10 ? newSpan / currentSpan : 1; - - var viewFocus = pixelRatio * newCenter.x; - var worldFocus = vp.currentDisplayTransform.xViewToWorld(viewFocus); - - this.displayTransform_.set(vp.currentDisplayTransform); - this.displayTransform_.scaleX *= zoomScaleValue; - this.displayTransform_.xPanWorldPosToViewPos( - worldFocus, viewFocus, viewWidth); - this.displayTransform_.incrementPanXInViewUnits(xDelta); - this.displayTransform_.panY -= yDelta; - vp.setDisplayTransformImmediately(this.displayTransform_); - this.storeLastTouchPositions_(e); - }, - - initHintText_: function() { - this.$.hint_text.style.display = 'none'; - - this.pendingHintTextClearTimeout_ = undefined; - }, - - showHintText_: function(text) { - if (this.pendingHintTextClearTimeout_) { - window.clearTimeout(this.pendingHintTextClearTimeout_); - this.pendingHintTextClearTimeout_ = undefined; - } - this.pendingHintTextClearTimeout_ = setTimeout( - this.hideHintText_.bind(this), 1000); - this.$.hint_text.textContent = text; - this.$.hint_text.style.display = ''; - }, - - hideHintText_: function() { - this.pendingHintTextClearTimeout_ = undefined; - this.$.hint_text.style.display = 'none'; - } - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/timeline_track_view_test.html b/chromium/third_party/catapult/tracing/tracing/ui/timeline_track_view_test.html deleted file mode 100644 index 70c00ec74d0..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/timeline_track_view_test.html +++ /dev/null @@ -1,200 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/task.html"> -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/extras/importer/trace_event_importer.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/ui/timeline_track_view.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var EventSet = tr.model.EventSet; - var SelectionState = tr.model.SelectionState; - var Task = tr.b.Task; - - test('instantiate', function() { - var num_threads = 500; - var model = tr.c.TestUtils.newModelWithEvents([], { - shiftWorldToZero: false, - pruneContainers: false, - customizeModelCallback: function(model) { - var p100 = model.getOrCreateProcess(100); - for (var i = 0; i < num_threads; i++) { - var t = p100.getOrCreateThread(101 + i); - if (i % 2 == 0) { - t.sliceGroup.beginSlice('cat', 'a', 100); - t.sliceGroup.endSlice(110); - } else { - t.sliceGroup.beginSlice('cat', 'b', 50); - t.sliceGroup.endSlice(120); - } - } - } - }); - - var timeline = document.createElement('tr-ui-timeline-track-view'); - timeline.model = model; - timeline.style.maxHeight = '600px'; - this.addHTMLOutput(timeline); - }); - - test('addAllEventsMatchingFilterToSelectionAsTask', function() { - var model = new tr.Model(); - var p1 = model.getOrCreateProcess(1); - var t1 = p1.getOrCreateThread(1); - - t1.sliceGroup.pushSlice( - new tr.model.ThreadSlice('', 'a', 0, 1, {}, 3)); - t1.sliceGroup.pushSlice( - new tr.model.ThreadSlice('', 'b', 0, 1.1, {}, 2.8)); - - var t1asg = t1.asyncSliceGroup; - t1asg.slices.push( - tr.c.TestUtils.newAsyncSliceNamed('a', 0, 1, t1, t1)); - t1asg.slices.push( - tr.c.TestUtils.newAsyncSliceNamed('b', 1, 2, t1, t1)); - - var timeline = document.createElement('tr-ui-timeline-track-view'); - timeline.model = model; - - var expected = new tr.model.EventSet( - [t1asg.slices[0], t1.sliceGroup.slices[0]]); - var result = new tr.model.EventSet; - var filterTask = timeline.addAllEventsMatchingFilterToSelectionAsTask( - new tr.c.TitleOrCategoryFilter('a'), result); - Task.RunSynchronously(filterTask); - assert.isTrue(result.equals(expected)); - - var expected = new tr.model.EventSet( - [t1asg.slices[1], t1.sliceGroup.slices[1]]); - var result = new tr.model.EventSet(); - var filterTask = timeline.addAllEventsMatchingFilterToSelectionAsTask( - new tr.c.TitleOrCategoryFilter('b'), result); - Task.RunSynchronously(filterTask); - assert.isTrue(result.equals(expected)); - }); - - test('emptyThreadsDeleted', function() { - var model = new tr.Model(); - var p1 = model.getOrCreateProcess(1); - var t1 = p1.getOrCreateThread(1); - - var timeline = document.createElement('tr-ui-timeline-track-view'); - timeline.model = model; - - assert.isFalse(timeline.hasVisibleContent); - }); - - test('filteredCounters', function() { - var model = new tr.Model(); - var c1 = model.kernel.getOrCreateCpu(0); - c1.getOrCreateCounter('', 'b'); - - var p1 = model.getOrCreateProcess(1); - var ctr = p1.getOrCreateCounter('', 'a'); - var series = new tr.model.CounterSeries('a', 0); - series.addCounterSample(0, 1); - ctr.addSeries(series); - - var timeline = document.createElement('tr-ui-timeline-track-view'); - timeline.model = model; - - assert.isTrue(timeline.hasVisibleContent); - }); - - test('filteredCpus', function() { - var model = new tr.Model(); - var c1 = model.kernel.getOrCreateCpu(1); - c1.getOrCreateCounter('', 'a'); - - var timeline = document.createElement('tr-ui-timeline-track-view'); - timeline.model = model; - - assert.isTrue(timeline.hasVisibleContent); - }); - - test('filteredProcesses', function() { - var model = new tr.Model(); - var p1 = model.getOrCreateProcess(1); - p1.getOrCreateCounter('', 'a'); - - var timeline = document.createElement('tr-ui-timeline-track-view'); - timeline.model = model; - - assert.isTrue(timeline.hasVisibleContent); - }); - - test('filteredThreads', function() { - var model = new tr.Model(); - var p1 = model.getOrCreateProcess(1); - var t1 = p1.getOrCreateThread(2); - t1.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({start: 0, duration: 1})); - - var timeline = document.createElement('tr-ui-timeline-track-view'); - timeline.model = model; - - assert.isTrue(timeline.hasVisibleContent); - }); - - test('interestRange', function() { - var events = [ - {name: 'a', args: {}, pid: 52, ts: 520, cat: 'foo', tid: 53, ph: 'B'}, - {name: 'b', args: {}, pid: 52, ts: 560, cat: 'foo', tid: 53, ph: 'B'}, - {name: 'c', args: {}, pid: 52, ts: 560, cat: 'foo', tid: 53, ph: 'B'}, - {name: 'c', args: {}, pid: 52, ts: 629, cat: 'foo', tid: 53, ph: 'E'}, - {name: 'b', args: {}, pid: 52, ts: 631, cat: 'foo', tid: 53, ph: 'E'}, - {name: 'a', args: {}, pid: 52, ts: 634, cat: 'foo', tid: 53, ph: 'E'} - ]; - var model = tr.c.TestUtils.newModelWithEvents([events]); - var trackView = document.createElement('tr-ui-timeline-track-view'); - trackView.model = model; - this.addHTMLOutput(trackView); - - var slice = model.processes[52].threads[53].sliceGroup.slices[2]; - trackView.viewport.interestRange.setMinAndMax(slice.start, slice.end); - }); - - test('emptyInterestRange', function() { - var events = [ - {name: 'a', args: {}, pid: 52, ts: 520, cat: 'foo', tid: 53, ph: 'B'}, - {name: 'b', args: {}, pid: 52, ts: 560, cat: 'foo', tid: 53, ph: 'B'}, - {name: 'c', args: {}, pid: 52, ts: 560, cat: 'foo', tid: 53, ph: 'B'}, - {name: 'c', args: {}, pid: 52, ts: 629, cat: 'foo', tid: 53, ph: 'E'}, - {name: 'b', args: {}, pid: 52, ts: 631, cat: 'foo', tid: 53, ph: 'E'}, - {name: 'a', args: {}, pid: 52, ts: 634, cat: 'foo', tid: 53, ph: 'E'} - ]; - var model = tr.c.TestUtils.newModelWithEvents([events]); - var trackView = document.createElement('tr-ui-timeline-track-view'); - trackView.model = model; - this.addHTMLOutput(trackView); - trackView.viewport.interestRange.reset(); - }); - - - test('thinnestInterestRange', function() { - var events = [ - {name: 'a', args: {}, pid: 52, ts: 520, cat: 'foo', tid: 53, ph: 'B'}, - {name: 'b', args: {}, pid: 52, ts: 560, cat: 'foo', tid: 53, ph: 'B'}, - {name: 'c', args: {}, pid: 52, ts: 560, cat: 'foo', tid: 53, ph: 'B'}, - {name: 'c', args: {}, pid: 52, ts: 629, cat: 'foo', tid: 53, ph: 'E'}, - {name: 'b', args: {}, pid: 52, ts: 631, cat: 'foo', tid: 53, ph: 'E'}, - {name: 'a', args: {}, pid: 52, ts: 634, cat: 'foo', tid: 53, ph: 'E'} - ]; - var model = tr.c.TestUtils.newModelWithEvents([events]); - var trackView = document.createElement('tr-ui-timeline-track-view'); - trackView.model = model; - this.addHTMLOutput(trackView); - trackView.viewport.interestRange.reset(); - - var slice = model.processes[52].threads[53].sliceGroup.slices[2]; - trackView.viewport.interestRange.setMinAndMax(slice.start, slice.start); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/timeline_view.html b/chromium/third_party/catapult/tracing/tracing/ui/timeline_view.html deleted file mode 100644 index e6dc34ab422..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/timeline_view.html +++ /dev/null @@ -1,530 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/settings.html"> -<link rel="import" href="/tracing/base/utils.html"> -<link rel="import" href="/tracing/core/scripting_controller.html"> -<link rel="import" href="/tracing/metrics/all_metrics.html"> -<link rel="import" href="/tracing/ui/analysis/analysis_view.html"> -<link rel="import" href="/tracing/ui/base/dom_helpers.html"> -<link rel="import" href="/tracing/ui/base/drag_handle.html"> -<link rel="import" href="/tracing/ui/base/dropdown.html"> -<link rel="import" href="/tracing/ui/base/favicons.html"> -<link rel="import" href="/tracing/ui/base/hotkey_controller.html"> -<link rel="import" href="/tracing/ui/base/info_bar_group.html"> -<link rel="import" href="/tracing/ui/base/overlay.html"> -<link rel="import" href="/tracing/ui/base/toolbar_button.html"> -<link rel="import" href="/tracing/ui/base/utils.html"> -<link rel="import" href="/tracing/ui/brushing_state_controller.html"> -<link rel="import" href="/tracing/ui/find_control.html"> -<link rel="import" href="/tracing/ui/find_controller.html"> -<link rel="import" href="/tracing/ui/scripting_control.html"> -<link rel="import" href="/tracing/ui/side_panel/side_panel_container.html"> -<link rel="import" href="/tracing/ui/timeline_track_view.html"> -<link rel="import" href="/tracing/ui/timeline_view_help_overlay.html"> -<link rel="import" href="/tracing/ui/timeline_view_metadata_overlay.html"> -<link rel="import" href="/tracing/value/ui/preferred_display_unit.html"> - -<polymer-element name='tr-ui-timeline-view'> - <template> - <style> - :host { - flex-direction: column; - cursor: default; - display: flex; - font-family: sans-serif; - padding: 0; - } - - #control { - background-color: #e6e6e6; - background-image: -webkit-gradient(linear, 0 0, 0 100%, - from(#E5E5E5), to(#D1D1D1)); - flex: 0 0 auto; - overflow-x: auto; - } - - #control::-webkit-scrollbar { height: 0px; } - - #control > #bar { - font-size: 12px; - display: flex; - flex-direction: row; - margin: 1px; - } - - #control > #bar > #title { - display: flex; - align-items: center; - padding-left: 8px; - padding-right: 8px; - flex: 1 1 auto; - } - - #control > #bar > #left_controls, - #control > #bar > #right_controls { - display: flex; - flex-direction: row; - align-items: stretch; - } - - #control > #bar > #left_controls > * { margin-right: 2px; } - #control > #bar > #right_controls > * { margin-left: 2px; } - #control > #collapsing_controls { display: flex; } - - middle-container { - flex: 1 1 auto; - flex-direction: row; - border-bottom: 1px solid #8e8e8e; - display: flex; - min-height: 0; - } - - middle-container ::content track-view-container { - flex: 1 1 auto; - display: flex; - min-height: 0; - min-width: 0; - overflow-x: hidden; - } - - middle-container ::content track-view-container > * { flex: 1 1 auto; } - middle-container > x-timeline-view-side-panel-container { flex: 0 0 auto; } - tr-ui-b-drag-handle { flex: 0 0 auto; } - tr-ui-a-analysis-view { flex: 0 0 auto; } - </style> - - <tv-ui-b-hotkey-controller id="hkc"></tv-ui-b-hotkey-controller> - <div id="control"> - <div id="bar"> - <div id="left_controls"></div> - <div id="title">^_^</div> - <div id="right_controls"> - <tr-ui-b-toolbar-button id="view_metadata_button"> - M - </tr-ui-b-toolbar-button> - <tr-ui-b-dropdown id="view_options_dropdown"></tr-ui-b-dropdown> - <tr-ui-find-control id="view_find_control"></tr-ui-find-control> - <tr-ui-b-toolbar-button id="view_console_button"> - » - </tr-ui-b-toolbar-button> - <tr-ui-b-toolbar-button id="view_help_button"> - ? - </tr-ui-b-toolbar-button> - </div> - </div> - <div id="collapsing_controls"></div> - <tr-ui-b-info-bar-group id="import-warnings"> - </tr-ui-b-info-bar-group> - </div> - <middle-container> - <content></content> - - <tr-ui-side-panel-container id="side_panel_container"> - </tr-ui-side-panel-container> - </middle-container> - <tr-ui-b-drag-handle id="drag_handle"></tr-ui-b-drag-handle> - <tr-ui-a-analysis-view id="analysis"></tr-ui-a-analysis-view> - - <tr-v-ui-preferred-display-unit id="display_unit"> - </tr-v-ui-preferred-display-unit> - </template> - - <script> - 'use strict'; - - Polymer({ - ready: function() { - this.tabIndex = 0; // Let the timeline able to receive key events. - - this.titleEl_ = this.$.title; - this.leftControlsEl_ = this.$.left_controls; - this.rightControlsEl_ = this.$.right_controls; - this.collapsingControlsEl_ = this.$.collapsing_controls; - this.sidePanelContainer_ = this.$.side_panel_container; - - this.brushingStateController_ = new tr.c.BrushingStateController(this); - - this.findCtl_ = this.$.view_find_control; - this.findCtl_.controller = new tr.ui.FindController( - this.brushingStateController_); - - this.scriptingCtl_ = document.createElement('tr-ui-scripting-control'); - this.scriptingCtl_.controller = new tr.c.ScriptingController( - this.brushingStateController_); - - this.sidePanelContainer_.brushingStateController = - this.brushingStateController_; - - if (window.tr.metrics && window.tr.metrics.sh && - window.tr.metrics.sh.systemHealthMetric) { - this.railScoreSpan_ = document.createElement( - 'tr-metrics-ui-sh-system-health-span'); - this.rightControls.appendChild(this.railScoreSpan_); - } else { - this.railScoreSpan_ = undefined; - } - - this.optionsDropdown_ = this.$.view_options_dropdown; - this.optionsDropdown_.iconElement.textContent = 'View Options'; - - this.showFlowEvents_ = false; - this.optionsDropdown_.appendChild(tr.ui.b.createCheckBox( - this, 'showFlowEvents', - 'tr.ui.TimelineView.showFlowEvents', false, - 'Flow events')); - this.highlightVSync_ = false; - this.highlightVSyncCheckbox_ = tr.ui.b.createCheckBox( - this, 'highlightVSync', - 'tr.ui.TimelineView.highlightVSync', false, - 'Highlight VSync'); - this.optionsDropdown_.appendChild(this.highlightVSyncCheckbox_); - - this.initMetadataButton_(); - this.initConsoleButton_(); - this.initHelpButton_(); - - this.collapsingControls.appendChild(this.scriptingCtl_); - - this.dragEl_ = this.$.drag_handle; - - this.analysisEl_ = this.$.analysis; - this.analysisEl_.brushingStateController = this.brushingStateController_; - - this.addEventListener( - 'requestSelectionChange', - function(e) { - var sc = this.brushingStateController_; - sc.changeSelectionFromRequestSelectionChangeEvent(e.selection); - }.bind(this)); - - // Bookkeeping. - this.onViewportChanged_ = this.onViewportChanged_.bind(this); - this.bindKeyListeners_(); - - this.dragEl_.target = this.analysisEl_; - }, - - domReady: function() { - this.trackViewContainer_ = this.querySelector('#track_view_container'); - }, - - get globalMode() { - return this.hotkeyController.globalMode; - }, - - set globalMode(globalMode) { - globalMode = !!globalMode; - this.brushingStateController_.historyEnabled = globalMode; - this.hotkeyController.globalMode = globalMode; - }, - - get hotkeyController() { - return this.$.hkc; - }, - - updateDocumentFavicon: function() { - var hue; - if (!this.model) - hue = 'blue'; - else - hue = this.model.faviconHue; - - var faviconData = tr.ui.b.FaviconsByHue[hue]; - if (faviconData === undefined) - faviconData = tr.ui.b.FaviconsByHue['blue']; - - // Find link if its there - var link = document.head.querySelector('link[rel="shortcut icon"]'); - if (!link) { - link = document.createElement('link'); - link.rel = 'shortcut icon'; - document.head.appendChild(link); - } - link.href = faviconData; - }, - - get showFlowEvents() { - return this.showFlowEvents_; - }, - - set showFlowEvents(showFlowEvents) { - this.showFlowEvents_ = showFlowEvents; - if (!this.trackView_) - return; - this.trackView_.viewport.showFlowEvents = showFlowEvents; - }, - - get highlightVSync() { - return this.highlightVSync_; - }, - - set highlightVSync(highlightVSync) { - this.highlightVSync_ = highlightVSync; - if (!this.trackView_) - return; - this.trackView_.viewport.highlightVSync = highlightVSync; - }, - - initHelpButton_: function() { - var helpButtonEl = this.$.view_help_button; - - function onClick(e) { - var dlg = new tr.ui.b.Overlay(); - dlg.title = 'Chrome Tracing Help'; - dlg.appendChild( - document.createElement('tr-ui-timeline-view-help-overlay')); - dlg.visible = true; - - // Stop event so it doesn't trigger new click listener on document. - e.stopPropagation(); - } - helpButtonEl.addEventListener('click', onClick.bind(this)); - }, - - initConsoleButton_: function() { - var toggleEl = this.$.view_console_button; - - function onClick(e) { - this.scriptingCtl_.toggleVisibility(); - e.stopPropagation(); - return false; - } - toggleEl.addEventListener('click', onClick.bind(this)); - }, - - initMetadataButton_: function() { - var showEl = this.$.view_metadata_button; - - function onClick(e) { - var dlg = new tr.ui.b.Overlay(); - dlg.title = 'Metadata for trace'; - - var metadataOverlay = document.createElement( - 'tr-ui-timeline-view-metadata-overlay'); - metadataOverlay.metadata = this.model.metadata; - - dlg.appendChild(metadataOverlay); - dlg.visible = true; - - e.stopPropagation(); - return false; - } - showEl.addEventListener('click', onClick.bind(this)); - - this.updateMetadataButtonVisibility_(); - }, - - updateMetadataButtonVisibility_: function() { - var showEl = this.$.view_metadata_button; - showEl.style.display = - (this.model && this.model.metadata.length) ? '' : 'none'; - }, - - get leftControls() { - return this.leftControlsEl_; - }, - - get rightControls() { - return this.rightControlsEl_; - }, - - get collapsingControls() { - return this.collapsingControlsEl_; - }, - - get viewTitle() { - return this.titleEl_.textContent.substring( - this.titleEl_.textContent.length - 2); - }, - - set viewTitle(text) { - if (text === undefined) { - this.titleEl_.textContent = ''; - this.titleEl_.hidden = true; - return; - } - this.titleEl_.hidden = false; - this.titleEl_.textContent = text; - }, - - get model() { - if (this.trackView_) - return this.trackView_.model; - return undefined; - }, - - set model(model) { - var modelInstanceChanged = model != this.model; - var modelValid = model && !model.bounds.isEmpty; - - var importWarningsEl = this.shadowRoot.querySelector('#import-warnings'); - importWarningsEl.textContent = ''; - - // Remove old trackView if the model has completely changed. - if (modelInstanceChanged) { - if (this.railScoreSpan_) - this.railScoreSpan_.model = undefined; - this.trackViewContainer_.textContent = ''; - if (this.trackView_) { - this.trackView_.viewport.removeEventListener( - 'change', this.onViewportChanged_); - this.trackView_.brushingStateController = undefined; - this.trackView_.detach(); - this.trackView_ = undefined; - } - this.brushingStateController_.modelWillChange(); - } - - // Create new trackView if needed. - if (modelValid && !this.trackView_) { - this.trackView_ = document.createElement('tr-ui-timeline-track-view'); - this.trackView_.timelineView = this; - - this.trackView.brushingStateController = this.brushingStateController_; - - this.trackViewContainer_.appendChild(this.trackView_); - this.trackView_.viewport.addEventListener( - 'change', this.onViewportChanged_); - } - - // Set the model. - if (modelValid) { - this.trackView_.model = model; - this.trackView_.viewport.showFlowEvents = this.showFlowEvents; - this.trackView_.viewport.highlightVSync = this.highlightVSync; - if (this.railScoreSpan_) - this.railScoreSpan_.model = model; - - this.$.display_unit.preferredTimeDisplayMode = model.intrinsicTimeUnit; - } - - if (model) { - model.importWarningsThatShouldBeShownToUser.forEach( - function(importWarning) { - importWarningsEl.addMessage( - 'Import Warning: ' + importWarning.type + ': ' + - importWarning.message); - }, this); - } - - // Do things that are selection specific - if (modelInstanceChanged) { - this.updateMetadataButtonVisibility_(); - this.brushingStateController_.modelDidChange(); - this.onViewportChanged_(); - } - }, - - get brushingStateController() { - return this.brushingStateController_; - }, - - get trackView() { - return this.trackView_; - }, - - get settings() { - if (!this.settings_) - this.settings_ = new tr.b.Settings(); - return this.settings_; - }, - - /** - * Deprecated. Kept around because third_party code occasionally calls - * this to set up embedding. - */ - set focusElement(value) { - throw new Error('This is deprecated. Please set globalMode to true.'); - }, - - bindKeyListeners_: function() { - var hkc = this.hotkeyController; - - // Shortcuts that *can* steal focus from the console and the filter text - // box. - hkc.addHotKey(new tr.ui.b.HotKey({ - eventType: 'keypress', - keyCode: '`'.charCodeAt(0), - useCapture: true, - thisArg: this, - callback: function(e) { - this.scriptingCtl_.toggleVisibility(); - if (!this.scriptingCtl_.hasFocus) - this.focus(); - e.stopPropagation(); - } - })); - - // Shortcuts that *can* steal focus from the filter text box. - hkc.addHotKey(new tr.ui.b.HotKey({ - eventType: 'keypress', - keyCode: '/'.charCodeAt(0), - useCapture: true, - thisArg: this, - callback: function(e) { - if (this.scriptingCtl_.hasFocus) - return; - if (this.findCtl_.hasFocus) - this.focus(); - else - this.findCtl_.focus(); - e.preventDefault(); - e.stopPropagation(); - } - })); - - // Shortcuts that *can't* steal focus. - hkc.addHotKey(new tr.ui.b.HotKey({ - eventType: 'keypress', - keyCode: '?'.charCodeAt(0), - useCapture: false, - thisArg: this, - callback: function(e) { - this.$.view_help_button.click(); - e.stopPropagation(); - } - })); - - hkc.addHotKey(new tr.ui.b.HotKey({ - eventType: 'keypress', - keyCode: 'v'.charCodeAt(0), - useCapture: false, - thisArg: this, - callback: function(e) { - this.toggleHighlightVSync_(); - e.stopPropagation(); - } - })); - }, - - onViewportChanged_: function(e) { - var spc = this.sidePanelContainer_; - if (!this.trackView_) { - spc.rangeOfInterest.reset(); - return; - } - - var vr = this.trackView_.viewport.interestRange.asRangeObject(); - if (!spc.rangeOfInterest.equals(vr)) - spc.rangeOfInterest = vr; - - if (this.railScoreSpan_ && this.model) - this.railScoreSpan_.model = this.model; - }, - - toggleHighlightVSync_: function() { - this.highlightVSyncCheckbox_.checked = - !this.highlightVSyncCheckbox_.checked; - }, - - setFindCtlText: function(string) { - this.findCtl_.setText(string); - } - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/timeline_view_help_overlay.html b/chromium/third_party/catapult/tracing/tracing/ui/timeline_view_help_overlay.html deleted file mode 100644 index 1cde57bd69c..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/timeline_view_help_overlay.html +++ /dev/null @@ -1,243 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> -<link rel="import" href="/tracing/base/base.html"> -<link rel="import" href="/tracing/ui/base/mouse_mode_icon.html"> -<link rel="import" href="/tracing/ui/base/overlay.html"> - -<polymer-element name="tr-ui-timeline-view-help-overlay"> - <template> - <style> - :host { - -webkit-flex: 1 1 auto; - -webkit-flex-direction: row; - display: -webkit-flex; - width: 700px; - } - .column { - width: 50%; - } - h2 { - font-size: 1.2em; - margin: 0; - margin-top: 5px; - text-align: center; - } - h3 { - margin: 0; - margin-left: 126px; - margin-top: 10px; - } - .pair { - -webkit-flex: 1 1 auto; - -webkit-flex-direction: row; - display: -webkit-flex; - } - .command { - font-family: monospace; - margin-right: 5px; - text-align: right; - width: 150px; - } - .action { - font-size: 0.9em; - text-align: left; - width: 200px; - } - tr-ui-b-mouse-mode-icon { - border: 1px solid #888; - border-radius: 3px; - box-shadow: inset 0 0 2px rgba(0,0,0,0.3); - display: inline-block; - margin-right: 1px; - position: relative; - top: 4px; - } - .mouse-mode-icon.pan-mode { - background-position: -1px -11px; - } - .mouse-mode-icon.select-mode { - background-position: -1px -41px; - } - .mouse-mode-icon.zoom-mode { - background-position: -1px -71px; - } - .mouse-mode-icon.timing-mode { - background-position: -1px -101px; - } - </style> - <div class="column left"> - <h2>Navigation</h2> - <div class='pair'> - <div class='command'>w/s</div> - <div class='action'>Zoom in/out (+shift: faster)</div> - </div> - - <div class='pair'> - <div class='command'>a/d</div> - <div class='action'>Pan left/right (+shift: faster)</div> - </div> - - <div class='pair'> - <div class='command'>→/shift-TAB</div> - <div class='action'>Select previous event</div> - </div> - - <div class='pair'> - <div class='command'>←/TAB</div> - <div class='action'>Select next event</div> - </div> - - <h2>Mouse Controls</h2> - <div class='pair'> - <div class='command'>click</div> - <div class='action'>Select event</div> - </div> - <div class='pair'> - <div class='command'>alt-mousewheel</div> - <div class='action'>Zoom in/out</div> - </div> - - <h3> - <tr-ui-b-mouse-mode-icon modeName="SELECTION"></tr-ui-b-mouse-mode-icon> - Select mode - </h3> - <div class='pair'> - <div class='command'>drag</div> - <div class='action'>Box select</div> - </div> - - <div class='pair'> - <div class='command'><span class='mod'></span>-click/drag</div> - <div class='action'>Add events to the current selection</div> - </div> - - <div class='pair'> - <div class='command'>double click</div> - <div class='action'>Select all events with same title</div> - </div> - - <h3> - <tr-ui-b-mouse-mode-icon modeName="PANSCAN"></tr-ui-b-mouse-mode-icon> - Pan mode - </h3> - <div class='pair'> - <div class='command'>drag</div> - <div class='action'>Pan the view</div> - </div> - - <h3> - <tr-ui-b-mouse-mode-icon modeName="ZOOM"></tr-ui-b-mouse-mode-icon> - Zoom mode - </h3> - <div class='pair'> - <div class='command'>drag</div> - <div class='action'>Zoom in/out by dragging up/down</div> - </div> - - <h3> - <tr-ui-b-mouse-mode-icon modeName="TIMING"></tr-ui-b-mouse-mode-icon> - Timing mode - </h3> - <div class='pair'> - <div class='command'>drag</div> - <div class='action'>Create or move markers</div> - </div> - - <div class='pair'> - <div class='command'>double click</div> - <div class='action'>Set marker range to slice</div> - </div> - </div> - - <div class="column right"> - <h2>General</h2> - <div class='pair'> - <div class='command'>1-4</div> - <div class='action'>Switch mouse mode</div> - </div> - - <div class='pair'> - <div class='command'>shift</div> - <div class='action'>Hold for temporary select</div> - </div> - - <div class='pair'> - <div class='command'>space</div> - <div class='action'>Hold for temporary pan</div> - </div> - - <div class='pair'> - <div class='command'>/</div> - <div class='action'>Search</div> - </div> - - <div class='pair'> - <div class='command'>enter</div> - <div class='action'>Step through search results</div> - </div> - - <div class='pair'> - <div class='command'>f</div> - <div class='action'>Zoom into selection</div> - </div> - - <div class='pair'> - <div class='command'>z/0</div> - <div class='action'>Reset zoom and pan</div> - </div> - - <div class='pair'> - <div class='command'>g/G</div> - <div class='action'>Toggle 60hz grid</div> - </div> - - <div class='pair'> - <div class='command'>v</div> - <div class='action'>Highlight VSync</div> - </div> - - <div class='pair'> - <div class='command'>h</div> - <div class='action'>Toggle low/high details</div> - </div> - - <div class='pair'> - <div class='command'>m</div> - <div class='action'>Mark current selection</div> - </div> - - <div class='pair'> - <div class='command'>p</div> - <div class='action'>Select power samples over current selection interval</div> - </div> - - <div class='pair'> - <div class='command'>`</div> - <div class='action'>Show or hide the scripting console</div> - </div> - - <div class='pair'> - <div class='command'>?</div> - <div class='action'>Show help</div> - </div> - </div> - </template> - - <script> - 'use strict'; - - Polymer('tr-ui-timeline-view-help-overlay', { - ready: function() { - var mod = tr.isMac ? 'cmd ' : 'ctrl'; - var spans = this.shadowRoot.querySelectorAll('span.mod'); - for (var i = 0; i < spans.length; i++) { - spans[i].textContent = mod; - } - } - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/timeline_view_help_overlay_test.html b/chromium/third_party/catapult/tracing/tracing/ui/timeline_view_help_overlay_test.html deleted file mode 100644 index d7e009d1623..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/timeline_view_help_overlay_test.html +++ /dev/null @@ -1,17 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> -<link rel="import" href="/tracing/ui/timeline_view_help_overlay.html"> -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - test('inactive', function() { - var el = document.createElement('tr-ui-timeline-view-help-overlay'); - this.addHTMLOutput(el); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/timeline_view_metadata_overlay.html b/chromium/third_party/catapult/tracing/tracing/ui/timeline_view_metadata_overlay.html deleted file mode 100644 index 0727958cfbe..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/timeline_view_metadata_overlay.html +++ /dev/null @@ -1,42 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> -<link rel="import" href="/tracing/base/base.html"> -<link rel="import" href="/tracing/ui/base/mouse_mode_icon.html"> -<link rel="import" href="/tracing/ui/base/overlay.html"> -<link rel="import" href="/tracing/value/ui/generic_table_view.html"> - -<polymer-element name="tr-ui-timeline-view-metadata-overlay"> - <template> - <style> - :host { - width: 700px; - - overflow: auto; - } - </style> - <tr-v-ui-generic-table-view id="gtv"></tr-v-ui-generic-table-view> - </template> - - <script> - 'use strict'; - - Polymer('tr-ui-timeline-view-metadata-overlay', { - created: function() { - this.metadata_ = undefined; - }, - - get metadata() { - return this.metadata_; - }, - - set metadata(metadata) { - this.metadata_ = metadata; - this.$.gtv.items = this.metadata_; - } - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/timeline_view_metadata_overlay_test.html b/chromium/third_party/catapult/tracing/tracing/ui/timeline_view_metadata_overlay_test.html deleted file mode 100644 index 04e88d00cda..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/timeline_view_metadata_overlay_test.html +++ /dev/null @@ -1,31 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> -<link rel="import" href="/tracing/ui/timeline_view_metadata_overlay.html"> -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - test('inactive', function() { - var el = document.createElement('tr-ui-timeline-view-metadata-overlay'); - el.metadata = [ - { - name: 'clientInfo', - value: { - command_line: './out/Release/Chromium.app/Contents/MacOS/Chromium --enable-threaded-compositing --force-compositing-mode --enable-impl-side-painting --enable-skia-benchmarking --allow-webui-compositing --flag-switches-begin --force-compositing-mode --disable-threaded-compositing --flag-switches-end', // @suppress longLineCheck - version: 'Chrome/29.0.1521.0' - } - }, - { - name: 'somethingElse', - value: 'fascinating!' - } - ]; - - this.addHTMLOutput(el); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/timeline_view_test.html b/chromium/third_party/catapult/tracing/tracing/ui/timeline_view_test.html deleted file mode 100644 index e3e2e060985..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/timeline_view_test.html +++ /dev/null @@ -1,161 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/task.html"> -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/ui/timeline_view.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var Task = tr.b.Task; - - function setupTimeline() { - var container = document.createElement('track-view-container'); - container.id = 'track_view_container'; - - var view = document.createElement('tr-ui-timeline-view'); - view.appendChild(container); - view.trackViewContainer_ = container; - return view; - } - - var createFullyPopulatedModel = function(opt_withError, opt_withMetadata) { - var withError = opt_withError !== undefined ? opt_withError : true; - var withMetadata = opt_withMetadata !== undefined ? - opt_withMetadata : true; - - var num_tests = 50; - var testIndex = 0; - var startTime = 0; - - var model = new tr.Model(); - var io = new tr.importer.ImportOptions(); - io.showImportWarnings = false; - model.importOptions = io; - - for (testIndex = 0; testIndex < num_tests; ++testIndex) { - var process = model.getOrCreateProcess(10000 + testIndex); - if (testIndex % 2 == 0) { - var thread = process.getOrCreateThread('Thread Name Here'); - thread.sliceGroup.pushSlice(new tr.model.Slice( - 'foo', 'a', 0, startTime, {}, 1)); - thread.sliceGroup.pushSlice(new tr.model.Slice( - 'bar', 'b', 0, startTime + 23, {}, 10)); - } else { - var thread = process.getOrCreateThread('Name'); - thread.sliceGroup.pushSlice(new tr.model.Slice( - 'foo', 'a', 0, startTime + 4, {}, 11)); - thread.sliceGroup.pushSlice(new tr.model.Slice( - 'bar', 'b', 0, startTime + 22, {}, 14)); - } - } - var p1000 = model.getOrCreateProcess(1000); - var objects = p1000.objects; - objects.idWasCreated('0x1000', 'tr.e.cc', 'LayerTreeHostImpl', 10); - objects.addSnapshot('0x1000', 'tr.e.cc', 'LayerTreeHostImpl', 10, - 'snapshot-1'); - objects.addSnapshot('0x1000', 'tr.e.cc', 'LayerTreeHostImpl', 25, - 'snapshot-2'); - objects.addSnapshot('0x1000', 'tr.e.cc', 'LayerTreeHostImpl', 40, - 'snapshot-3'); - objects.idWasDeleted('0x1000', 'tr.e.cc', 'LayerTreeHostImpl', 45); - model.updateCategories_(); - - // Add a known problematic piece of data to test the import errors UI. - model.importWarning({ - type: 'test_error', - message: 'Synthetic Import Error' - }); - model.updateBounds(); - - // Add data with metadata information stored - model.metadata.push({name: 'a', value: 'testA'}); - model.metadata.push({name: 'b', value: 'testB'}); - model.metadata.push({name: 'c', value: 'testC'}); - - return model; - }; - - var visibleTracks = function(trackButtons) { - return trackButtons.reduce(function(numVisible, button) { - var style = button.parentElement.style; - var visible = (style.display.indexOf('none') === -1); - return visible ? numVisible + 1 : numVisible; - }, 0); - }; - - var modelsEquivalent = function(lhs, rhs) { - if (lhs.length !== rhs.length) - return false; - return lhs.every(function(lhsItem, index) { - var rhsItem = rhs[index]; - return rhsItem.regexpText === lhsItem.regexpText && - rhsItem.isOn === lhsItem.isOn; - }); - }; - - test('instantiate', function() { - var model11 = createFullyPopulatedModel(true, true); - - var view = setupTimeline(); - view.style.height = '400px'; - view.style.border = '1px solid black'; - view.model = model11; - - var simpleButton1 = document.createElement('tr-ui-b-toolbar-button'); - simpleButton1.textContent = 'M'; - view.leftControls.appendChild(simpleButton1); - - var simpleButton2 = document.createElement('tr-ui-b-toolbar-button'); - simpleButton2.textContent = 'am button'; - view.leftControls.appendChild(simpleButton2); - - this.addHTMLOutput(view); - }); - - test('changeModelToSomethingDifferent', function() { - var model00 = createFullyPopulatedModel(false, false); - var model11 = createFullyPopulatedModel(true, true); - - var view = setupTimeline(); - view.style.height = '400px'; - view.model = model00; - view.model = undefined; - view.model = model11; - view.model = model00; - }); - - test('setModelToSameThingAgain', function() { - var model = createFullyPopulatedModel(false, false); - - // Create a view with am model. - var view = setupTimeline(); - view.style.height = '400px'; - view.model = model; - var sc = view.brushingStateController; - - // Mutate the model and update the view. - var t123 = model.getOrCreateProcess(123).getOrCreateThread(123); - t123.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx( - {title: 'somethingUnusual', start: 0, duration: 5})); - view.model = model; - - // Verify that the new bits of the model show up in the view. - var selection = new tr.model.EventSet(); - var filter = new tr.c.TitleOrCategoryFilter('somethingUnusual'); - var filterTask = sc.addAllEventsMatchingFilterToSelectionAsTask( - filter, selection); - Task.RunSynchronously(filterTask); - assert.equal(selection.length, 1); - }); -}); -</script> - diff --git a/chromium/third_party/catapult/tracing/tracing/ui/timeline_viewport.html b/chromium/third_party/catapult/tracing/tracing/ui/timeline_viewport.html deleted file mode 100644 index 92f4679ae01..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/timeline_viewport.html +++ /dev/null @@ -1,428 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2012 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/event.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/ui/base/animation.html"> -<link rel="import" href="/tracing/ui/base/animation_controller.html"> -<link rel="import" href="/tracing/ui/base/dom_helpers.html"> -<link rel="import" href="/tracing/ui/base/draw_helpers.html"> -<link rel="import" href="/tracing/ui/timeline_display_transform.html"> -<link rel="import" href="/tracing/ui/timeline_interest_range.html"> -<link rel="import" href="/tracing/ui/tracks/container_to_track_map.html"> -<link rel="import" href="/tracing/ui/tracks/event_to_track_map.html"> - -<script> -'use strict'; - -/** - * @fileoverview Code for the viewport. - */ -tr.exportTo('tr.ui', function() { - var TimelineDisplayTransform = tr.ui.TimelineDisplayTransform; - var TimelineInterestRange = tr.ui.TimelineInterestRange; - - /** - * The TimelineViewport manages the transform used for navigating - * within the timeline. It is a simple transform: - * x' = (x+pan) * scale - * - * The timeline code tries to avoid directly accessing this transform, - * instead using this class to do conversion between world and viewspace, - * as well as the math for centering the viewport in various interesting - * ways. - * - * @constructor - * @extends {tr.b.EventTarget} - */ - function TimelineViewport(parentEl) { - this.parentEl_ = parentEl; - this.modelTrackContainer_ = undefined; - this.currentDisplayTransform_ = new TimelineDisplayTransform(); - this.initAnimationController_(); - - // Flow events - this.showFlowEvents_ = false; - - // Highlights. - this.highlightVSync_ = false; - - // High details. - this.highDetails_ = false; - - // Grid system. - this.gridTimebase_ = 0; - this.gridStep_ = 1000 / 60; - this.gridEnabled_ = false; - - // Init logic. - this.hasCalledSetupFunction_ = false; - - this.onResize_ = this.onResize_.bind(this); - this.onModelTrackControllerScroll_ = - this.onModelTrackControllerScroll_.bind(this); - - // The following code uses an interval to detect when the parent element - // is attached to the document. That is a trigger to run the setup function - // and install a resize listener. - this.checkForAttachInterval_ = setInterval( - this.checkForAttach_.bind(this), 250); - - this.majorMarkPositions = []; - this.interestRange_ = new TimelineInterestRange(this); - - this.eventToTrackMap_ = new tr.ui.tracks.EventToTrackMap(); - this.containerToTrackMap = new tr.ui.tracks.ContainerToTrackMap(); - } - - TimelineViewport.prototype = { - __proto__: tr.b.EventTarget.prototype, - - /** - * Allows initialization of the viewport when the viewport's parent element - * has been attached to the document and given a size. - * @param {Function} fn Function to call when the viewport can be safely - * initialized. - */ - setWhenPossible: function(fn) { - this.pendingSetFunction_ = fn; - }, - - /** - * @return {boolean} Whether the current timeline is attached to the - * document. - */ - get isAttachedToDocumentOrInTestMode() { - // Allow not providing a parent element, used by tests. - if (this.parentEl_ === undefined) - return; - return tr.ui.b.isElementAttachedToDocument(this.parentEl_); - }, - - onResize_: function() { - this.dispatchChangeEvent(); - }, - - /** - * Checks whether the parentNode is attached to the document. - * When it is, it installs the iframe-based resize detection hook - * and then runs the pendingSetFunction_, if present. - */ - checkForAttach_: function() { - if (!this.isAttachedToDocumentOrInTestMode || this.clientWidth == 0) - return; - - if (!this.iframe_) { - this.iframe_ = document.createElement('iframe'); - this.iframe_.style.cssText = - 'position:absolute;width:100%;height:0;border:0;visibility:hidden;'; - this.parentEl_.appendChild(this.iframe_); - - this.iframe_.contentWindow.addEventListener('resize', this.onResize_); - } - - var curSize = this.parentEl_.clientWidth + 'x' + - this.parentEl_.clientHeight; - if (this.pendingSetFunction_) { - this.lastSize_ = curSize; - try { - this.pendingSetFunction_(); - } catch (ex) { - console.log('While running setWhenPossible:', - ex.message ? ex.message + '\n' + ex.stack : ex.stack); - } - this.pendingSetFunction_ = undefined; - } - - window.clearInterval(this.checkForAttachInterval_); - this.checkForAttachInterval_ = undefined; - }, - - /** - * Fires the change event on this viewport. Used to notify listeners - * to redraw when the underlying model has been mutated. - */ - dispatchChangeEvent: function() { - tr.b.dispatchSimpleEvent(this, 'change'); - }, - - detach: function() { - if (this.checkForAttachInterval_) { - window.clearInterval(this.checkForAttachInterval_); - this.checkForAttachInterval_ = undefined; - } - if (this.iframe_) { - this.iframe_.removeEventListener('resize', this.onResize_); - this.parentEl_.removeChild(this.iframe_); - } - }, - - initAnimationController_: function() { - this.dtAnimationController_ = new tr.ui.b.AnimationController(); - this.dtAnimationController_.addEventListener( - 'didtick', function(e) { - this.onCurentDisplayTransformChange_(e.oldTargetState); - }.bind(this)); - - var that = this; - this.dtAnimationController_.target = { - get panX() { - return that.currentDisplayTransform_.panX; - }, - - set panX(panX) { - that.currentDisplayTransform_.panX = panX; - }, - - get panY() { - return that.currentDisplayTransform_.panY; - }, - - set panY(panY) { - that.currentDisplayTransform_.panY = panY; - }, - - get scaleX() { - return that.currentDisplayTransform_.scaleX; - }, - - set scaleX(scaleX) { - that.currentDisplayTransform_.scaleX = scaleX; - }, - - cloneAnimationState: function() { - return that.currentDisplayTransform_.clone(); - }, - - xPanWorldPosToViewPos: function(xWorld, xView) { - that.currentDisplayTransform_.xPanWorldPosToViewPos( - xWorld, xView, that.modelTrackContainer_.canvas.clientWidth); - } - }; - }, - - get currentDisplayTransform() { - return this.currentDisplayTransform_; - }, - - setDisplayTransformImmediately: function(displayTransform) { - this.dtAnimationController_.cancelActiveAnimation(); - - var oldDisplayTransform = - this.dtAnimationController_.target.cloneAnimationState(); - this.currentDisplayTransform_.set(displayTransform); - this.onCurentDisplayTransformChange_(oldDisplayTransform); - }, - - queueDisplayTransformAnimation: function(animation) { - if (!(animation instanceof tr.ui.b.Animation)) - throw new Error('animation must be instanceof tr.ui.b.Animation'); - this.dtAnimationController_.queueAnimation(animation); - }, - - onCurentDisplayTransformChange_: function(oldDisplayTransform) { - // Ensure panY stays clamped in the track container's scroll range. - if (this.modelTrackContainer_) { - this.currentDisplayTransform.panY = tr.b.clamp( - this.currentDisplayTransform.panY, - 0, - this.modelTrackContainer_.scrollHeight - - this.modelTrackContainer_.clientHeight); - } - - var changed = !this.currentDisplayTransform.equals(oldDisplayTransform); - var yChanged = this.currentDisplayTransform.panY !== - oldDisplayTransform.panY; - if (yChanged) - this.modelTrackContainer_.scrollTop = this.currentDisplayTransform.panY; - if (changed) - this.dispatchChangeEvent(); - }, - - onModelTrackControllerScroll_: function(e) { - if (this.dtAnimationController_.activeAnimation && - this.dtAnimationController_.activeAnimation.affectsPanY) - this.dtAnimationController_.cancelActiveAnimation(); - var panY = this.modelTrackContainer_.scrollTop; - this.currentDisplayTransform_.panY = panY; - }, - - get modelTrackContainer() { - return this.modelTrackContainer_; - }, - - set modelTrackContainer(m) { - if (this.modelTrackContainer_) - this.modelTrackContainer_.removeEventListener('scroll', - this.onModelTrackControllerScroll_); - - this.modelTrackContainer_ = m; - this.modelTrackContainer_.addEventListener('scroll', - this.onModelTrackControllerScroll_); - }, - - get showFlowEvents() { - return this.showFlowEvents_; - }, - - set showFlowEvents(showFlowEvents) { - this.showFlowEvents_ = showFlowEvents; - this.dispatchChangeEvent(); - }, - - get highlightVSync() { - return this.highlightVSync_; - }, - - set highlightVSync(highlightVSync) { - this.highlightVSync_ = highlightVSync; - this.dispatchChangeEvent(); - }, - - get highDetails() { - return this.highDetails_; - }, - - set highDetails(highDetails) { - this.highDetails_ = highDetails; - this.dispatchChangeEvent(); - }, - - get gridEnabled() { - return this.gridEnabled_; - }, - - set gridEnabled(enabled) { - if (this.gridEnabled_ == enabled) - return; - - this.gridEnabled_ = enabled && true; - this.dispatchChangeEvent(); - }, - - get gridTimebase() { - return this.gridTimebase_; - }, - - set gridTimebase(timebase) { - if (this.gridTimebase_ == timebase) - return; - this.gridTimebase_ = timebase; - this.dispatchChangeEvent(); - }, - - get gridStep() { - return this.gridStep_; - }, - - get interestRange() { - return this.interestRange_; - }, - - drawMajorMarkLines: function(ctx) { - // Apply subpixel translate to get crisp lines. - // http://www.mobtowers.com/html5-canvas-crisp-lines-every-time/ - ctx.save(); - ctx.translate((Math.round(ctx.lineWidth) % 2) / 2, 0); - - ctx.beginPath(); - for (var idx in this.majorMarkPositions) { - var x = Math.floor(this.majorMarkPositions[idx]); - tr.ui.b.drawLine(ctx, x, 0, x, ctx.canvas.height); - } - ctx.strokeStyle = '#ddd'; - ctx.stroke(); - - ctx.restore(); - }, - - drawGridLines: function(ctx, viewLWorld, viewRWorld) { - if (!this.gridEnabled) - return; - - var dt = this.currentDisplayTransform; - var x = this.gridTimebase; - - // Apply subpixel translate to get crisp lines. - // http://www.mobtowers.com/html5-canvas-crisp-lines-every-time/ - ctx.save(); - ctx.translate((Math.round(ctx.lineWidth) % 2) / 2, 0); - - ctx.beginPath(); - while (x < viewRWorld) { - if (x >= viewLWorld) { - // Do conversion to viewspace here rather than on - // x to avoid precision issues. - var vx = Math.floor(dt.xWorldToView(x)); - tr.ui.b.drawLine(ctx, vx, 0, vx, ctx.canvas.height); - } - - x += this.gridStep; - } - ctx.strokeStyle = 'rgba(255, 0, 0, 0.25)'; - ctx.stroke(); - - ctx.restore(); - }, - - /** - * Helper for selection previous or next. - * @param {boolean} offset If positive, select one forward (next). - * Else, select previous. - * - * @return {boolean} true if current selection changed. - */ - getShiftedSelection: function(selection, offset) { - var newSelection = new tr.model.EventSet(); - for (var event of selection) { - - // If this is a flow event, then move to its slice based on the - // offset direction. - if (event instanceof tr.model.FlowEvent) { - if (offset > 0) { - newSelection.push(event.endSlice); - } else if (offset < 0) { - newSelection.push(event.startSlice); - } else { - /* Do nothing. Zero offsets don't do anything. */ - } - continue; - } - - var track = this.trackForEvent(event); - track.addEventNearToProvidedEventToSelection( - event, offset, newSelection); - } - - if (newSelection.length == 0) - return undefined; - return newSelection; - }, - - rebuildEventToTrackMap: function() { - // TODO(charliea): Make the event to track map have a similar interface - // to the container to track map so that we can just clear() here. - this.eventToTrackMap_ = new tr.ui.tracks.EventToTrackMap(); - this.modelTrackContainer_.addEventsToTrackMap(this.eventToTrackMap_); - }, - - rebuildContainerToTrackMap: function() { - this.containerToTrackMap.clear(); - this.modelTrackContainer_.addContainersToTrackMap( - this.containerToTrackMap); - }, - - trackForEvent: function(event) { - return this.eventToTrackMap_[event.guid]; - } - }; - - return { - TimelineViewport: TimelineViewport - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/timeline_viewport_test.html b/chromium/third_party/catapult/tracing/tracing/ui/timeline_viewport_test.html deleted file mode 100644 index 75a4939427e..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/timeline_viewport_test.html +++ /dev/null @@ -1,150 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/model/location.html"> -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/ui/base/constants.html"> -<link rel="import" href="/tracing/ui/timeline_track_view.html"> -<link rel="import" href="/tracing/ui/timeline_viewport.html"> -<link rel="import" href="/tracing/ui/tracks/drawing_container.html"> -<link rel="import" href="/tracing/ui/tracks/slice_track.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var Location = tr.model.Location; - var Model = tr.Model; - - test('memoization', function() { - - var vp = new tr.ui.TimelineViewport(document.createElement('div')); - - var slice = { guid: 1 }; - - vp.modelTrackContainer = { - addEventsToTrackMap: function(eventToTrackMap) { - eventToTrackMap.addEvent(slice, 'track'); - }, - addEventListener: function() {} - }; - - assert.isUndefined(vp.trackForEvent(slice)); - vp.rebuildEventToTrackMap(); - - assert.equal(vp.trackForEvent(slice), 'track'); - }); - - test('shiftedSelection', function() { - var model = new tr.Model(); - var p1 = model.getOrCreateProcess(1); - var t1 = p1.getOrCreateThread(1); - t1.sliceGroup.pushSlice( - new tr.model.ThreadSlice('', 'a', 0, 1, {}, 3)); - t1.sliceGroup.pushSlice( - new tr.model.ThreadSlice('', 'a', 0, 5, {}, 1)); - - var viewport = new tr.ui.TimelineViewport(); - var track = new tr.ui.tracks.SliceTrack(viewport); - viewport.modelTrackContainer = track; - track.slices = t1.sliceGroup.slices; - - viewport.rebuildEventToTrackMap(); - - var sel = new tr.model.EventSet(); - sel.push(t1.sliceGroup.slices[0]); - - var shifted = track.viewport.getShiftedSelection(sel, 1); - assert.isTrue(shifted.equals( - new tr.model.EventSet(t1.sliceGroup.slices[1]))); - }); - - test('locationObj', function() { - var process; - var thread; - var model = tr.c.TestUtils.newModelWithEvents([], { - shiftWorldToZero: false, - pruneContainers: false, - customizeModelCallback: function(model) { - process = model.getOrCreateProcess(123); - thread = process.getOrCreateThread(456); - - thread.asyncSliceGroup.push( - tr.c.TestUtils.newAsyncSliceNamed('a', 80, 20, thread, thread)); - thread.asyncSliceGroup.push( - tr.c.TestUtils.newAsyncSliceNamed('a', 85, 10, thread, thread)); - } - }); - - var timeline = document.createElement('tr-ui-timeline-track-view'); - var vp = new tr.ui.TimelineViewport(timeline); - timeline.model = model; - timeline.style.maxHeight = '600px'; - this.addHTMLOutput(timeline); - - // Our stableId to track map is not automatically built. We need to - // search for the tracks and manually build the stableId map here. - var processTracks = document.getElementsByClassName('process-track-base'); - vp.modelTrackContainer = { - addContainersToTrackMap: function(containerToTrackMap) { - // Invoking the process track's addContainersToTrackMap is enough to - // build the map for all children (i.e. Threads, AsyncSliceGroups) - // as well. - for (var i = 0; i < processTracks.length; i++) - processTracks[i].addContainersToTrackMap(containerToTrackMap); - }, - addEventListener: function() {}, - canvas: { - offsetLeft: tr.ui.b.constants.HEADING_WIDTH, - offsetTop: 0 - } - }; - vp.rebuildContainerToTrackMap(); - - var asyncTrack = - vp.containerToTrackMap.getTrackByStableId('123.456.AsyncSliceGroup'); - assert.isDefined(asyncTrack); - assert.isFalse(asyncTrack.expanded); // Make sure this starts unexpanded. - - // Hack to allow Location to find the element we're looking for. - // This ensures the correct behaviour of document.elementFrompoint(x,y) of - // an originally off-screen element. - asyncTrack.scrollIntoView(); - - var boundRect = asyncTrack.getBoundingClientRect(); - var viewX = boundRect.left; - var viewY = boundRect.top + boundRect.height / 2; - var location = Location.fromViewCoordinates(vp, viewX, viewY); - assert.equal(asyncTrack, location.getContainingTrack(vp)); - assert.deepEqual(location.toViewCoordinates(vp), - { viewX: viewX, viewY: viewY }); - - // Try expanding the multi-row track so that the dimensions of the thread - // track changes. - asyncTrack.expanded = true; - // Expanding the track causes the height to double. We can calculate the new - // viewY with respect to the track's old boundRect. ViewX remains unchanged. - var expandedViewY = boundRect.top + boundRect.height; - assert.deepEqual(location.toViewCoordinates(vp), - { viewX: viewX, viewY: expandedViewY }); - - // Test the functionality of fromStableIdAndTimestamp. - var locationFromCoord = - Location.fromViewCoordinates(vp, viewX, boundRect.top); - var locationFromStableId = - Location.fromStableIdAndTimestamp(vp, '123.456.AsyncSliceGroup', - location.xWorld); - assert.deepEqual(locationFromCoord, locationFromStableId); - - // Undo scroll. - document.getElementById('results-container').scrollTop = 0; - }); -}); -</script> - diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/alert_track.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/alert_track.html deleted file mode 100644 index a6082f9d040..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/alert_track.html +++ /dev/null @@ -1,51 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/tracks/letter_dot_track.html"> -<script> -'use strict'; - -tr.exportTo('tr.ui.tracks', function() { - /** - * A track that displays an array of alert objects. - * @constructor - * @extends {LetterDotTrack} - */ - var AlertTrack = tr.ui.b.define( - 'alert-track', tr.ui.tracks.LetterDotTrack); - - AlertTrack.prototype = { - __proto__: tr.ui.tracks.LetterDotTrack.prototype, - - decorate: function(viewport) { - tr.ui.tracks.LetterDotTrack.prototype.decorate.call(this, viewport); - this.heading = 'Alerts'; - this.alerts_ = undefined; - }, - - get alerts() { - return this.alerts_; - }, - - set alerts(alerts) { - this.alerts_ = alerts; - if (alerts === undefined) { - this.items = undefined; - return; - } - this.items = this.alerts_.map(function(alert) { - return new tr.ui.tracks.LetterDot( - alert, String.fromCharCode(9888), alert.colorId, alert.start); - }); - } - }; - - return { - AlertTrack: AlertTrack - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/alert_track_test.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/alert_track_test.html deleted file mode 100644 index 48d488e3e48..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/alert_track_test.html +++ /dev/null @@ -1,76 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/model/global_memory_dump.html"> -<link rel="import" href="/tracing/model/selection_state.html"> -<link rel="import" href="/tracing/ui/timeline_viewport.html"> -<link rel="import" href="/tracing/ui/tracks/alert_track.html"> -<link rel="import" href="/tracing/ui/tracks/drawing_container.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var AlertTrack = tr.ui.tracks.AlertTrack; - var SelectionState = tr.model.SelectionState; - var Viewport = tr.ui.TimelineViewport; - - var ALERT_INFO_1 = new tr.model.EventInfo( - 'Alert 1', 'One alert'); - var ALERT_INFO_2 = new tr.model.EventInfo( - 'Alert 2', 'Another alert'); - - var createAlerts = function() { - var alerts = [ - new tr.model.Alert(ALERT_INFO_1, 5), - new tr.model.Alert(ALERT_INFO_1, 20), - new tr.model.Alert(ALERT_INFO_2, 35), - new tr.model.Alert(ALERT_INFO_2, 50) - ]; - return alerts; - }; - - test('instantiate', function() { - var alerts = createAlerts(); - alerts[1].selectionState = SelectionState.SELECTED; - - var div = document.createElement('div'); - var viewport = new Viewport(div); - var drawingContainer = new tr.ui.tracks.DrawingContainer(viewport); - div.appendChild(drawingContainer); - - var track = AlertTrack(viewport); - drawingContainer.appendChild(track); - - this.addHTMLOutput(div); - drawingContainer.invalidate(); - - track.alerts = alerts; - var dt = new tr.ui.TimelineDisplayTransform(); - dt.xSetWorldBounds(0, 50, track.clientWidth); - track.viewport.setDisplayTransformImmediately(dt); - - - assert.equal(5, track.items[0].start); - }); - - test('modelMapping', function() { - var alerts = createAlerts(); - - var div = document.createElement('div'); - var viewport = new Viewport(div); - var track = AlertTrack(viewport); - track.alerts = alerts; - - var a0 = track.items[0].modelItem; - assert.equal(a0, alerts[0]); - }); -}); -</script> - diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/async_slice_group_track.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/async_slice_group_track.html deleted file mode 100644 index 56971486083..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/async_slice_group_track.html +++ /dev/null @@ -1,136 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/base/ui.html"> -<link rel="import" href="/tracing/ui/tracks/multi_row_track.html"> -<link rel="import" href="/tracing/ui/tracks/slice_track.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.tracks', function() { - /** - * A track that displays a AsyncSliceGroup. - * @constructor - * @extends {MultiRowTrack} - */ - var AsyncSliceGroupTrack = tr.ui.b.define( - 'async-slice-group-track', - tr.ui.tracks.MultiRowTrack); - - AsyncSliceGroupTrack.prototype = { - - __proto__: tr.ui.tracks.MultiRowTrack.prototype, - - decorate: function(viewport) { - tr.ui.tracks.MultiRowTrack.prototype.decorate.call(this, viewport); - this.classList.add('async-slice-group-track'); - this.group_ = undefined; - }, - - addSubTrack_: function(slices) { - var track = new tr.ui.tracks.SliceTrack(this.viewport); - track.slices = slices; - this.appendChild(track); - track.asyncStyle = true; - return track; - }, - - get group() { - return this.group_; - }, - - set group(group) { - this.group_ = group; - this.setItemsToGroup(this.group_.slices, this.group_); - }, - - get eventContainer() { - return this.group; - }, - - addContainersToTrackMap: function(containerToTrackMap) { - tr.ui.tracks.MultiRowTrack.prototype.addContainersToTrackMap.apply( - this, arguments); - containerToTrackMap.addContainer(this.group, this); - }, - - /** - * Breaks up the list of slices into N rows, each of which is a list of - * slices that are non overlapping. - * - * It uses a very simple approach: walk through the slices in sorted order - * by start time. For each slice, try to fit it in an existing subRow. If - * it doesn't fit in any subrow, make another subRow. It then fits nested - * subSlices recursively into rows below parent slice according to which - * nested level the child is in. - */ - buildSubRows_: function(slices, opt_skipSort) { - if (!opt_skipSort) { - slices.sort(function(x, y) { - return x.start - y.start; - }); - } - - // Helper function that returns true if it can put the slice on row n. - var findLevel = function(sliceToPut, rows, n) { - if (n >= rows.length) - return true; // We always can make empty rows to put the slice. - var subRow = rows[n]; - var lastSliceInSubRow = subRow[subRow.length - 1]; - if (sliceToPut.start >= lastSliceInSubRow.end) { - if (sliceToPut.subSlices === undefined || - sliceToPut.subSlices.length === 0) { - return true; - } - // Make sure nested sub slices can be fitted in as well. - for (var subSlice of sliceToPut.subSlices) { - if (!findLevel(subSlice, rows, n + 1)) - return false; - } - return true; - } - return false; - }; - - var subRows = []; - for (var slice of slices) { - var found = false; - var index = subRows.length; - for (var j = 0; j < subRows.length; j++) { - if (findLevel(slice, subRows, j)) { - found = true; - index = j; - break; - } - } - if (!found) - subRows.push([]); - subRows[index].push(slice); - - // Fit subSlices recursively into rows below parent. - var fitSubSlicesRecursively = function(subSlices, level, rows) { - if (subSlices === undefined || subSlices.length === 0) - return; - if (level === rows.length) - rows.push([]); - for (var subSlice of subSlices) { - rows[level].push(subSlice); - fitSubSlicesRecursively(subSlice.subSlices, level + 1, rows); - } - }; - fitSubSlicesRecursively(slice.subSlices, index + 1, subRows); - } - return subRows; - } - }; - - return { - AsyncSliceGroupTrack: AsyncSliceGroupTrack - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/async_slice_group_track_test.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/async_slice_group_track_test.html deleted file mode 100644 index cb924f42113..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/async_slice_group_track_test.html +++ /dev/null @@ -1,252 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/ui/timeline_track_view.html"> -<link rel="import" href="/tracing/model/model.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var AsyncSliceGroup = tr.model.AsyncSliceGroup; - var AsyncSliceGroupTrack = tr.ui.tracks.AsyncSliceGroupTrack; - var Process = tr.model.Process; - var ProcessTrack = tr.ui.tracks.ProcessTrack; - var Thread = tr.model.Thread; - var ThreadTrack = tr.ui.tracks.ThreadTrack; - var newAsyncSlice = tr.c.TestUtils.newAsyncSlice; - var newAsyncSliceNamed = tr.c.TestUtils.newAsyncSliceNamed; - - test('filterSubRows', function() { - var model = new tr.Model(); - var p1 = new Process(model, 1); - var t1 = new Thread(p1, 1); - var g = new AsyncSliceGroup(t1); - g.push(newAsyncSlice(0, 1, t1, t1)); - var track = new AsyncSliceGroupTrack(new tr.ui.TimelineViewport()); - track.group = g; - - assert.equal(track.children.length, 1); - assert.isTrue(track.hasVisibleContent); - }); - - test('rebuildSubRows_twoNonOverlappingSlices', function() { - var model = new tr.Model(); - var p1 = new Process(model, 1); - var t1 = new Thread(p1, 1); - var g = new AsyncSliceGroup(t1); - var s1 = newAsyncSlice(0, 1, t1, t1); - var subs1 = newAsyncSliceNamed('b', 0, 1, t1, t1); - s1.subSlices = [subs1]; - g.push(s1); - g.push(newAsyncSlice(1, 1, t1, t1)); - var track = new AsyncSliceGroupTrack(new tr.ui.TimelineViewport()); - track.group = g; - var subRows = track.subRows; - assert.equal(subRows.length, 2); - assert.equal(subRows[0].length, 2); - assert.equal(subRows[1].length, 1); - assert.equal(subRows[1][0], g.slices[0].subSlices[0]); - assert.sameMembers(g.slices[1].subSlices, []); - }); - - test('rebuildSubRows_twoOverlappingSlices', function() { - var model = new tr.Model(); - var p1 = new Process(model, 1); - var t1 = new Thread(p1, 1); - var g = new AsyncSliceGroup(t1); - - var s1 = newAsyncSlice(0, 1, t1, t1); - var subs1 = newAsyncSliceNamed('b', 0, 1, t1, t1); - s1.subSlices = [subs1]; - var s2 = newAsyncSlice(0, 1.5, t1, t1); - var subs2 = newAsyncSliceNamed('b', 0, 1, t1, t1); - s2.subSlices = [subs2]; - g.push(s1); - g.push(s2); - - g.updateBounds(); - - var track = new AsyncSliceGroupTrack(new tr.ui.TimelineViewport()); - track.group = g; - - var subRows = track.subRows; - - assert.equal(subRows.length, 4); - assert.equal(subRows[0].length, 1); - assert.equal(subRows[1].length, 1); - assert.equal(subRows[2].length, 1); - assert.equal(subRows[3].length, 1); - assert.equal(subRows[1][0], g.slices[0].subSlices[0]); - assert.equal(subRows[3][0], g.slices[1].subSlices[0]); - }); - - test('rebuildSubRows_threePartlyOverlappingSlices', function() { - var model = new tr.Model(); - var p1 = new Process(model, 1); - var t1 = new Thread(p1, 1); - var g = new AsyncSliceGroup(t1); - g.push(newAsyncSlice(0, 1, t1, t1)); - g.push(newAsyncSlice(0, 1.5, t1, t1)); - g.push(newAsyncSlice(1, 1.5, t1, t1)); - g.updateBounds(); - var track = new AsyncSliceGroupTrack(new tr.ui.TimelineViewport()); - track.group = g; - var subRows = track.subRows; - - assert.equal(subRows.length, 2); - assert.equal(subRows[0].length, 2); - assert.equal(subRows[0][0], g.slices[0]); - assert.equal(subRows[0][1], g.slices[2]); - assert.equal(subRows[1][0], g.slices[1]); - assert.equal(subRows[1].length, 1); - assert.sameMembers(g.slices[0].subSlices, []); - assert.sameMembers(g.slices[1].subSlices, []); - assert.sameMembers(g.slices[2].subSlices, []); - }); - - test('rebuildSubRows_threeOverlappingSlices', function() { - var model = new tr.Model(); - var p1 = new Process(model, 1); - var t1 = new Thread(p1, 1); - var g = new AsyncSliceGroup(t1); - - g.push(newAsyncSlice(0, 1, t1, t1)); - g.push(newAsyncSlice(0, 1.5, t1, t1)); - g.push(newAsyncSlice(2, 1, t1, t1)); - g.updateBounds(); - - var track = new AsyncSliceGroupTrack(new tr.ui.TimelineViewport()); - track.group = g; - - var subRows = track.subRows; - assert.equal(subRows.length, 2); - assert.equal(subRows[0].length, 2); - assert.equal(subRows[1].length, 1); - assert.equal(subRows[0][0], g.slices[0]); - assert.equal(subRows[1][0], g.slices[1]); - assert.equal(subRows[0][1], g.slices[2]); - }); - - // Tests that no slices and their sub slices overlap. - test('rebuildSubRows_NonOverlappingSubSlices', function() { - var model = new tr.Model(); - var p1 = new Process(model, 1); - var t1 = new Thread(p1, 1); - var g = new AsyncSliceGroup(t1); - - var slice1 = newAsyncSlice(0, 5, t1, t1); - var slice1Child = newAsyncSlice(1, 2, t1, t1); - slice1.subSlices = [slice1Child]; - var slice2 = newAsyncSlice(3, 5, t1, t1); - var slice3 = newAsyncSlice(5, 4, t1, t1); - var slice3Child = newAsyncSlice(6, 2, t1, t1); - slice3.subSlices = [slice3Child]; - g.push(slice1); - g.push(slice2); - g.push(slice3); - g.updateBounds(); - - var track = new AsyncSliceGroupTrack(new tr.ui.TimelineViewport()); - track.group = g; - - var subRows = track.subRows; - // Checks each sub row to see that we don't have any overlapping slices. - for (var i = 0; i < subRows.length; i++) { - var row = subRows[i]; - for (var j = 0; j < row.length; j++) { - for (var k = j + 1; k < row.length; k++) { - assert.isTrue(row[j].end <= row[k].start); - } - } - } - }); - - test('rebuildSubRows_NonOverlappingSubSlicesThreeNestedLevels', function() { - var model = new tr.Model(); - var p1 = new Process(model, 1); - var t1 = new Thread(p1, 1); - var g = new AsyncSliceGroup(t1); - - var slice1 = newAsyncSlice(0, 4, t1, t1); - var slice1Child = newAsyncSlice(1, 2, t1, t1); - slice1.subSlices = [slice1Child]; - var slice2 = newAsyncSlice(2, 7, t1, t1); - var slice3 = newAsyncSlice(5, 5, t1, t1); - var slice3Child = newAsyncSlice(6, 3, t1, t1); - var slice3Child2 = newAsyncSlice(7, 1, t1, t1); - slice3.subSlices = [slice3Child]; - slice3Child.subSlices = [slice3Child2]; - g.push(slice1); - g.push(slice2); - g.push(slice3); - g.updateBounds(); - - var track = new AsyncSliceGroupTrack(new tr.ui.TimelineViewport()); - track.group = g; - - var subRows = track.subRows; - // Checks each sub row to see that we don't have any overlapping slices. - for (var i = 0; i < subRows.length; i++) { - var row = subRows[i]; - for (var j = 0; j < row.length; j++) { - for (var k = j + 1; k < row.length; k++) { - assert.isTrue(row[j].end <= row[k].start); - } - } - } - }); - - test('asyncSliceGroupContainerMap', function() { - var vp = new tr.ui.TimelineViewport(); - var containerToTrack = vp.containerToTrackMap; - var model = new tr.Model(); - var process = model.getOrCreateProcess(123); - var thread = process.getOrCreateThread(456); - var group = new AsyncSliceGroup(thread); - - var processTrack = new ProcessTrack(vp); - var threadTrack = new ThreadTrack(vp); - var groupTrack = new AsyncSliceGroupTrack(vp); - processTrack.process = process; - threadTrack.thread = thread; - groupTrack.group = group; - processTrack.appendChild(threadTrack); - threadTrack.appendChild(groupTrack); - - assert.equal(processTrack.eventContainer, process); - assert.equal(threadTrack.eventContainer, thread); - assert.equal(groupTrack.eventContainer, group); - - assert.isUndefined(containerToTrack.getTrackByStableId('123')); - assert.isUndefined(containerToTrack.getTrackByStableId('123.456')); - assert.isUndefined( - containerToTrack.getTrackByStableId('123.456.AsyncSliceGroup')); - - vp.modelTrackContainer = { - addContainersToTrackMap: function(containerToTrackMap) { - processTrack.addContainersToTrackMap(containerToTrackMap); - }, - addEventListener: function() {} - }; - vp.rebuildContainerToTrackMap(); - - // Check that all tracks call childs' addContainersToTrackMap() - // by checking the resulting map. - assert.equal(containerToTrack.getTrackByStableId('123'), processTrack); - assert.equal(containerToTrack.getTrackByStableId('123.456'), threadTrack); - assert.equal(containerToTrack.getTrackByStableId('123.456.AsyncSliceGroup'), - groupTrack); - - // Check the track's eventContainer getter. - assert.equal(processTrack.eventContainer, process); - assert.equal(threadTrack.eventContainer, thread); - assert.equal(groupTrack.eventContainer, group); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/chart_axis.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/chart_axis.html deleted file mode 100644 index f91733ced9e..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/chart_axis.html +++ /dev/null @@ -1,127 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/range.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.tracks', function() { - - /** - * A vertical axis for a (set of) chart series which maps an arbitrary range - * of values [min, max] to the unit range [0, 1]. - * - * @constructor - */ - function ChartAxis(opt_min, opt_max) { - this.guid_ = tr.b.GUID.allocateSimple(); - this.bounds = new tr.b.Range(); - if (opt_min !== undefined) - this.bounds.addValue(opt_min); - if (opt_max !== undefined) - this.bounds.addValue(opt_max); - }; - - ChartAxis.prototype = { - get guid() { - return this.guid_; - }, - - valueToUnitRange: function(value) { - if (this.bounds.isEmpty) - throw new Error('Chart axis bounds are empty'); - var bounds = this.bounds; - if (bounds.range === 0) - return 0; - return (value - bounds.min) / bounds.range; - }, - - /** - * Automatically set the axis bounds from the range of values of all series - * in a list. - * - * See the description of autoSetFromRange for the optional configuration - * argument flags. - */ - autoSetFromSeries: function(series, opt_config) { - var range = new tr.b.Range(); - series.forEach(function(s) { - range.addRange(s.range); - }, this); - this.autoSetFromRange(range, opt_config); - }, - - /** - * Automatically set the axis bound from a range of values. - * - * The following four flags, which affect the behavior of this method with - * respect to already defined bounds, can be present in the optional - * configuration (a flag is assumed to be false if it is not provided or if - * the configuration is not provided): - * - * - expandMin: allow decreasing the min bound (if range.min < this.min) - * - shrinkMin: allow increasing the min bound (if range.min > this.min) - * - expandMax: allow increasing the max bound (if range.max > this.max) - * - shrinkMax: allow decreasing the max bound (if range.max < this.max) - * - * This method will ensure that the resulting bounds are defined and valid - * (i.e. min <= max) provided that they were valid or empty before and the - * value range is non-empty and valid. - * - * Note that unless expanding/shrinking a bound is explicitly enabled in - * the configuration, non-empty bounds will not be changed under any - * circumstances. - * - * Observe that if no configuration is provided (or all flags are set to - * false), this method will only modify the axis bounds if they are empty. - */ - autoSetFromRange: function(range, opt_config) { - if (range.isEmpty) - return; - - var bounds = this.bounds; - if (bounds.isEmpty) { - bounds.addRange(range); - return; - } - - if (!opt_config) - return; - - var useRangeMin = (opt_config.expandMin && range.min < bounds.min || - opt_config.shrinkMin && range.min > bounds.min); - var useRangeMax = (opt_config.expandMax && range.max > bounds.max || - opt_config.shrinkMax && range.max < bounds.max); - - // Neither bound is modified. - if (!useRangeMin && !useRangeMax) - return; - - // Both bounds are modified. Assuming the range argument is a valid - // range, no extra checks are necessary. - if (useRangeMin && useRangeMax) { - bounds.min = range.min; - bounds.max = range.max; - return; - } - - // Only one bound is modified. We must ensure that it doesn't go - // over/under the other (unmodified) bound. - if (useRangeMin) { - bounds.min = Math.min(range.min, bounds.max); - } else { - bounds.max = Math.max(range.max, bounds.min); - } - } - }; - - return { - ChartAxis: ChartAxis - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/chart_axis_test.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/chart_axis_test.html deleted file mode 100644 index a5f83fd56f8..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/chart_axis_test.html +++ /dev/null @@ -1,312 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/range.html"> -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/ui/tracks/chart_axis.html"> -<link rel="import" href="/tracing/ui/tracks/chart_point.html"> -<link rel="import" href="/tracing/ui/tracks/chart_series.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var ChartAxis = tr.ui.tracks.ChartAxis; - var ChartPoint = tr.ui.tracks.ChartPoint; - var ChartSeries = tr.ui.tracks.ChartSeries; - var Range = tr.b.Range; - - function buildRange() { - var range = new Range(); - for (var i = 0; i < arguments.length; i++) - range.addValue(arguments[i]); - return range; - } - - function buildSeries() { - var points = []; - for (var i = 0; i < arguments.length; i++) { - points.push(new ChartPoint(undefined, i, arguments[i])); - } - return new ChartSeries(points, new ChartAxis()); - } - - test('instantiate_emptyBounds', function() { - var axis = new ChartAxis(); - assert.isTrue(axis.bounds.isEmpty); - }); - - test('instantiate_nonEmptyBounds', function() { - var axis = new ChartAxis(-2, 12); - assert.isFalse(axis.bounds.isEmpty); - assert.equal(axis.bounds.min, -2); - assert.equal(axis.bounds.max, 12); - }); - - test('instantiate_equalBounds', function() { - var axis = new ChartAxis(2.72); - assert.isFalse(axis.bounds.isEmpty); - assert.equal(axis.bounds.min, 2.72); - assert.equal(axis.bounds.max, 2.72); - }); - - test('checkValueToUnitRange_emptyBounds', function() { - var axis = new ChartAxis(); - assert.throws(function() { axis.valueToUnitRange(42); }); - }); - - test('checkValueToUnitRange_nonEmptyBounds', function() { - var axis = new ChartAxis(10, 20); - - assert.equal(axis.valueToUnitRange(0), -1); - assert.equal(axis.valueToUnitRange(10), 0); - assert.equal(axis.valueToUnitRange(15), 0.5); - assert.equal(axis.valueToUnitRange(20), 1); - assert.equal(axis.valueToUnitRange(30), 2); - }); - - test('checkValueToUnitRange_equalBounds', function() { - var axis = new ChartAxis(3.14); - - assert.equal(axis.valueToUnitRange(0), 0); - assert.equal(axis.valueToUnitRange(3.14), 0); - assert.equal(axis.valueToUnitRange(6.28), 0); - }); - - test('checkAutoSetFromRange_emptyBounds', function() { - // Empty range. - var axis = new ChartAxis(); - axis.autoSetFromRange(buildRange()); - assert.isTrue(axis.bounds.isEmpty); - - // Non-empty range. - var axis = new ChartAxis(); - axis.autoSetFromRange(buildRange(-1, 3)); - assert.isFalse(axis.bounds.isEmpty); - assert.equal(axis.bounds.min, -1); - assert.equal(axis.bounds.max, 3); - }); - - test('checkAutoSetFromRange_nonEmptyBounds', function() { - // Empty range. - var axis = new ChartAxis(0, 1); - axis.autoSetFromRange(buildRange()); - assert.isFalse(axis.bounds.isEmpty); - assert.equal(axis.bounds.min, 0); - assert.equal(axis.bounds.max, 1); - - // No configuration. - var axis = new ChartAxis(2, 3); - axis.autoSetFromRange(buildRange(1, 4)); - assert.isFalse(axis.bounds.isEmpty); - assert.equal(axis.bounds.min, 2); - assert.equal(axis.bounds.max, 3); - - // Allow expanding min. - var axis = new ChartAxis(-2, -1); - axis.autoSetFromRange(buildRange(-3, 0), {expandMin: true}); - assert.isFalse(axis.bounds.isEmpty); - assert.equal(axis.bounds.min, -3); - assert.equal(axis.bounds.max, -1); - - // Allow shrinking min. - var axis = new ChartAxis(-2, -1); - axis.autoSetFromRange(buildRange(-1.5, 0.5), {shrinkMin: true}); - assert.isFalse(axis.bounds.isEmpty); - assert.equal(axis.bounds.min, -1.5); - assert.equal(axis.bounds.max, -1); - - var axis = new ChartAxis(7, 8); - axis.autoSetFromRange(buildRange(9, 10), {shrinkMin: true}); - assert.isFalse(axis.bounds.isEmpty); - assert.equal(axis.bounds.min, 8); - assert.equal(axis.bounds.max, 8); - - // Allow expanding max. - var axis = new ChartAxis(19, 20); - axis.autoSetFromRange(buildRange(18, 21), {expandMax: true}); - assert.isFalse(axis.bounds.isEmpty); - assert.equal(axis.bounds.min, 19); - assert.equal(axis.bounds.max, 21); - - // Allow shrinking max. - var axis = new ChartAxis(30, 32); - axis.autoSetFromRange(buildRange(29, 31), {shrinkMax: true}); - assert.isFalse(axis.bounds.isEmpty); - assert.equal(axis.bounds.min, 30); - assert.equal(axis.bounds.max, 31); - - var axis = new ChartAxis(41, 42); - axis.autoSetFromRange(buildRange(39, 40), {shrinkMax: true}); - assert.isFalse(axis.bounds.isEmpty); - assert.equal(axis.bounds.min, 41); - assert.equal(axis.bounds.max, 41); - - // Allow shrinking both bounds. - var axis = new ChartAxis(50, 53); - axis.autoSetFromRange(buildRange(51, 52), - {shrinkMin: true, shrinkMax: true}); - assert.isFalse(axis.bounds.isEmpty); - assert.equal(axis.bounds.min, 51); - assert.equal(axis.bounds.max, 52); - - var axis = new ChartAxis(50, 53); - axis.autoSetFromRange(buildRange(49, 52), - {shrinkMin: true, shrinkMax: true}); - assert.isFalse(axis.bounds.isEmpty); - assert.equal(axis.bounds.min, 50); - assert.equal(axis.bounds.max, 52); - - var axis = new ChartAxis(50, 53); - axis.autoSetFromRange(buildRange(51, 54), - {shrinkMin: true, shrinkMax: true}); - assert.isFalse(axis.bounds.isEmpty); - assert.equal(axis.bounds.min, 51); - assert.equal(axis.bounds.max, 53); - - var axis = new ChartAxis(50, 53); - axis.autoSetFromRange(buildRange(49, 54), - {shrinkMin: true, shrinkMax: true}); - assert.isFalse(axis.bounds.isEmpty); - assert.equal(axis.bounds.min, 50); - assert.equal(axis.bounds.max, 53); - - // Allow expanding both bounds. - var axis = new ChartAxis(60, 61); - axis.autoSetFromRange(buildRange(0, 100), - {expandMin: true, expandMax: true}); - assert.isFalse(axis.bounds.isEmpty); - assert.equal(axis.bounds.min, 0); - assert.equal(axis.bounds.max, 100); - - var axis = new ChartAxis(60, 61); - axis.autoSetFromRange(buildRange(60.5, 100), - {expandMin: true, expandMax: true}); - assert.isFalse(axis.bounds.isEmpty); - assert.equal(axis.bounds.min, 60); - assert.equal(axis.bounds.max, 100); - - var axis = new ChartAxis(60, 61); - axis.autoSetFromRange(buildRange(0, 60.5), - {expandMin: true, expandMax: true}); - assert.isFalse(axis.bounds.isEmpty); - assert.equal(axis.bounds.min, 0); - assert.equal(axis.bounds.max, 61); - - var axis = new ChartAxis(60, 61); - axis.autoSetFromRange(buildRange(60.2, 60.8), - {expandMin: true, expandMax: true}); - assert.isFalse(axis.bounds.isEmpty); - assert.equal(axis.bounds.min, 60); - assert.equal(axis.bounds.max, 61); - - // Allow shrinking min and expanding max. - var axis = new ChartAxis(60, 61); - axis.autoSetFromRange(buildRange(62, 63), - {shrinkMin: true, expandMax: true}); - assert.isFalse(axis.bounds.isEmpty); - assert.equal(axis.bounds.min, 62); - assert.equal(axis.bounds.max, 63); - - var axis = new ChartAxis(60, 61); - axis.autoSetFromRange(buildRange(59, 63), - {shrinkMin: true, expandMax: true}); - assert.isFalse(axis.bounds.isEmpty); - assert.equal(axis.bounds.min, 60); - assert.equal(axis.bounds.max, 63); - - var axis = new ChartAxis(60, 61); - axis.autoSetFromRange(buildRange(60.2, 60.8), - {shrinkMin: true, expandMax: true}); - assert.isFalse(axis.bounds.isEmpty); - assert.equal(axis.bounds.min, 60.2); - assert.equal(axis.bounds.max, 61); - - var axis = new ChartAxis(60, 61); - axis.autoSetFromRange(buildRange(59, 60.5), - {shrinkMin: true, expandMax: true}); - assert.isFalse(axis.bounds.isEmpty); - assert.equal(axis.bounds.min, 60); - assert.equal(axis.bounds.max, 61); - - // Allow expanding min and shrinking max. - var axis = new ChartAxis(60, 61); - axis.autoSetFromRange(buildRange(62, 63), - {expandMin: true, shrinkMax: true}); - assert.isFalse(axis.bounds.isEmpty); - assert.equal(axis.bounds.min, 60); - assert.equal(axis.bounds.max, 61); - - var axis = new ChartAxis(60, 61); - axis.autoSetFromRange(buildRange(59, 63), - {expandMin: true, shrinkMax: true}); - assert.isFalse(axis.bounds.isEmpty); - assert.equal(axis.bounds.min, 59); - assert.equal(axis.bounds.max, 61); - - var axis = new ChartAxis(60, 61); - axis.autoSetFromRange(buildRange(60.2, 60.8), - {expandMin: true, shrinkMax: true}); - assert.isFalse(axis.bounds.isEmpty); - assert.equal(axis.bounds.min, 60); - assert.equal(axis.bounds.max, 60.8); - - var axis = new ChartAxis(60, 61); - axis.autoSetFromRange(buildRange(59, 60.5), - {expandMin: true, shrinkMax: true}); - assert.isFalse(axis.bounds.isEmpty); - assert.equal(axis.bounds.min, 59); - assert.equal(axis.bounds.max, 60.5); - - // Allow everything. - var axis = new ChartAxis(200, 250); - axis.autoSetFromRange(buildRange(150, 175), - {expandMin: true, expandMax: true, shrinkMin: true, shrinkMax: true}); - assert.isFalse(axis.bounds.isEmpty); - assert.equal(axis.bounds.min, 150); - assert.equal(axis.bounds.max, 175); - - var axis = new ChartAxis(0, 0.1); - axis.autoSetFromRange(buildRange(0.2, 0.3), - {expandMin: true, expandMax: true, shrinkMin: true, shrinkMax: true}); - assert.isFalse(axis.bounds.isEmpty); - assert.equal(axis.bounds.min, 0.2); - assert.equal(axis.bounds.max, 0.3); - }); - - test('checkAutoSetFromSeries_noSeries', function() { - var axis = new ChartAxis(-100, 100); - var series = []; - - axis.autoSetFromSeries(series); - assert.equal(axis.bounds.min, -100); - assert.equal(axis.bounds.max, 100); - }); - - test('checkAutoSetFromSeries_oneSeries', function() { - var axis = new ChartAxis(-100, 100); - var series = [buildSeries(-80, 100, -40, 200)]; - - axis.autoSetFromSeries(series, {shrinkMin: true, expandMax: true}); - assert.equal(axis.bounds.min, -80); - assert.equal(axis.bounds.max, 200); - }); - - test('checkAutoSetFromSeries_multipleSeries', function() { - var axis = new ChartAxis(-100, 100); - var series = [ - buildSeries(0, 20, 10, 30), - buildSeries(), - buildSeries(-500) - ]; - - axis.autoSetFromSeries(series, {expandMin: true, shrinkMax: true}); - assert.equal(axis.bounds.min, -500); - assert.equal(axis.bounds.max, 30); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/chart_point.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/chart_point.html deleted file mode 100644 index f5b5587dcde..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/chart_point.html +++ /dev/null @@ -1,43 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/model/proxy_selectable_item.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.tracks', function() { - - /** - * A point in a chart series with x (timestamp) and y (value) coordinates - * and an associated model item. The point can optionally also have a base - * y coordinate (which for example corresponds to the bottom edge of the - * associated bar in a bar chart). - * - * @constructor - * @extends {ProxySelectableItem} - */ - function ChartPoint(modelItem, x, y, opt_yBase) { - tr.model.ProxySelectableItem.call(this, modelItem); - this.x = x; - this.y = y; - - // If the base y-coordinate is undefined, the bottom edge of the associated - // bar in a bar chart will start at the outer bottom edge (which is most - // likely slightly below zero). - this.yBase = opt_yBase; - }; - - ChartPoint.prototype = { - __proto__: tr.model.ProxySelectableItem.prototype - }; - - return { - ChartPoint: ChartPoint - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/chart_point_test.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/chart_point_test.html deleted file mode 100644 index 491784dbe51..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/chart_point_test.html +++ /dev/null @@ -1,37 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/ui/tracks/chart_point.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var ChartPoint = tr.ui.tracks.ChartPoint; - - test('checkFields_withoutYBase', function() { - var event = {}; - var point = new ChartPoint(event, 42, -7); - - assert.equal(point.modelItem, event); - assert.equal(point.x, 42); - assert.equal(point.y, -7); - assert.isUndefined(point.yBase); - }); - - test('checkFields_withYBase', function() { - var event = {}; - var point = new ChartPoint(event, 111, 222, 333); - - assert.equal(point.modelItem, event); - assert.equal(point.x, 111); - assert.equal(point.y, 222); - assert.equal(point.yBase, 333); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/chart_series.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/chart_series.html deleted file mode 100644 index 05cd5a03a6e..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/chart_series.html +++ /dev/null @@ -1,494 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/range.html"> -<link rel="import" href="/tracing/ui/base/event_presenter.html"> -<link rel="import" href="/tracing/model/proxy_selectable_item.html"> -<link rel="import" href="/tracing/model/selection_state.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.tracks', function() { - var EventPresenter = tr.ui.b.EventPresenter; - var SelectionState = tr.model.SelectionState; - - /** - * The type of a chart series. - * @enum - */ - var ChartSeriesType = { - LINE: 0, - AREA: 1 - }; - - // The default rendering configuration for ChartSeries. - var DEFAULT_RENDERING_CONFIG = { - // The type of the chart series. - chartType: ChartSeriesType.LINE, - - // The size of a selected point dot in device-independent pixels (circle - // diameter). - selectedPointSize: 4, - - // The size of an unselected point dot in device-independent pixels (square - // width/height). - unselectedPointSize: 3, - - // The color of the chart. - colorId: 0, - - // The width of the top line in device-independent pixels. - lineWidth: 1, - - // Minimum distance between points in physical pixels. Points which are - // closer than this distance will be skipped. - skipDistance: 1, - - // Density in points per physical pixel at which unselected point dots - // become transparent. - unselectedPointDensityTransparent: 0.10, - - // Density in points per physical pixel at which unselected point dots - // become fully opaque. - unselectedPointDensityOpaque: 0.05, - - // Opacity of area chart background. - backgroundOpacity: 0.5 - }; - - // The virtual width of the last point in a series (whose rectangle has zero - // width) in world timestamps difference for the purposes of selection. - var LAST_POINT_WIDTH = 16; - - /** - * Visual components of a ChartSeries. - * @enum - */ - var ChartSeriesComponent = { - BACKGROUND: 0, - LINE: 1, - DOTS: 2 - }; - - /** - * A series of points corresponding to a single chart on a chart track. - * This class is responsible for drawing the actual chart onto canvas. - * - * @constructor - */ - function ChartSeries(points, axis, opt_renderingConfig) { - this.points = points; - this.axis = axis; - - this.useRenderingConfig_(opt_renderingConfig); - } - - ChartSeries.prototype = { - useRenderingConfig_: function(opt_renderingConfig) { - var config = opt_renderingConfig || {}; - - // Store all configuration flags as private properties. - tr.b.iterItems(DEFAULT_RENDERING_CONFIG, function(key, defaultValue) { - var value = config[key]; - if (value === undefined) - value = defaultValue; - this[key + '_'] = value; - }, this); - - // Avoid unnecessary recomputation in getters. - this.topPadding = this.bottomPadding = Math.max( - this.selectedPointSize_, this.unselectedPointSize_) / 2; - }, - - get range() { - var range = new tr.b.Range(); - this.points.forEach(function(point) { - range.addValue(point.y); - }, this); - return range; - }, - - draw: function(ctx, transform, highDetails) { - if (this.points === undefined || this.points.length === 0) - return; - - // Draw the background. - if (this.chartType_ === ChartSeriesType.AREA) { - this.drawComponent_(ctx, transform, ChartSeriesComponent.BACKGROUND, - highDetails); - } - - // Draw the line at the top. - if (this.chartType_ === ChartSeriesType.LINE || highDetails) { - this.drawComponent_(ctx, transform, ChartSeriesComponent.LINE, - highDetails); - } - - // Draw the points. - this.drawComponent_(ctx, transform, ChartSeriesComponent.DOTS, - highDetails); - }, - - drawComponent_: function(ctx, transform, component, highDetails) { - // We need to consider extra pixels outside the visible area to avoid - // visual glitches due to non-zero width of dots. - var extraPixels = 0; - if (component === ChartSeriesComponent.DOTS) { - extraPixels = Math.max( - this.selectedPointSize_, this.unselectedPointSize_); - } - var leftViewX = transform.leftViewX - extraPixels * transform.pixelRatio; - var rightViewX = transform.rightViewX + - extraPixels * transform.pixelRatio; - var leftTimestamp = transform.leftTimestamp - extraPixels; - var rightTimestamp = transform.rightTimestamp + extraPixels; - - // Find the index of the first and last (partially) visible points. - var firstVisibleIndex = tr.b.findLowIndexInSortedArray( - this.points, - function(point) { return point.x; }, - leftTimestamp); - var lastVisibleIndex = tr.b.findLowIndexInSortedArray( - this.points, - function(point) { return point.x; }, - rightTimestamp); - if (lastVisibleIndex >= this.points.length || - this.points[lastVisibleIndex].x > rightTimestamp) { - lastVisibleIndex--; - } - - // Pre-calculate component style which does not depend on individual - // points: - // * Skip distance between points, - // * Selected (circle) and unselected (square) dot size, - // * Unselected dot opacity, - // * Selected dot edge color and width, and - // * Line component color and width. - var viewSkipDistance = this.skipDistance_ * transform.pixelRatio; - var circleRadius; - var squareSize; - var squareHalfSize; - var squareOpacity; - - switch (component) { - case ChartSeriesComponent.DOTS: - // Selected dot edge color and width. - ctx.strokeStyle = EventPresenter.getCounterSeriesColor( - this.colorId_, SelectionState.NONE); - ctx.lineWidth = transform.pixelRatio; - - // Selected (circle) and unselected (square) dot size. - circleRadius = (this.selectedPointSize_ / 2) * transform.pixelRatio; - squareSize = this.unselectedPointSize_ * transform.pixelRatio; - squareHalfSize = squareSize / 2; - - // Unselected dot opacity. - if (!highDetails) { - // Unselected dots are not displayed in 'low details' mode. - squareOpacity = 0; - break; - } - var visibleIndexRange = lastVisibleIndex - firstVisibleIndex; - if (visibleIndexRange <= 0) { - // There is at most one visible point. - squareOpacity = 1; - break; - } - var visibleViewXRange = - transform.worldXToViewX(this.points[lastVisibleIndex].x) - - transform.worldXToViewX(this.points[firstVisibleIndex].x); - if (visibleViewXRange === 0) { - // Multiple visible points which all have the same timestamp. - squareOpacity = 1; - break; - } - var density = visibleIndexRange / visibleViewXRange; - var clampedDensity = tr.b.clamp(density, - this.unselectedPointDensityOpaque_, - this.unselectedPointDensityTransparent_); - var densityRange = this.unselectedPointDensityTransparent_ - - this.unselectedPointDensityOpaque_; - squareOpacity = - (this.unselectedPointDensityTransparent_ - clampedDensity) / - densityRange; - break; - - case ChartSeriesComponent.LINE: - // Line component color and width. - ctx.strokeStyle = EventPresenter.getCounterSeriesColor( - this.colorId_, SelectionState.NONE); - ctx.lineWidth = this.lineWidth_ * transform.pixelRatio; - break; - - case ChartSeriesComponent.BACKGROUND: - // Style depends on the selection state of individual points. - break; - - default: - throw new Error('Invalid component: ' + component); - } - - // The main loop which draws the given component of visible points from - // left to right. Given the potentially large number of points to draw, - // it should be considered performance-critical and function calls should - // be avoided when possible. - // - // Note that the background and line components are drawn in a delayed - // fashion: the rectangle/line that we draw in an iteration corresponds - // to the *previous* point. This does not apply to the dots, whose - // position is independent of the surrounding dots. - var previousViewX = undefined; - var previousViewY = undefined; - var previousViewYBase = undefined; - var lastSelectionState = undefined; - var baseSteps = undefined; - var startIndex = Math.max(firstVisibleIndex - 1, 0); - - for (var i = startIndex; i < this.points.length; i++) { - var currentPoint = this.points[i]; - var currentViewX = transform.worldXToViewX(currentPoint.x); - - // Stop drawing the points once we are to the right of the visible area. - if (currentViewX > rightViewX) { - if (previousViewX !== undefined) { - previousViewX = currentViewX = rightViewX; - if (component === ChartSeriesComponent.BACKGROUND || - component === ChartSeriesComponent.LINE) { - ctx.lineTo(currentViewX, previousViewY); - } - } - break; - } - - if (i + 1 < this.points.length) { - var nextPoint = this.points[i + 1]; - var nextViewX = transform.worldXToViewX(nextPoint.x); - - // Skip points that are too close to each other. - if (previousViewX !== undefined && - nextViewX - previousViewX <= viewSkipDistance && - nextViewX < rightViewX) { - continue; - } - - // Start drawing right at the left side of the visible are (instead - // of potentially very far to the left). - if (currentViewX < leftViewX) { - currentViewX = leftViewX; - } - } - - if (previousViewX !== undefined && - currentViewX - previousViewX < viewSkipDistance) { - // We know that nextViewX > previousViewX + viewSkipDistance, so we - // can safely move this points's x over that much without passing - // nextViewX. This ensures that the previous point is visible when - // zoomed out very far. - currentViewX = previousViewX + viewSkipDistance; - } - - var currentViewY = Math.round(transform.worldYToViewY(currentPoint.y)); - var currentViewYBase; - if (currentPoint.yBase === undefined) { - currentViewYBase = transform.outerBottomViewY; - } else { - currentViewYBase = Math.round( - transform.worldYToViewY(currentPoint.yBase)); - } - var currentSelectionState = currentPoint.selectionState; - - // Actually draw the given component of the point. - switch (component) { - case ChartSeriesComponent.DOTS: - // Change dot style when the selection state changes (and at the - // beginning). - if (currentSelectionState !== lastSelectionState) { - if (currentSelectionState === SelectionState.SELECTED) { - ctx.fillStyle = EventPresenter.getCounterSeriesColor( - this.colorId_, currentSelectionState); - } else if (squareOpacity > 0) { - ctx.fillStyle = EventPresenter.getCounterSeriesColor( - this.colorId_, currentSelectionState, squareOpacity); - } - } - - // Draw the dot for the current point. - if (currentSelectionState === SelectionState.SELECTED) { - ctx.beginPath(); - ctx.arc(currentViewX, currentViewY, circleRadius, 0, 2 * Math.PI); - ctx.fill(); - ctx.stroke(); - } else if (squareOpacity > 0) { - ctx.fillRect(currentViewX - squareHalfSize, - currentViewY - squareHalfSize, squareSize, squareSize); - } - break; - - case ChartSeriesComponent.LINE: - // Draw the top line for the previous point (if applicable), or - // prepare for drawing the top line of the current point in the next - // iteration. - if (previousViewX === undefined) { - ctx.beginPath(); - ctx.moveTo(currentViewX, currentViewY); - } else { - ctx.lineTo(currentViewX, previousViewY); - } - - // Move to the current point coordinate. - ctx.lineTo(currentViewX, currentViewY); - break; - - case ChartSeriesComponent.BACKGROUND: - // Draw the background for the previous point (if applicable). - if (previousViewX !== undefined) - ctx.lineTo(currentViewX, previousViewY); - - // Finish the bottom part of the backgound polygon, change - // background color and start a new polygon when the selection state - // changes (and at the beginning). - if (currentSelectionState !== lastSelectionState) { - if (previousViewX !== undefined) { - var previousBaseStepViewX = currentViewX; - for (var j = baseSteps.length - 1; j >= 0; j--) { - var baseStep = baseSteps[j]; - var baseStepViewX = baseStep.viewX; - var baseStepViewY = baseStep.viewY; - ctx.lineTo(previousBaseStepViewX, baseStepViewY); - ctx.lineTo(baseStepViewX, baseStepViewY); - previousBaseStepViewX = baseStepViewX; - } - ctx.closePath(); - ctx.fill(); - } - ctx.beginPath(); - ctx.fillStyle = EventPresenter.getCounterSeriesColor( - this.colorId_, currentSelectionState, - this.backgroundOpacity_); - ctx.moveTo(currentViewX, currentViewYBase); - baseSteps = []; - } - - if (currentViewYBase !== previousViewYBase || - currentSelectionState !== lastSelectionState) { - baseSteps.push({viewX: currentViewX, viewY: currentViewYBase}); - } - - // Move to the current point coordinate. - ctx.lineTo(currentViewX, currentViewY); - break; - - default: - throw new Error('Not reachable'); - } - - previousViewX = currentViewX; - previousViewY = currentViewY; - previousViewYBase = currentViewYBase; - lastSelectionState = currentSelectionState; - } - - // If we still have an open background or top line polygon (which is - // always the case once we have started drawing due to the delayed fashion - // of drawing), we must close it. - if (previousViewX !== undefined) { - switch (component) { - case ChartSeriesComponent.DOTS: - // All dots were drawn in the main loop. - break; - - case ChartSeriesComponent.LINE: - ctx.stroke(); - break; - - case ChartSeriesComponent.BACKGROUND: - var previousBaseStepViewX = currentViewX; - for (var j = baseSteps.length - 1; j >= 0; j--) { - var baseStep = baseSteps[j]; - var baseStepViewX = baseStep.viewX; - var baseStepViewY = baseStep.viewY; - ctx.lineTo(previousBaseStepViewX, baseStepViewY); - ctx.lineTo(baseStepViewX, baseStepViewY); - previousBaseStepViewX = baseStepViewX; - } - ctx.closePath(); - ctx.fill(); - break; - - default: - throw new Error('Not reachable'); - } - } - }, - - addIntersectingEventsInRangeToSelectionInWorldSpace: function( - loWX, hiWX, viewPixWidthWorld, selection) { - var points = this.points; - - function getPointWidth(point, i) { - if (i === points.length - 1) - return LAST_POINT_WIDTH * viewPixWidthWorld; - var nextPoint = points[i + 1]; - return nextPoint.x - point.x; - } - - function selectPoint(point) { - point.addToSelection(selection); - } - - tr.b.iterateOverIntersectingIntervals( - this.points, - function(point) { return point.x }, - getPointWidth, - loWX, - hiWX, - selectPoint); - }, - - addEventNearToProvidedEventToSelection: function(event, offset, selection) { - if (this.points === undefined) - return false; - - var index = tr.b.findFirstIndexInArray(this.points, function(point) { - return point.modelItem === event; - }, this); - if (index === -1) - return false; - - var newIndex = index + offset; - if (newIndex < 0 || newIndex >= this.points.length) - return false; - - this.points[newIndex].addToSelection(selection); - return true; - }, - - addClosestEventToSelection: function(worldX, worldMaxDist, loY, hiY, - selection) { - if (this.points === undefined) - return; - - var item = tr.b.findClosestElementInSortedArray( - this.points, - function(point) { return point.x }, - worldX, - worldMaxDist); - - if (!item) - return; - - item.addToSelection(selection); - } - }; - - return { - ChartSeries: ChartSeries, - ChartSeriesType: ChartSeriesType - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/chart_series_test.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/chart_series_test.html deleted file mode 100644 index bf84ef56c6a..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/chart_series_test.html +++ /dev/null @@ -1,294 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/event.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/ui/timeline_display_transform.html"> -<link rel="import" href="/tracing/ui/tracks/chart_axis.html"> -<link rel="import" href="/tracing/ui/tracks/chart_point.html"> -<link rel="import" href="/tracing/ui/tracks/chart_series.html"> -<link rel="import" href="/tracing/ui/tracks/chart_transform.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var EventSet = tr.model.EventSet; - var TimelineDisplayTransform = tr.ui.TimelineDisplayTransform; - var Event = tr.model.Event; - var ChartAxis = tr.ui.tracks.ChartAxis; - var ChartPoint = tr.ui.tracks.ChartPoint; - var ChartSeries = tr.ui.tracks.ChartSeries; - var ChartTransform = tr.ui.tracks.ChartTransform; - var ChartSeriesType = tr.ui.tracks.ChartSeriesType; - - var CANVAS_WIDTH = 800; - var CANVAS_HEIGHT = 80; - - function buildSeries(renderingConfig) { - var points = []; - for (var i = 0; i < 60; i++) { - var event = new Event(); - event.index = i; - var phase = i * Math.PI / 15; - var value = Math.sin(phase); - var peakIndex = Math.floor((phase + Math.PI / 2) / (2 * Math.PI)); - var base = peakIndex % 2 === 0 ? undefined : -1 + value / 1.5; - var point = new ChartPoint(event, i - 30, value, base); - points.push(point); - } - var axis = new ChartAxis(-1, 1); - return new ChartSeries(points, axis, renderingConfig); - } - - function drawSeriesWithDetails(test, series, highDetails) { - var div = document.createElement('div'); - var canvas = document.createElement('canvas'); - div.appendChild(canvas); - - var pixelRatio = window.devicePixelRatio || 1; - - canvas.width = CANVAS_WIDTH * pixelRatio; - canvas.style.width = CANVAS_WIDTH + 'px'; - canvas.height = CANVAS_HEIGHT * pixelRatio; - canvas.style.height = CANVAS_HEIGHT + 'px'; - - var displayTransform = new TimelineDisplayTransform(); - displayTransform.scaleX = CANVAS_WIDTH * pixelRatio / 60; - displayTransform.panX = 30; - - var transform = new ChartTransform( - displayTransform, - series.axis, - CANVAS_WIDTH * pixelRatio, - CANVAS_HEIGHT * pixelRatio, - 10 * pixelRatio, - 10 * pixelRatio, - pixelRatio); - - series.draw(canvas.getContext('2d'), transform, highDetails); - - test.addHTMLOutput(div); - } - - function drawSeries(test, series) { - drawSeriesWithDetails(test, series, false); - drawSeriesWithDetails(test, series, true); - } - - test('instantiate_defaultConfig', function() { - var series = buildSeries(undefined); - drawSeries(this, series); - }); - - test('instantiate_lineChart', function() { - var series = buildSeries({ - chartType: ChartSeriesType.LINE, - colorId: 4, - unselectedPointSize: 6, - lineWidth: 2, - unselectedPointDensityOpaque: 0.08 - }); - drawSeries(this, series); - }); - - test('instantiate_areaChart', function() { - var series = buildSeries({ - chartType: ChartSeriesType.AREA, - colorId: 2, - backgroundOpacity: 0.2 - }); - drawSeries(this, series); - }); - - test('instantiate_largeSkipDistance', function() { - var series = buildSeries({ - chartType: ChartSeriesType.AREA, - colorId: 1, - skipDistance: 40, - unselectedPointDensityTransparent: 0.07 - }); - drawSeries(this, series); - }); - - test('instantiate_selection', function() { - var series = buildSeries({ - chartType: ChartSeriesType.AREA, - colorId: 10 - }); - series.points.forEach(function(point, index) { - point.modelItem.selectionState = index % 4; - }); - drawSeries(this, series); - }); - - test('instantiate_selectionWithAllConfigFlags', function() { - var series = buildSeries({ - chartType: ChartSeriesType.AREA, - selectedPointSize: 10, - unselectedPointSize: 6, - colorId: 15, - lineWidth: 2, - skipDistance: 25, - unselectedPointDensityOpaque: 0.07, - unselectedPointDensityTransparent: 0.09, - backgroundOpacity: 0.8 - }); - series.points.forEach(function(point, index) { - point.modelItem.selectionState = index % 4; - }); - drawSeries(this, series); - }); - - test('checkRange', function() { - var series = buildSeries(); - var range = series.range; - assert.isFalse(range.isEmpty); - assert.closeTo(range.min, -1, 0.05); - assert.closeTo(range.max, 1, 0.05); - }); - - test('checkaddIntersectingEventsInRangeToSelectionInWorldSpace', function() { - var series = buildSeries(); - - // Too far left. - var sel = new EventSet(); - series.addIntersectingEventsInRangeToSelectionInWorldSpace( - -1000, -30.5, 40, sel); - assert.lengthOf(sel, 0); - - // Select first point. - var sel = new EventSet(); - series.addIntersectingEventsInRangeToSelectionInWorldSpace( - -30.5, -29.5, 40, sel); - assert.lengthOf(sel, 1); - assert.equal(sel[0].index, 0); - - // Select second point. - var sel = new EventSet(); - series.addIntersectingEventsInRangeToSelectionInWorldSpace( - -28.8, -28.2, 40, sel); - assert.lengthOf(sel, 1); - assert.equal(sel[0].index, 1); - - // Select points in the middle. - var sel = new EventSet(); - series.addIntersectingEventsInRangeToSelectionInWorldSpace( - -0.99, 1.01, 40, sel); - assert.lengthOf(sel, 3); - assert.equal(sel[0].index, 29); - assert.equal(sel[1].index, 30); - assert.equal(sel[2].index, 31); - - // Select the last point. - var sel = new EventSet(); - series.addIntersectingEventsInRangeToSelectionInWorldSpace( - 668.99, 668.99, 40, sel); - assert.lengthOf(sel, 1); - assert.equal(sel[0].index, 59); - - // Too far right. - var sel = new EventSet(); - series.addIntersectingEventsInRangeToSelectionInWorldSpace( - 669.01, 2000, 40, sel); - assert.lengthOf(sel, 0); - - // Select everything. - var sel = new EventSet(); - series.addIntersectingEventsInRangeToSelectionInWorldSpace( - -29.01, 669.01, 40, sel); - assert.lengthOf(sel, 60); - }); - - test('checkaddEventNearToProvidedEventToSelection', function() { - var series = buildSeries(); - - // Invalid event. - var sel = new EventSet(); - assert.isFalse(series.addEventNearToProvidedEventToSelection( - new Event(), 1, sel)); - assert.lengthOf(sel, 0); - - var sel = new EventSet(); - assert.isFalse(series.addEventNearToProvidedEventToSelection( - new Event(), -1, sel)); - assert.lengthOf(sel, 0); - - // First point. - var sel = new EventSet(); - assert.isTrue(series.addEventNearToProvidedEventToSelection( - series.points[0].modelItem, 1, sel)); - assert.lengthOf(sel, 1); - assert.equal(sel[0].index, 1); - - var sel = new EventSet(); - assert.isFalse(series.addEventNearToProvidedEventToSelection( - series.points[0].modelItem, -1, sel)); - assert.lengthOf(sel, 0); - - // Middle point. - var sel = new EventSet(); - assert.isTrue(series.addEventNearToProvidedEventToSelection( - series.points[30].modelItem, 1, sel)); - assert.lengthOf(sel, 1); - assert.equal(sel[0].index, 31); - - var sel = new EventSet(); - assert.isTrue(series.addEventNearToProvidedEventToSelection( - series.points[30].modelItem, -1, sel)); - assert.lengthOf(sel, 1); - assert.equal(sel[0].index, 29); - - // Last point. - var sel = new EventSet(); - assert.isFalse(series.addEventNearToProvidedEventToSelection( - series.points[59].modelItem, 1, sel)); - assert.lengthOf(sel, 0); - - var sel = new EventSet(); - assert.isTrue(series.addEventNearToProvidedEventToSelection( - series.points[59].modelItem, -1, sel)); - assert.lengthOf(sel, 1); - assert.equal(sel[0].index, 58); - }); - - test('checkAddClosestEventToSelection', function() { - var series = buildSeries(); - - // Left of first point. - var sel = new EventSet(); - series.addClosestEventToSelection(-40, 9, -0.5, 0.5, sel); - assert.lengthOf(sel, 0); - - var sel = new EventSet(); - series.addClosestEventToSelection(-40, 11, -0.5, 0.5, sel); - assert.lengthOf(sel, 1); - assert.equal(sel[0].index, 0); - - // Between two points. - var sel = new EventSet(); - series.addClosestEventToSelection(0.4, 0.3, -0.5, 0.5, sel); - assert.lengthOf(sel, 0); - - var sel = new EventSet(); - series.addClosestEventToSelection(0.4, 0.4, -0.5, 0.5, sel); - assert.lengthOf(sel, 1); - assert.equal(sel[0].index, 30); - - // Right of last point. - var sel = new EventSet(); - series.addClosestEventToSelection(40, 10, -0.5, 0.5, sel); - assert.lengthOf(sel, 0); - - var sel = new EventSet(); - series.addClosestEventToSelection(40, 12, -0.5, 0.5, sel); - assert.lengthOf(sel, 1); - assert.equal(sel[0].index, 59); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/chart_track.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/chart_track.html deleted file mode 100644 index 86e80ae1cde..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/chart_track.html +++ /dev/null @@ -1,241 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/tracks/chart_transform.html"> -<link rel="import" href="/tracing/ui/tracks/track.html"> -<link rel="import" href="/tracing/ui/base/heading.html"> -<link rel="import" href="/tracing/ui/base/ui.html"> - -<style> -.chart-track { - height: 30px; - position: relative; -} -</style> - -<script> -'use strict'; - -tr.exportTo('tr.ui.tracks', function() { - - /** - * A track that displays a chart. - * - * @constructor - * @extends {Track} - */ - var ChartTrack = - tr.ui.b.define('chart-track', tr.ui.tracks.Track); - - ChartTrack.prototype = { - __proto__: tr.ui.tracks.Track.prototype, - - decorate: function(viewport) { - tr.ui.tracks.Track.prototype.decorate.call(this, viewport); - this.classList.add('chart-track'); - this.series_ = undefined; - - // GUID -> {axis: ChartAxis, series: [ChartSeries]}. - this.axisGuidToAxisData_ = undefined; - - // The maximum top and bottom padding of all series. - this.topPadding_ = undefined; - this.bottomPadding_ = undefined; - - this.heading_ = document.createElement('tr-ui-heading'); - this.appendChild(this.heading_); - }, - - set heading(heading) { - this.heading_.heading = heading; - }, - - get heading() { - return this.heading_.heading; - }, - - set tooltip(tooltip) { - this.heading_.tooltip = tooltip; - }, - - get series() { - return this.series_; - }, - - /** - * Set the list of chart series to be displayed on this track. The list - * is assumed to be sorted in increasing z-order (i.e. the last series in - * the list will be drawn at the top). - */ - set series(series) { - this.series_ = series; - this.calculateAxisDataAndPadding_(); - this.invalidateDrawingContainer(); - }, - - get height() { - return window.getComputedStyle(this).height; - }, - - set height(height) { - this.style.height = height; - this.invalidateDrawingContainer(); - }, - - get hasVisibleContent() { - return !!this.series && this.series.length > 0; - }, - - calculateAxisDataAndPadding_: function() { - if (!this.series_) { - this.axisGuidToAxisData_ = undefined; - this.topPadding_ = undefined; - this.bottomPadding_ = undefined; - return; - } - - var axisGuidToAxisData = {}; - var topPadding = 0; - var bottomPadding = 0; - - this.series_.forEach(function(series) { - var axis = series.axis; - var axisGuid = axis.guid; - if (!(axisGuid in axisGuidToAxisData)) { - axisGuidToAxisData[axisGuid] = { - axis: axis, - series: [] - }; - } - axisGuidToAxisData[axisGuid].series.push(series); - topPadding = Math.max(topPadding, series.topPadding); - bottomPadding = Math.max(bottomPadding, series.bottomPadding); - }, this); - - this.axisGuidToAxisData_ = axisGuidToAxisData; - this.topPadding_ = topPadding; - this.bottomPadding_ = bottomPadding; - }, - - draw: function(type, viewLWorld, viewRWorld) { - switch (type) { - case tr.ui.tracks.DrawType.GENERAL_EVENT: - this.drawChart_(viewLWorld, viewRWorld); - break; - } - }, - - drawChart_: function(viewLWorld, viewRWorld) { - if (!this.series_) - return; - - var ctx = this.context(); - - // Get track drawing parameters. - var displayTransform = this.viewport.currentDisplayTransform; - var pixelRatio = window.devicePixelRatio || 1; - var bounds = this.getBoundingClientRect(); - var highDetails = this.viewport.highDetails; - - // Pre-multiply all device-independent pixel parameters with the pixel - // ratio to avoid unnecessary recomputation in the performance-critical - // drawing code. - var width = bounds.width * pixelRatio; - var height = bounds.height * pixelRatio; - var topPadding = this.topPadding_ * pixelRatio; - var bottomPadding = this.bottomPadding_ * pixelRatio; - - // Set up clipping. - ctx.save(); - ctx.beginPath(); - ctx.rect(0, 0, width, height); - ctx.clip(); - - // Draw all series in the increasing z-order. - this.series_.forEach(function(series) { - var chartTransform = new tr.ui.tracks.ChartTransform( - displayTransform, series.axis, width, height, topPadding, - bottomPadding, pixelRatio); - series.draw(ctx, chartTransform, highDetails); - }, this); - - // Stop clipping. - ctx.restore(); - }, - - addEventsToTrackMap: function(eventToTrackMap) { - // TODO(petrcermak): Consider adding the series to the track map instead - // of the track (a potential performance optimization). - this.series_.forEach(function(series) { - series.points.forEach(function(point) { - point.addToTrackMap(eventToTrackMap, this); - }, this); - }, this); - }, - - addIntersectingEventsInRangeToSelectionInWorldSpace: function( - loWX, hiWX, viewPixWidthWorld, selection) { - this.series_.forEach(function(series) { - series.addIntersectingEventsInRangeToSelectionInWorldSpace( - loWX, hiWX, viewPixWidthWorld, selection); - }, this); - }, - - addEventNearToProvidedEventToSelection: function(event, offset, selection) { - var foundItem = false; - this.series_.forEach(function(series) { - foundItem = foundItem || series.addEventNearToProvidedEventToSelection( - event, offset, selection); - }, this); - return foundItem; - }, - - addAllEventsMatchingFilterToSelection: function(filter, selection) { - // Do nothing. - }, - - addClosestEventToSelection: function(worldX, worldMaxDist, loY, hiY, - selection) { - this.series_.forEach(function(series) { - series.addClosestEventToSelection( - worldX, worldMaxDist, loY, hiY, selection); - }, this); - }, - - /** - * Automatically set the bounds of all axes on this track from the range of - * values of all series (in this track) associated with each of them. - * - * See the description of ChartAxis.autoSetFromRange for the optional - * configuration argument flags. - */ - autoSetAllAxes: function(opt_config) { - tr.b.iterItems(this.axisGuidToAxisData_, function(axisGuid, axisData) { - var axis = axisData.axis; - var series = axisData.series; - axis.autoSetFromSeries(series, opt_config); - }, this); - }, - - /** - * Automatically set the bounds of the provided axis from the range of - * values of all series (in this track) associated with it. - * - * See the description of ChartAxis.autoSetFromRange for the optional - * configuration argument flags. - */ - autoSetAxis: function(axis, opt_config) { - var series = this.axisGuidToAxisData_[axis.guid].series; - axis.autoSetFromSeries(series, opt_config); - } - }; - - return { - ChartTrack: ChartTrack - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/chart_track_test.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/chart_track_test.html deleted file mode 100644 index 7595a2e2cd7..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/chart_track_test.html +++ /dev/null @@ -1,236 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/event.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/model/selection_state.html"> -<link rel="import" href="/tracing/ui/timeline_track_view.html"> -<link rel="import" href="/tracing/ui/tracks/chart_axis.html"> -<link rel="import" href="/tracing/ui/tracks/chart_point.html"> -<link rel="import" href="/tracing/ui/tracks/chart_series.html"> -<link rel="import" href="/tracing/ui/tracks/chart_track.html"> -<link rel="import" href="/tracing/ui/tracks/event_to_track_map.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var ChartAxis = tr.ui.tracks.ChartAxis; - var ChartPoint = tr.ui.tracks.ChartPoint; - var ChartSeries = tr.ui.tracks.ChartSeries; - var ChartSeriesType = tr.ui.tracks.ChartSeriesType; - var ChartTrack = tr.ui.tracks.ChartTrack; - var Event = tr.model.Event; - var EventSet = tr.model.EventSet; - var EventToTrackMap = tr.ui.tracks.EventToTrackMap; - var SelectionState = tr.model.SelectionState; - var Viewport = tr.ui.TimelineViewport; - - function buildPoint(x, y) { - var event = new Event(); - return new ChartPoint(event, x, y); - } - - function buildTrack(opt_viewport) { - var viewport = opt_viewport || new Viewport(document.createElement('div')); - - var axis1 = new ChartAxis(0, 2); - var axis2 = new ChartAxis(-100, 100); - - var points1 = [ - buildPoint(-2.5, 2), - buildPoint(-1.5, 1), - buildPoint(-0.5, 0), - buildPoint(0.5, 1), - buildPoint(1.5, 2), - buildPoint(2.5, 0) - ]; - var renderingConfig1 = { - chartType: ChartSeriesType.AREA, - colorId: 6, - selectedPointSize: 7 - }; - var series1 = new ChartSeries(points1, axis1, renderingConfig1); - - var points2 = [ - buildPoint(-2.3, 0.2), - buildPoint(-1.3, 1.2), - buildPoint(-0.3, 2.2), - buildPoint(0.3, 1.2), - buildPoint(1.3, 0.2), - buildPoint(2.3, 0) - ]; - var renderingConfig2 = { - chartType: ChartSeriesType.AREA, - colorId: 4, - selectedPointSize: 10 - }; - var series2 = new ChartSeries(points2, axis1, renderingConfig2); - - var points3 = [ - buildPoint(-3, -50), - buildPoint(-2.4, -40), - buildPoint(-1.8, -30), - buildPoint(-1.2, -20), - buildPoint(-0.6, -10), - buildPoint(0, 0), - buildPoint(0.6, 10), - buildPoint(1.2, 20), - buildPoint(1.8, 30), - buildPoint(2.4, 40), - buildPoint(3, 50) - ]; - var renderingConfig3 = { - chartType: ChartSeriesType.LINE, - lineWidth: 2 - }; - var series3 = new ChartSeries(points3, axis2, renderingConfig3); - - var track = new ChartTrack(viewport); - track.series = [series1, series2, series3]; - - return track; - } - - test('instantiate_lowDetailsWithoutSelection', function() { - var div = document.createElement('div'); - var viewport = new Viewport(div); - var drawingContainer = new tr.ui.tracks.DrawingContainer(viewport); - div.appendChild(drawingContainer); - - var track = buildTrack(viewport); - drawingContainer.appendChild(track); - - this.addHTMLOutput(div); - drawingContainer.invalidate(); - - var dt = new tr.ui.TimelineDisplayTransform(); - var pixelRatio = window.devicePixelRatio || 1; - dt.xSetWorldBounds(-3, 3, track.clientWidth * pixelRatio); - track.viewport.setDisplayTransformImmediately(dt); - - track.height = '100px'; - }); - - test('instantiate_highDetailsWithSelection', function() { - var div = document.createElement('div'); - var viewport = new Viewport(div); - viewport.highDetails = true; - var drawingContainer = new tr.ui.tracks.DrawingContainer(viewport); - div.appendChild(drawingContainer); - - var track = buildTrack(viewport); - drawingContainer.appendChild(track); - - track.series[0].points[1].modelItem.selectionState = - SelectionState.SELECTED; - track.series[1].points[1].modelItem.selectionState = - SelectionState.SELECTED; - track.series[2].points[3].modelItem.selectionState = - SelectionState.SELECTED; - - this.addHTMLOutput(div); - drawingContainer.invalidate(); - - var dt = new tr.ui.TimelineDisplayTransform(); - var pixelRatio = window.devicePixelRatio || 1; - dt.xSetWorldBounds(-3, 3, track.clientWidth * pixelRatio); - track.viewport.setDisplayTransformImmediately(dt); - - track.height = '100px'; - }); - - test('checkPadding', function() { - var track = buildTrack(); - - // Padding should be equal to half maximum point size. - assert.equal(track.topPadding_, 5); - assert.equal(track.bottomPadding_, 5); - }); - - test('checkAddEventsToTrackMap', function() { - var track = buildTrack(); - var eventToTrackMap = new EventToTrackMap(); - track.addEventsToTrackMap(eventToTrackMap); - assert.lengthOf(Object.keys(eventToTrackMap), 23); - }); - - test('checkaddIntersectingEventsInRangeToSelectionInWorldSpace', function() { - var track = buildTrack(); - - var sel = new EventSet(); - track.addIntersectingEventsInRangeToSelectionInWorldSpace( - -1.1, -0.7, 0.01, sel); - assert.lengthOf(sel, 3); - assert.equal(sel[0], track.series[0].points[1].modelItem); - assert.equal(sel[1], track.series[1].points[1].modelItem); - assert.equal(sel[2], track.series[2].points[3].modelItem); - }); - - test('checkaddEventNearToProvidedEventToSelection', function() { - var track = buildTrack(); - - // Fail to find a near item to the left in any series. - var sel = new EventSet(); - assert.isFalse(track.addEventNearToProvidedEventToSelection( - track.series[0].points[0].modelItem, -1, sel)); - assert.lengthOf(sel, 0); - - // Succeed at finding a near item to the right of one series. - var sel = new EventSet(); - assert.isTrue(track.addEventNearToProvidedEventToSelection( - track.series[1].points[1].modelItem, 1, sel)); - assert.lengthOf(sel, 1); - assert.equal(sel[0], track.series[1].points[2].modelItem); - }); - - test('checkAddClosestEventToSelection', function() { - var track = buildTrack(); - - var sel = new EventSet(); - track.addClosestEventToSelection(-0.8, 0.4, 0.5, 1.5, sel); - assert.lengthOf(sel, 2); - assert.equal(sel[0], track.series[0].points[2].modelItem); - assert.equal(sel[1], track.series[2].points[4].modelItem); - }); - - test('checkAutoSetAllAxes', function() { - var track = buildTrack(); - var axis1 = track.series[0].axis; - var axis2 = track.series[2].axis; - - track.autoSetAllAxes({expandMax: true, shrinkMax: true}); - - // Min bounds of both axes should not have been modified. - assert.equal(axis1.bounds.min, 0); - assert.equal(axis2.bounds.min, -100); - - // Max bounds of both axes should have been modified. - assert.equal(axis1.bounds.max, 2.2); - assert.equal(axis2.bounds.max, 50); - }); - - test('checkAutoSetAxis', function() { - var track = buildTrack(); - var axis1 = track.series[0].axis; - var axis2 = track.series[2].axis; - - track.autoSetAxis(axis2, - {expandMin: true, shrinkMin: true, expandMax: true, shrinkMax: true}); - - // First axis should not have been modified. - assert.equal(axis1.bounds.min, 0); - assert.equal(axis1.bounds.max, 2); - - // Second axis should have been modified. - assert.equal(axis2.bounds.min, -50); - assert.equal(axis2.bounds.max, 50); - }); -}); -</script> - diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/chart_transform.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/chart_transform.html deleted file mode 100644 index ff98f4057e0..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/chart_transform.html +++ /dev/null @@ -1,84 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/base.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.tracks', function() { - - /** - * A helper object encapsulating all parameters necessary to draw a chart - * series and provides conversion between world coordinates and physical - * pixels. - * - * All parameters (except for pixelRatio) are assumed to be in physical pixels - * (i.e. already pre-multiplied with pixelRatio). - * - * The diagram below explains the meaning of the resulting fields with - * respect to a chart track: - * - * outerTopViewY -> +--------------------/-\-------+ <- Top padding - * innerTopViewY -> + - - - - - - - - - -| |- - - -+ <- Axis max - * | .. ==\-/== | - * | == Series == | - * | ==/-\== .. | - * innerBottomViewY -> + - - -Point- - - - - - - - - -+ <- Axis min - * outerBottomViewY -> +-------\-/--------------------+ <- Bottom padding - * ^ ^ - * leftViewX rightViewX - * leftTimeStamp rightTimestamp - * - * Labels starting with a lower case letter are the resulting fields of the - * transform object. Labels starting with an upper case letter correspond - * to the relevant chart track concepts. - * - * @constructor - */ - function ChartTransform(displayTransform, axis, trackWidth, - trackHeight, topPadding, bottomPadding, pixelRatio) { - this.pixelRatio = pixelRatio; - - // X axis. - this.leftViewX = 0; - this.rightViewX = trackWidth; - this.leftTimestamp = displayTransform.xViewToWorld(this.leftViewX); - this.rightTimestamp = displayTransform.xViewToWorld(this.rightViewX); - - this.displayTransform_ = displayTransform; - - // Y axis. - this.outerTopViewY = 0; - this.innerTopViewY = topPadding; - this.innerBottomViewY = trackHeight - bottomPadding; - this.outerBottomViewY = trackHeight; - - this.axis_ = axis; - this.innerHeight_ = this.innerBottomViewY - this.innerTopViewY; - }; - - ChartTransform.prototype = { - worldXToViewX: function(worldX) { - return this.displayTransform_.xWorldToView(worldX); - }, - - viewXToWorldX: function(viewX) { - return this.displayTransform_.xViewToWorld(viewX); - }, - - worldYToViewY: function(worldY) { - var innerHeightCoefficient = 1 - this.axis_.valueToUnitRange(worldY); - return innerHeightCoefficient * this.innerHeight_ + this.innerTopViewY; - } - }; - - return { - ChartTransform: ChartTransform - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/chart_transform_test.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/chart_transform_test.html deleted file mode 100644 index d7652260e09..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/chart_transform_test.html +++ /dev/null @@ -1,86 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/ui/timeline_display_transform.html"> -<link rel="import" href="/tracing/ui/tracks/chart_axis.html"> -<link rel="import" href="/tracing/ui/tracks/chart_transform.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var TimelineDisplayTransform = tr.ui.TimelineDisplayTransform; - var ChartTransform = tr.ui.tracks.ChartTransform; - var ChartAxis = tr.ui.tracks.ChartAxis; - - function buildChartTransform() { - var displayTransform = new TimelineDisplayTransform(); - displayTransform.panX = -20; - displayTransform.scaleX = 0.5; - - var axis = new ChartAxis(-100, 100); - - var chartTransform = new ChartTransform( - displayTransform, - axis, - 500, /* trackWidth */ - 80, /* trackHeight */ - 15, /* topPadding */ - 5, /* bottomPadding */ - 3 /* pixelRatio */); - - return chartTransform; - } - - test('checkFields', function() { - var t = buildChartTransform(); - - assert.equal(t.pixelRatio, 3); - - assert.equal(t.leftViewX, 0); - assert.equal(t.rightViewX, 500); - assert.equal(t.leftTimestamp, 20); - assert.equal(t.rightTimestamp, 1020); - - assert.equal(t.outerTopViewY, 0); - assert.equal(t.innerTopViewY, 15); - assert.equal(t.innerBottomViewY, 75); - assert.equal(t.outerBottomViewY, 80); - }); - - test('checkWorldXToViewX', function() { - var t = buildChartTransform(); - - assert.equal(t.worldXToViewX(-100), -60); - assert.equal(t.worldXToViewX(0), -10); - assert.equal(t.worldXToViewX(520), 250); - assert.equal(t.worldXToViewX(1020), 500); - assert.equal(t.worldXToViewX(1200), 590); - }); - - test('checkViewXToWorldX', function() { - var t = buildChartTransform(); - - assert.equal(t.viewXToWorldX(-60), -100); - assert.equal(t.viewXToWorldX(-10), 0); - assert.equal(t.viewXToWorldX(250), 520); - assert.equal(t.viewXToWorldX(500), 1020); - assert.equal(t.viewXToWorldX(590), 1200); - }); - - test('checkWorldYToViewY', function() { - var t = buildChartTransform(); - - assert.equal(t.worldYToViewY(-200), 105); - assert.equal(t.worldYToViewY(-100), 75); - assert.equal(t.worldYToViewY(0), 45); - assert.equal(t.worldYToViewY(100), 15); - assert.equal(t.worldYToViewY(200), -15); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/container_to_track_map.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/container_to_track_map.html deleted file mode 100644 index bb4b549ae08..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/container_to_track_map.html +++ /dev/null @@ -1,45 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/base.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.tracks', function() { - - /** - * ContainerToTrackMap is a class to handle building and accessing a map - * between an EventContainer's stableId and its handling track. - * - * @constructor - */ - function ContainerToTrackMap() { - this.stableIdToTrackMap_ = {}; - } - - ContainerToTrackMap.prototype = { - addContainer: function(container, track) { - if (!track) - throw new Error('Must provide a track.'); - this.stableIdToTrackMap_[container.stableId] = track; - }, - - clear: function() { - this.stableIdToTrackMap_ = {}; - }, - - getTrackByStableId: function(stableId) { - return this.stableIdToTrackMap_[stableId]; - } - }; - - return { - ContainerToTrackMap: ContainerToTrackMap - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/container_track.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/container_track.html deleted file mode 100644 index cdad43bef5c..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/container_track.html +++ /dev/null @@ -1,132 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/task.html"> -<link rel="import" href="/tracing/ui/tracks/track.html"> -<link rel="import" href="/tracing/core/filter.html"> -<link rel="import" href="/tracing/ui/base/ui.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.tracks', function() { - var Task = tr.b.Task; - - /** - * A generic track that contains other tracks as its children. - * @constructor - */ - var ContainerTrack = tr.ui.b.define('container-track', tr.ui.tracks.Track); - ContainerTrack.prototype = { - __proto__: tr.ui.tracks.Track.prototype, - - decorate: function(viewport) { - tr.ui.tracks.Track.prototype.decorate.call(this, viewport); - }, - - detach: function() { - this.textContent = ''; - }, - - get tracks_() { - var tracks = []; - for (var i = 0; i < this.children.length; i++) { - if (this.children[i] instanceof tr.ui.tracks.Track) - tracks.push(this.children[i]); - } - return tracks; - }, - - drawTrack: function(type) { - this.tracks_.forEach(function(track) { - track.drawTrack(type); - }); - }, - - /** - * Adds items intersecting the given range to a selection. - * @param {number} loVX Lower X bound of the interval to search, in - * viewspace. - * @param {number} hiVX Upper X bound of the interval to search, in - * viewspace. - * @param {number} loY Lower Y bound of the interval to search, in - * viewspace space. - * @param {number} hiY Upper Y bound of the interval to search, in - * viewspace space. - * @param {Selection} selection Selection to which to add results. - */ - addIntersectingEventsInRangeToSelection: function( - loVX, hiVX, loY, hiY, selection) { - for (var i = 0; i < this.tracks_.length; i++) { - var trackClientRect = this.tracks_[i].getBoundingClientRect(); - var a = Math.max(loY, trackClientRect.top); - var b = Math.min(hiY, trackClientRect.bottom); - if (a <= b) - this.tracks_[i].addIntersectingEventsInRangeToSelection( - loVX, hiVX, loY, hiY, selection); - } - - tr.ui.tracks.Track.prototype.addIntersectingEventsInRangeToSelection. - apply(this, arguments); - }, - - addEventsToTrackMap: function(eventToTrackMap) { - for (var i = 0; i < this.children.length; ++i) - this.children[i].addEventsToTrackMap(eventToTrackMap); - }, - - addAllEventsMatchingFilterToSelection: function(filter, selection) { - for (var i = 0; i < this.tracks_.length; i++) - this.tracks_[i].addAllEventsMatchingFilterToSelection( - filter, selection); - }, - - addAllEventsMatchingFilterToSelectionAsTask: function(filter, selection) { - var task = new Task(); - for (var i = 0; i < this.tracks_.length; i++) { - task.subTask(function(i) { return function() { - this.tracks_[i].addAllEventsMatchingFilterToSelection( - filter, selection); - } }(i), this); - } - return task; - }, - - addClosestEventToSelection: function( - worldX, worldMaxDist, loY, hiY, selection) { - for (var i = 0; i < this.tracks_.length; i++) { - var trackClientRect = this.tracks_[i].getBoundingClientRect(); - var a = Math.max(loY, trackClientRect.top); - var b = Math.min(hiY, trackClientRect.bottom); - if (a <= b) { - this.tracks_[i].addClosestEventToSelection( - worldX, worldMaxDist, loY, hiY, selection); - } - } - - tr.ui.tracks.Track.prototype.addClosestEventToSelection. - apply(this, arguments); - }, - - addContainersToTrackMap: function(containerToTrackMap) { - this.tracks_.forEach(function(track) { - track.addContainersToTrackMap(containerToTrackMap); - }); - }, - - clearTracks_: function() { - this.tracks_.forEach(function(track) { - this.removeChild(track); - }, this); - } - }; - - return { - ContainerTrack: ContainerTrack - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/counter_track.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/counter_track.html deleted file mode 100644 index 759b2433596..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/counter_track.html +++ /dev/null @@ -1,80 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/tracks/chart_axis.html"> -<link rel="import" href="/tracing/ui/tracks/chart_point.html"> -<link rel="import" href="/tracing/ui/tracks/chart_series.html"> -<link rel="import" href="/tracing/ui/tracks/chart_track.html"> -<link rel="import" href="/tracing/ui/base/ui.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.tracks', function() { - - /** - * A track that displays a Counter object. - * @constructor - * @extends {ChartTrack} - */ - var CounterTrack = tr.ui.b.define('counter-track', tr.ui.tracks.ChartTrack); - - CounterTrack.prototype = { - __proto__: tr.ui.tracks.ChartTrack.prototype, - - decorate: function(viewport) { - tr.ui.tracks.ChartTrack.prototype.decorate.call(this, viewport); - this.classList.add('counter-track'); - }, - - get counter() { - return this.chart; - }, - - set counter(counter) { - this.heading = counter.name + ': '; - this.series = CounterTrack.buildChartSeriesFromCounter(counter); - this.autoSetAllAxes({expandMax: true}); - }, - - getModelEventFromItem: function(chartValue) { - return chartValue; - } - }; - - CounterTrack.buildChartSeriesFromCounter = function(counter) { - var numSeries = counter.series.length; - var totals = counter.totals; - - // Create one common axis for all series. - var chartAxis = new tr.ui.tracks.ChartAxis(0, undefined); - - // Build one chart series for each counter series. - var chartSeries = counter.series.map(function(series, seriesIndex) { - var chartPoints = series.samples.map(function(sample, sampleIndex) { - var total = totals[sampleIndex * numSeries + seriesIndex]; - return new tr.ui.tracks.ChartPoint(sample, sample.timestamp, total); - }); - var renderingConfig = { - chartType: tr.ui.tracks.ChartSeriesType.AREA, - colorId: series.color - }; - return new tr.ui.tracks.ChartSeries( - chartPoints, chartAxis, renderingConfig); - }); - - // Show the first series (with the smallest cumulative value) at the top. - chartSeries.reverse(); - - return chartSeries; - }; - - return { - CounterTrack: CounterTrack - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/counter_track_perf_test.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/counter_track_perf_test.html deleted file mode 100644 index afa3ad3f967..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/counter_track_perf_test.html +++ /dev/null @@ -1,129 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/ui/extras/full_config.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - function getSynchronous(url) { - var req = new XMLHttpRequest(); - req.open('GET', url, false); - // Without the mime type specified like this, the file's bytes are not - // retrieved correctly. - req.overrideMimeType('text/plain; charset=x-user-defined'); - req.send(null); - return req.responseText; - } - - var ZOOM_STEPS = 10; - var ZOOM_COEFFICIENT = 1.2; - - var model = undefined; - - var drawingContainer; - var viewportDiv; - - var viewportWidth; - var worldMid; - - var startScale = undefined; - - function timedCounterTrackPerfTest(name, testFn, iterations) { - - function setUpOnce() { - if (model !== undefined) - return; - var fileUrl = '/test_data/counter_tracks.html'; - var events = getSynchronous(fileUrl); - model = tr.c.TestUtils.newModelWithEvents([events]); - } - - function setUp() { - setUpOnce(); - viewportDiv = document.createElement('div'); - - var viewport = new tr.ui.TimelineViewport(viewportDiv); - - drawingContainer = new tr.ui.tracks.DrawingContainer(viewport); - viewport.modelTrackContainer = drawingContainer; - - var modelTrack = new tr.ui.tracks.ModelTrack(viewport); - drawingContainer.appendChild(modelTrack); - - modelTrack.model = model; - - viewportDiv.appendChild(drawingContainer); - - this.addHTMLOutput(viewportDiv); - - // Size the canvas. - drawingContainer.updateCanvasSizeIfNeeded_(); - - // Size the viewport. - viewportWidth = drawingContainer.canvas.width; - var min = model.bounds.min; - var range = model.bounds.range; - worldMid = min + range / 2; - - var boost = range * 0.15; - var dt = new tr.ui.TimelineDisplayTransform(); - dt.xSetWorldBounds(min - boost, min + range + boost, viewportWidth); - modelTrack.viewport.setDisplayTransformImmediately(dt); - startScale = dt.scaleX; - - // Select half of the counter samples. - for (var pid in model.processes) { - var counters = model.processes[pid].counters; - for (var cid in counters) { - var series = counters[cid].series; - for (var i = 0; i < series.length; i++) { - var samples = series[i].samples; - for (var j = Math.floor(samples.length / 2); j < samples.length; - j++) { - samples[j].selectionState = - tr.model.SelectionState.SELECTED; - } - } - } - } - }; - - function tearDown() { - viewportDiv.innerText = ''; - drawingContainer = undefined; - } - - timedPerfTest(name, testFn, { - setUp: setUp, - tearDown: tearDown, - iterations: iterations - }); - } - - var n110100 = [1, 10, 100]; - n110100.forEach(function(val) { - timedCounterTrackPerfTest( - 'draw_softwareCanvas_' + val, - function() { - var scale = startScale; - for (var i = 0; i < ZOOM_STEPS; i++) { - var dt = drawingContainer.viewport.currentDisplayTransform.clone(); - scale *= ZOOM_COEFFICIENT; - dt.scaleX = scale; - dt.xPanWorldPosToViewPos(worldMid, 'center', viewportWidth); - drawingContainer.viewport.setDisplayTransformImmediately(dt); - drawingContainer.draw_(); - } - }, val); - }); -}); -</script> - diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/counter_track_test.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/counter_track_test.html deleted file mode 100644 index 8cf6dcdfa00..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/counter_track_test.html +++ /dev/null @@ -1,201 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/iteration_helpers.html"> -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/ui/timeline_track_view.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var ColorScheme = tr.b.ColorScheme; - var Counter = tr.model.Counter; - var Viewport = tr.ui.TimelineViewport; - var CounterTrack = tr.ui.tracks.CounterTrack; - - var runTest = function(timestamps, samples, testFn) { - var testEl = document.createElement('div'); - - var ctr = new Counter(undefined, 'foo', '', 'foo'); - var n = samples.length; - - for (var i = 0; i < n; ++i) { - ctr.addSeries(new tr.model.CounterSeries('value' + i, - ColorScheme.getColorIdForGeneralPurposeString('value' + i))); - } - - for (var i = 0; i < samples.length; ++i) { - for (var k = 0; k < timestamps.length; ++k) { - ctr.series[i].addCounterSample(timestamps[k], samples[i][k]); - } - } - - ctr.updateBounds(); - - var viewport = new Viewport(testEl); - - var drawingContainer = new tr.ui.tracks.DrawingContainer(viewport); - testEl.appendChild(drawingContainer); - - var track = new CounterTrack(viewport); - drawingContainer.appendChild(track); - this.addHTMLOutput(testEl); - - // Force the container to update sizes so the test can use coordinates that - // make sense. This has to be after the adding of the track as we need to - // use the track header to figure out our positioning. - drawingContainer.updateCanvasSizeIfNeeded_(); - - var pixelRatio = window.devicePixelRatio || 1; - - track.heading = ctr.name; - track.counter = ctr; - var dt = new tr.ui.TimelineDisplayTransform(); - dt.xSetWorldBounds(0, 10, track.clientWidth * pixelRatio); - track.viewport.setDisplayTransformImmediately(dt); - - testFn(ctr, drawingContainer, track); - }; - - test('instantiate', function() { - var ctr = new Counter(undefined, 'testBasicCounter', '', - 'testBasicCounter'); - ctr.addSeries(new tr.model.CounterSeries('value1', - ColorScheme.getColorIdForGeneralPurposeString( - 'testBasicCounter.value1'))); - ctr.addSeries(new tr.model.CounterSeries('value2', - ColorScheme.getColorIdForGeneralPurposeString( - 'testBasicCounter.value2'))); - - var timestamps = [0, 1, 2, 3, 4, 5, 6, 7]; - var samples = [[0, 3, 1, 2, 3, 1, 3, 3.1], - [5, 3, 1, 1.1, 0, 7, 0, 0.5]]; - for (var i = 0; i < samples.length; ++i) { - for (var k = 0; k < timestamps.length; ++k) { - ctr.series[i].addCounterSample(timestamps[k], samples[i][k]); - } - } - - ctr.updateBounds(); - - var div = document.createElement('div'); - var viewport = new Viewport(div); - - var drawingContainer = new tr.ui.tracks.DrawingContainer(viewport); - div.appendChild(drawingContainer); - - var track = new CounterTrack(viewport); - drawingContainer.appendChild(track); - - this.addHTMLOutput(div); - drawingContainer.invalidate(); - - track.heading = ctr.name; - track.counter = ctr; - var dt = new tr.ui.TimelineDisplayTransform(); - dt.xSetWorldBounds(0, 7.7, track.clientWidth); - track.viewport.setDisplayTransformImmediately(dt); - }); - - test('basicCounterXPointPicking', function() { - var timestamps = [0, 1, 2, 3, 4, 5, 6, 7]; - var samples = [[0, 3, 1, 2, 3, 1, 3, 3.1], - [5, 3, 1, 1.1, 0, 7, 0, 0.5]]; - - runTest.call(this, timestamps, samples, function(ctr, container, track) { - var clientRect = track.getBoundingClientRect(); - var y75 = clientRect.top + (0.75 * clientRect.height); - - // In bounds. - var sel = new tr.model.EventSet(); - var x = 0.15 * clientRect.width; - track.addIntersectingEventsInRangeToSelection( - x, x + 1, y75, y75 + 1, sel); - - var nextSeriesIndex = 1; - assert.equal(sel.length, 2); - for (var event of sel) { - assert.equal(event.series.counter, ctr); - assert.equal(event.getSampleIndex(), 1); - assert.equal(event.series.seriesIndex, nextSeriesIndex--); - } - - // Outside bounds. - sel = new tr.model.EventSet(); - var x = -0.5 * clientRect.width; - track.addIntersectingEventsInRangeToSelection( - x, x + 1, y75, y75 + 1, sel); - assert.equal(sel.length, 0); - - sel = new tr.model.EventSet(); - var x = 0.8 * clientRect.width; - track.addIntersectingEventsInRangeToSelection( - x, x + 1, y75, y75 + 1, sel); - assert.equal(sel.length, 0); - }); - }); - - test('counterTrackAddClosestEventToSelection', function() { - var timestamps = [0, 1, 2, 3, 4, 5, 6, 7]; - var samples = [[0, 4, 1, 2, 3, 1, 3, 3.1], - [5, 3, 1, 1.1, 0, 7, 0, 0.5]]; - - runTest.call(this, timestamps, samples, function(ctr, container, track) { - // Before with not range. - var sel = new tr.model.EventSet(); - track.addClosestEventToSelection(-1, 0, 0, 0, sel); - assert.equal(sel.length, 0); - - // Before with negative range. - var sel = new tr.model.EventSet(); - track.addClosestEventToSelection(-1, -10, 0, 0, sel); - assert.equal(sel.length, 0); - - // Before first sample. - var sel = new tr.model.EventSet(); - track.addClosestEventToSelection(-1, 1, 0, 0, sel); - assert.equal(sel.length, 2); - for (var event of sel) - assert.equal(event.getSampleIndex(), 0); - - // Between and closer to sample before. - var sel = new tr.model.EventSet(); - track.addClosestEventToSelection(1.3, 1, 0, 0, sel); - assert.equal(sel.length, 2); - for (var event of sel) - assert.equal(event.getSampleIndex(), 1); - - // Between samples with bad range. - var sel = new tr.model.EventSet(); - track.addClosestEventToSelection(1.45, 0.25, 0, 0, sel); - assert.equal(sel.length, 0); - - // Between and closer to next sample. - var sel = new tr.model.EventSet(); - track.addClosestEventToSelection(4.7, 6, 0, 0, sel); - assert.equal(sel.length, 2); - for (var event of sel) - assert.equal(event.getSampleIndex(), 5); - - // After last sample with good range. - var sel = new tr.model.EventSet(); - track.addClosestEventToSelection(8.5, 2, 0, 0, sel); - assert.equal(sel.length, 2); - for (var event of sel) - assert.equal(event.getSampleIndex(), 7); - - // After last sample with bad range. - var sel = new tr.model.EventSet(); - track.addClosestEventToSelection(10, 1, 0, 0, sel); - assert.equal(sel.length, 0); - }); - }); -}); -</script> - diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/cpu_track.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/cpu_track.html deleted file mode 100644 index 84b7afe6582..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/cpu_track.html +++ /dev/null @@ -1,139 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/filter.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/ui/base/ui.html"> -<link rel="import" href="/tracing/ui/tracks/container_track.html"> -<link rel="import" href="/tracing/ui/tracks/slice_track.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.tracks', function() { - - /** - * Visualizes a Cpu using a series of SliceTracks. - * @constructor - */ - var CpuTrack = - tr.ui.b.define('cpu-track', tr.ui.tracks.ContainerTrack); - CpuTrack.prototype = { - __proto__: tr.ui.tracks.ContainerTrack.prototype, - - decorate: function(viewport) { - tr.ui.tracks.ContainerTrack.prototype.decorate.call(this, viewport); - this.classList.add('cpu-track'); - this.detailedMode_ = true; - }, - - get cpu() { - return this.cpu_; - }, - - set cpu(cpu) { - this.cpu_ = cpu; - this.updateContents_(); - }, - - get detailedMode() { - return this.detailedMode_; - }, - - set detailedMode(detailedMode) { - this.detailedMode_ = detailedMode; - this.updateContents_(); - }, - - get tooltip() { - return this.tooltip_; - }, - - set tooltip(value) { - this.tooltip_ = value; - this.updateContents_(); - }, - - get hasVisibleContent() { - if (this.cpu_ === undefined) - return false; - var cpu = this.cpu_; - if (cpu.slices.length) - return true; - if (cpu.samples && cpu.samples.length) - return true; - if (tr.b.dictionaryLength(cpu.counters) > 0) - return true; - return false; - }, - - updateContents_: function() { - this.detach(); - if (!this.cpu_) - return; - var slices = this.cpu_.slices; - if (slices.length) { - var track = new tr.ui.tracks.SliceTrack(this.viewport); - track.slices = slices; - track.heading = this.cpu_.userFriendlyName + ':'; - this.appendChild(track); - } - - if (this.detailedMode_) { - this.appendSamplesTracks_(); - - for (var counterName in this.cpu_.counters) { - var counter = this.cpu_.counters[counterName]; - track = new tr.ui.tracks.CounterTrack(this.viewport); - track.heading = this.cpu_.userFriendlyName + ' ' + - counter.name + ':'; - track.counter = counter; - this.appendChild(track); - } - } - }, - - appendSamplesTracks_: function() { - var samples = this.cpu_.samples; - if (samples === undefined || samples.length === 0) - return; - var samplesByTitle = {}; - samples.forEach(function(sample) { - if (samplesByTitle[sample.title] === undefined) - samplesByTitle[sample.title] = []; - samplesByTitle[sample.title].push(sample); - }); - - var sampleTitles = tr.b.dictionaryKeys(samplesByTitle); - sampleTitles.sort(); - - sampleTitles.forEach(function(sampleTitle) { - var samples = samplesByTitle[sampleTitle]; - var samplesTrack = new tr.ui.tracks.SliceTrack(this.viewport); - samplesTrack.group = this.cpu_; - samplesTrack.slices = samples; - samplesTrack.heading = this.cpu_.userFriendlyName + ': ' + - sampleTitle; - samplesTrack.tooltip = this.cpu_.userFriendlyDetails; - samplesTrack.selectionGenerator = function() { - var selection = new tr.model.EventSet(); - for (var i = 0; i < samplesTrack.slices.length; i++) { - selection.push(samplesTrack.slices[i]); - } - return selection; - }; - this.appendChild(samplesTrack); - }, this); - } - }; - - return { - CpuTrack: CpuTrack - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/cpu_track_test.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/cpu_track_test.html deleted file mode 100644 index 61108d514fc..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/cpu_track_test.html +++ /dev/null @@ -1,99 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/ui/timeline_track_view.html"> -<link rel="import" href="/tracing/model/model.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var Cpu = tr.model.Cpu; - var CpuTrack = tr.ui.tracks.CpuTrack; - var Slice = tr.model.Slice; - var StackFrame = tr.model.StackFrame; - var Sample = tr.model.Sample; - var Thread = tr.model.Thread; - var Viewport = tr.ui.TimelineViewport; - - test('basicCpu', function() { - var cpu = new Cpu({}, 7); - cpu.slices = [ - new Slice('', 'a', 0, 1, {}, 1), - new Slice('', 'b', 1, 2.1, {}, 4.8) - ]; - cpu.updateBounds(); - - var testEl = document.createElement('div'); - var viewport = new Viewport(testEl); - - var drawingContainer = new tr.ui.tracks.DrawingContainer(viewport); - - var track = new CpuTrack(viewport); - drawingContainer.appendChild(track); - - track.heading = 'CPU ' + cpu.cpuNumber; - track.cpu = cpu; - var dt = new tr.ui.TimelineDisplayTransform(); - dt.xSetWorldBounds(0, 11.1, track.clientWidth); - track.viewport.setDisplayTransformImmediately(dt); - }); - - - test('withSamples', function() { - var thread; - var cpu; - var model = tr.c.TestUtils.newModelWithEvents([], { - shiftWorldToZero: false, - pruneContainers: false, - customizeModelCallback: function(model) { - cpu = model.kernel.getOrCreateCpu(1); - thread = model.getOrCreateProcess(1).getOrCreateThread(2); - - var fA = model.addStackFrame(new StackFrame( - undefined, 1, 'cat', 'a', 7)); - var fAB = model.addStackFrame(new StackFrame( - fA, 2, 'cat', 'b', 7)); - var fABC = model.addStackFrame(new StackFrame( - fAB, 3, 'cat', 'c', 7)); - var fAD = model.addStackFrame(new StackFrame( - fA, 4, 'cat', 'd', 7)); - - model.samples.push(new Sample(undefined, thread, 'instructions_retired', - 10, fABC, 10)); - model.samples.push(new Sample(undefined, thread, 'instructions_retired', - 20, fAB, 10)); - model.samples.push(new Sample(undefined, thread, 'instructions_retired', - 30, fAB, 10)); - model.samples.push(new Sample(undefined, thread, 'instructions_retired', - 40, fAD, 10)); - - model.samples.push(new Sample(undefined, thread, 'page_fault', - 25, fAB, 10)); - model.samples.push(new Sample(undefined, thread, 'page_fault', - 35, fAD, 10)); - } - }); - - var testEl = document.createElement('div'); - var viewport = new Viewport(testEl); - - var drawingContainer = new tr.ui.tracks.DrawingContainer(viewport); - - var track = new CpuTrack(viewport); - drawingContainer.appendChild(track); - - track.heading = 'CPU ' + cpu.cpuNumber; - track.cpu = cpu; - var dt = new tr.ui.TimelineDisplayTransform(); - dt.xSetWorldBounds(0, 11.1, track.clientWidth); - track.viewport.setDisplayTransformImmediately(dt); - }); -}); -</script> - diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/cpu_usage_track.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/cpu_usage_track.html deleted file mode 100644 index 5845b546984..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/cpu_usage_track.html +++ /dev/null @@ -1,187 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright 2016 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/color_scheme.html"> -<link rel="import" href="/tracing/ui/base/ui.html"> -<link rel="import" href="/tracing/ui/tracks/chart_axis.html"> -<link rel="import" href="/tracing/ui/tracks/chart_point.html"> -<link rel="import" href="/tracing/ui/tracks/chart_series.html"> -<link rel="import" href="/tracing/ui/tracks/chart_track.html"> - -<style> -.cpu-usage-track { - height: 90px; -} -</style> - -<script> -'use strict'; - -tr.exportTo('tr.ui.tracks', function() { - - var ColorScheme = tr.b.ColorScheme; - var ChartTrack = tr.ui.tracks.ChartTrack; - var MAX_CPU_TRACK_INTERVAL_COUNT = 100000; - - /** - * A track that displays the cpu usage of a process. - * - * @constructor - * @extends {tr.ui.tracks.ChartTrack} - */ - var CpuUsageTrack = tr.ui.b.define('cpu-usage-track', ChartTrack); - - CpuUsageTrack.prototype = { - __proto__: ChartTrack.prototype, - - DEFAULT_INTERVAL: 5, // in ms. - - decorate: function(viewport) { - ChartTrack.prototype.decorate.call(this, viewport); - this.classList.add('cpu-usage-track'); - this.heading = 'CPU usage'; - this.cpuUsageSeries_ = undefined; - }, - - // Given a tr.Model, it creates a cpu usage series and a graph. - initialize: function(model, interval) { - if (interval !== undefined) - this.interval_ = interval; - else - this.interval_ = this.DEFAULT_INTERVAL; - if (model !== undefined) - this.cpuUsageSeries_ = this.computeCpuUsage_(model); - else - this.cpuUsageSeries_ = undefined; - this.series = this.buildChartSeries_(); - this.autoSetAllAxes({expandMax: true}); - }, - - // Given a tr.Model, it returns the computation of cpu usage of all the - // processes. - computeCpuUsage_: function(model) { - var intervalCount = Math.ceil(model.bounds.max / this.interval_); - // Rather than attempting a huge allocation and having the tab crash with - // an out-of-memory error, throw an error here if there are too many - // CPU intervals to handle. - if (intervalCount > MAX_CPU_TRACK_INTERVAL_COUNT) { - throw new Error('The trace is too long or the CPU usage counter ' + - 'interval is too small, leading to too many CPU usage intervals.'); - } - var cpuUsage = undefined; - if (intervalCount > 0) { - tr.b.iterItems(model.processes, function(pid, process) { - // Iterate slices, find all the CPU samples which overlap. For each - // such CPU sample, increment it of the "average CPU usage" of the - // slice. - for (var e of process.getDescendantEvents()) { - if (!(e instanceof tr.model.ThreadSlice) || e.duration === 0 || - e.cpuDuration === undefined) { - continue; - } - - // This slice contains the most fine-grained CPU usage information - // for the area of the trace that it covers but that is not covered - // by its subslices. - // The math goes this way: - // s.selfTime : duration of slice s not spent in its subslices. - // s.cpuSelfTime : cpuDuration over slice s but not its subslices. - // - // We're looking for - // s.cpuSelfTimeRatio: average cpu usage over the area covered by - // s but not any of its subslices. - // = s.cpuSelfTime / s.selfTime - if (e.selfTime === 0 || e.selfTime === undefined || - e.cpuSelfTime === undefined) { - continue; - } - - var cpuSelfTimeRatio = e.cpuSelfTime / e.selfTime; - cpuSelfTimeRatio = Math.max(0, cpuSelfTimeRatio); - cpuSelfTimeRatio = Math.min(1, cpuSelfTimeRatio); - // We have found at least one valid thread slice. - if (cpuUsage === undefined) - cpuUsage = new Array(intervalCount).fill(0); - - // Go through the area covered by this slice but not its subslices - // and add the cpuSelfTimeRatio contribution over this area. - var lastTime = e.start; - e.subSlices.forEach(function(slice) { - this.addCPUUsageOverInterval_(cpuUsage, cpuSelfTimeRatio, - lastTime, slice.start); - lastTime = slice.end; - }, this); - this.addCPUUsageOverInterval_(cpuUsage, cpuSelfTimeRatio, lastTime, - e.end); - } - }, this); - } - return cpuUsage || []; - }, - - addCPUUsageOverInterval_: function(cpuUsageArray, cpuUsage, start, end) { - if (start >= end) - return; - - // Simple arithmetic to find the indexes that overlap the current - // slice. - var interval = this.interval_; - var startIndex = Math.floor(start / interval); - // If the slice stops on an interval, endIndex will be too high. - // E.g.: start = 5, end = 10, endIndex = floor( 10 / 5 ) = 2. - // However, the slice is active for only one interval : [5, 10[ . - var endIndex = Math.ceil(end / interval) - 1; - var cpuUsagePerTime = cpuUsage / interval; - - // Add [startIndex * interval, endIndex * interval] duration. - for (var i = startIndex; i < endIndex; i++) - cpuUsageArray[i] += cpuUsage; - - // Subtract [startIndex * interval, start] duration. - cpuUsageArray[startIndex] -= cpuUsagePerTime * - (start - startIndex * interval); - - // Add [endIndex * interval, end] duration. - cpuUsageArray[endIndex] += cpuUsagePerTime * (end - endIndex * interval); - }, - - get hasVisibleContent() { - return !!this.cpuUsageSeries_ && this.cpuUsageSeries_.length > 0; - }, - - addContainersToTrackMap: function(containerToTrackMap) { - containerToTrackMap.addContainer(this.series_, this); - }, - - buildChartSeries_: function() { - if (!this.hasVisibleContent) - return []; - - var axis = new tr.ui.tracks.ChartAxis(0, undefined); - var pts = new Array(this.cpuUsageSeries_.length + 1); - - // Add all points and an extra one at the end, otherwise the last - // interval doesn't show up. - for (var i = 0; i <= this.cpuUsageSeries_.length; i++) { - pts[i] = new tr.ui.tracks.ChartPoint(undefined, this.interval_ * i, - this.cpuUsageSeries_[i] || 0); - } - - var renderingConfig = { - chartType: tr.ui.tracks.ChartSeriesType.AREA, - colorId: ColorScheme.getColorIdForGeneralPurposeString(this.heading) - }; - - return [new tr.ui.tracks.ChartSeries(pts, axis, renderingConfig)]; - } - }; - - return { - CpuUsageTrack: CpuUsageTrack - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/cpu_usage_track_test.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/cpu_usage_track_test.html deleted file mode 100644 index 0ef7005dcae..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/cpu_usage_track_test.html +++ /dev/null @@ -1,240 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright 2016 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/model/thread_slice.html"> -<link rel='import' href='/tracing/ui/base/constants.html'> -<link rel='import' href='/tracing/ui/timeline_viewport.html'> -<link rel="import" href="/tracing/ui/tracks/cpu_usage_track.html"> -<link rel='import' href='/tracing/ui/tracks/drawing_container.html'> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var Model = tr.Model; - var ThreadSlice = tr.model.ThreadSlice; - var DIFF_EPSILON = 0.0001; - - // Input : slices is an array-of-array-of slices. Each top level array - // represents a process. So, each slice in one of the top level array - // will be placed in the same process. - function buildModel(slices) { - var model = tr.c.TestUtils.newModel(function(model) { - var process = model.getOrCreateProcess(1); - for (var i = 0; i < slices.length; i++) { - var thread = process.getOrCreateThread(i); - slices[i].forEach(s => thread.sliceGroup.pushSlice(s)); - } - }); - return model; - } - - // Compare float arrays based on an epsilon since floating point arithmetic - // is not always 100% accurate. - function assertArrayValuesCloseTo(actualValue, expectedValue) { - assert.lengthOf(actualValue, expectedValue.length); - for (var i = 0; i < expectedValue.length; i++) - assert.closeTo(actualValue[i], expectedValue[i], DIFF_EPSILON); - } - - function createCpuUsageTrack(model, interval) { - var div = document.createElement('div'); - var viewport = new tr.ui.TimelineViewport(div); - var drawingContainer = new tr.ui.tracks.DrawingContainer(viewport); - div.appendChild(drawingContainer); - var track = new tr.ui.tracks.CpuUsageTrack(drawingContainer.viewport); - if (model !== undefined) - setDisplayTransformFromBounds(viewport, model.bounds); - track.initialize(model, interval); - drawingContainer.appendChild(track); - this.addHTMLOutput(drawingContainer); - return track; - } - - /** - * Sets the mapping between the input range of timestamps and the output range - * of horizontal pixels. - */ - function setDisplayTransformFromBounds(viewport, bounds) { - var dt = new tr.ui.TimelineDisplayTransform(); - var pixelRatio = window.devicePixelRatio || 1; - var chartPixelWidth = - (window.innerWidth - tr.ui.b.constants.HEADING_WIDTH) * pixelRatio; - dt.xSetWorldBounds(bounds.min, bounds.max, chartPixelWidth); - viewport.setDisplayTransformImmediately(dt); - }; - - test('computeCpuUsage_simpleOnBoundaries', function() { - // First thread. - // 0 5 10 15 20 25 30 35 40 45 50 55 - // [ sliceA ] - // [ sliceB ] [C] - var sliceA = new tr.model.ThreadSlice('', title, 0, 5, {}, 50); - sliceA.cpuDuration = 25; - var sliceB = new tr.model.ThreadSlice('', title, 0, 10, {}, 30); - sliceB.cpuDuration = 15; - // The slice completely fits into an interval and is the last. - var sliceC = new tr.model.ThreadSlice('', title, 0, 52, {}, 3); - sliceC.cpuDuration = 3; - - // Second thread. - // 0 5 10 15 20 25 30 35 40 45 50 55 - // [ sliceE ][ sliceD ] - var sliceD = new tr.model.ThreadSlice('', title, 0, 15, {}, 20); - sliceD.cpuDuration = 17; - var sliceE = new tr.model.ThreadSlice('', title, 0, 5, {}, 10); - sliceE.cpuDuration = 9; - - var model = buildModel([[sliceA, sliceB, sliceC], [sliceD, sliceE]]); - - // Compute average CPU usage over A (but not over B and C). - var avgCpuUsageA = sliceA.cpuSelfTime / sliceA.selfTime; - // Compute average CPU usage over B, C, D, E. They don't have subslices. - var avgCpuUsageB = sliceB.cpuDuration / sliceB.duration; - var avgCpuUsageC = sliceC.cpuDuration / sliceC.duration; - var avgCpuUsageD = sliceD.cpuDuration / sliceD.duration; - var avgCpuUsageE = sliceE.cpuDuration / sliceE.duration; - - var expectedValue = [ - 0, - avgCpuUsageA + avgCpuUsageE, - avgCpuUsageB + avgCpuUsageE, - avgCpuUsageB + avgCpuUsageD, - avgCpuUsageB + avgCpuUsageD, - avgCpuUsageB + avgCpuUsageD, - avgCpuUsageB + avgCpuUsageD, - avgCpuUsageB, - avgCpuUsageA, - avgCpuUsageA, - avgCpuUsageA * 2.0 / 5 + avgCpuUsageC * 3.0 / 5.0, - 0 // Extra point added to make the last interval show up. - ]; - var track = createCpuUsageTrack.call(this, model, 5); - var actualValue = track.series[0].points.map(point => point.y); - assertArrayValuesCloseTo(actualValue, expectedValue); - }); - - test('computeCpuUsage_tooManyIntervals', function() { - var sliceA = new tr.model.ThreadSlice('', title, 0, 5, {}, 50); - sliceA.cpuDuration = 25; - var sliceB = new tr.model.ThreadSlice( - '', title, 0, 50000010, {}, 50000030); - sliceB.cpuDuration = 15; - - var model = buildModel([[sliceA, sliceB]]); - - assert.throws(() => createCpuUsageTrack.call(this, model, 5)); - }); - - test('computeCpuUsage_floatAndComplexIntervals', function() { - // First thread. - // 0 5 10 15 20 25 30 35 40 45 50 55 - // [ sliceA ] - // [B] - var sliceA = new tr.model.ThreadSlice('', title, 0, 5.5111, {}, 47.1023); - sliceA.cpuDuration = 25; - var sliceB = new tr.model.ThreadSlice('', title, 0, 11.2384, {}, 1.8769); - sliceB.cpuDuration = 1.5; - - // Second thread. - // 0 5 10 15 20 25 30 35 40 45 50 55 - // [ C ] [ D ] - var sliceC = new tr.model.ThreadSlice('', title, 0, 11.239, {}, 5.8769); - sliceC.cpuDuration = 5; - var sliceD = new tr.model.ThreadSlice('', title, 0, 48.012, {}, 5.01); - sliceD.cpuDuration = 4; - - var model = buildModel([[sliceA, sliceB], [sliceC, sliceD]]); - - // Compute average CPU usage over A (but not over B and C). - var avgCpuUsageA = sliceA.cpuSelfTime / sliceA.selfTime; - // Compute average CPU usage over B, C, D. They don't have subslices. - var avgCpuUsageB = sliceB.cpuDuration / sliceB.duration; - var avgCpuUsageC = sliceC.cpuDuration / sliceC.duration; - var avgCpuUsageD = sliceD.cpuDuration / sliceD.duration; - - var expectedValue = [ - 0, - avgCpuUsageA * (10 - 5.5111) / 5.0, - avgCpuUsageA * (11.2384 - 10 + 15 - (11.2384 + 1.8769)) / 5.0 + - avgCpuUsageB * 1.8769 / 5.0 + - avgCpuUsageC * (15 - 11.239) / 5.0, - avgCpuUsageA + - avgCpuUsageC * ((11.239 + 5.8769) - 15) / 5.0, - avgCpuUsageA, - avgCpuUsageA, - avgCpuUsageA, - avgCpuUsageA, - avgCpuUsageA, - avgCpuUsageA + - avgCpuUsageD * (50 - 48.012) / 5.0, - avgCpuUsageA * (5.5111 + 47.1023 - 50) / 5.0 + - avgCpuUsageD * (48.012 + 5.01 - 50) / 5.0, - 0 // Extra point added to make the last interval show up. - ]; - var track = createCpuUsageTrack.call(this, model, 5); - var actualValue = track.series[0].points.map(point => point.y); - assertArrayValuesCloseTo(actualValue, expectedValue); - }); - - test('instantiate', function() { - var sliceA = new tr.model.ThreadSlice('', title, 0, 5.5111, {}, 47.1023); - sliceA.cpuDuration = 25; - var sliceB = new tr.model.ThreadSlice('', title, 0, 11.2384, {}, 1.8769); - sliceB.cpuDuration = 1.5; - var sliceC = new tr.model.ThreadSlice('', title, 0, 11.239, {}, 5.8769); - sliceC.cpuDuration = 5; - var sliceD = new tr.model.ThreadSlice('', title, 0, 48.012, {}, 5.01); - sliceD.cpuDuration = 4; - - var model = buildModel([[sliceA, sliceB, sliceC, sliceD]]); - createCpuUsageTrack.call(this, model); - }); - - test('hasVisibleContent_trueWithThreadSlicePresent', function() { - var sliceA = new tr.model.ThreadSlice('', title, 0, 48.012, {}, 5.01); - sliceA.cpuDuration = 4; - var model = buildModel([[sliceA]]); - var track = createCpuUsageTrack.call(this, model); - - assert.isTrue(track.hasVisibleContent); - }); - - test('hasVisibleContent_falseWithUndefinedProcessModel', function() { - var track = createCpuUsageTrack.call(this, undefined); - - assert.isFalse(track.hasVisibleContent); - }); - - test('hasVisibleContent_falseWithNoThreadSlice', function() { - // model with a CPU and a thread but no ThreadSlice. - var model = buildModel([]); - var track = createCpuUsageTrack.call(this, model); - - assert.isFalse(track.hasVisibleContent); - }); - - test('hasVisibleContent_trueWithSubSlices', function() { - var sliceA = new tr.model.ThreadSlice('', title, 0, 5.5111, {}, 47.1023); - sliceA.cpuDuration = 25; - var sliceB = new tr.model.ThreadSlice('', title, 0, 11.2384, {}, 1.8769); - sliceB.cpuDuration = 1.5; - - var model = buildModel([[sliceA, sliceB]]); - var process = model.getProcess(1); - // B will become lowest level slices of A. - process.getThread(0).sliceGroup.createSubSlices(); - assert.equal(sliceA.cpuSelfTime, (sliceA.cpuDuration - sliceB.cpuDuration)); - var track = createCpuUsageTrack.call(this, model); - - assert.isTrue(track.hasVisibleContent); - }); - -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/device_track.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/device_track.html deleted file mode 100644 index dfc6c364eea..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/device_track.html +++ /dev/null @@ -1,90 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/tracks/container_track.html"> -<link rel="import" href="/tracing/ui/tracks/power_series_track.html"> -<link rel="import" href="/tracing/ui/tracks/spacing_track.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.tracks', function() { - - var ContainerTrack = tr.ui.tracks.ContainerTrack; - - // TODO(charliea): Make this track collapsible. - /** - * Track to visualize the device model. - * - * @constructor - * @extends {ContainerTrack} - */ - var DeviceTrack = tr.ui.b.define('device-track', ContainerTrack); - - DeviceTrack.prototype = { - - __proto__: ContainerTrack.prototype, - - decorate: function(viewport) { - ContainerTrack.prototype.decorate.call(this, viewport); - - this.classList.add('device-track'); - this.device_ = undefined; - this.powerSeriesTrack_ = undefined; - }, - - get device() { - return this.device_; - }, - - set device(device) { - this.device_ = device; - this.updateContents_(); - }, - - get powerSeriesTrack() { - return this.powerSeriesTrack_; - }, - - get hasVisibleContent() { - return (this.powerSeriesTrack_ && - this.powerSeriesTrack_.hasVisibleContent); - }, - - addContainersToTrackMap: function(containerToTrackMap) { - tr.ui.tracks.ContainerTrack.prototype.addContainersToTrackMap.call( - this, containerToTrackMap); - containerToTrackMap.addContainer(this.device, this); - }, - - addEventsToTrackMap: function(eventToTrackMap) { - this.tracks_.forEach(function(track) { - track.addEventsToTrackMap(eventToTrackMap); - }); - }, - - appendPowerSeriesTrack_: function() { - this.powerSeriesTrack_ = new tr.ui.tracks.PowerSeriesTrack(this.viewport); - this.powerSeriesTrack_.powerSeries = this.device.powerSeries; - - if (this.powerSeriesTrack_.hasVisibleContent) { - this.appendChild(this.powerSeriesTrack_); - this.appendChild(new tr.ui.tracks.SpacingTrack(this.viewport)); - } - }, - - updateContents_: function() { - this.clearTracks_(); - this.appendPowerSeriesTrack_(); - } - }; - - return { - DeviceTrack: DeviceTrack - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/device_track_test.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/device_track_test.html deleted file mode 100644 index ce849355882..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/device_track_test.html +++ /dev/null @@ -1,146 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel='import' href='/tracing/model/device.html'> -<link rel='import' href='/tracing/model/model.html'> -<link rel="import" href="/tracing/ui/base/constants.html"> -<link rel='import' href='/tracing/ui/timeline_display_transform.html'> -<link rel='import' href='/tracing/ui/timeline_viewport.html'> -<link rel='import' href='/tracing/ui/tracks/device_track.html'> -<link rel='import' href='/tracing/ui/tracks/drawing_container.html'> -<link rel='import' href='/tracing/ui/tracks/event_to_track_map.html'> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - - var Device = tr.model.Device; - var DeviceTrack = tr.ui.tracks.DeviceTrack; - var Model = tr.Model; - var PowerSeries = tr.model.PowerSeries; - - var createDrawingContainer = function(series) { - var div = document.createElement('div'); - var viewport = new tr.ui.TimelineViewport(div); - var drawingContainer = new tr.ui.tracks.DrawingContainer(viewport); - div.appendChild(drawingContainer); - - if (series) { - series.updateBounds(); - setDisplayTransformFromBounds(viewport, series.bounds); - } - - return drawingContainer; - }; - - /** - * Sets the mapping between the input range of timestamps and the output range - * of horizontal pixels. - */ - var setDisplayTransformFromBounds = function(viewport, bounds) { - var dt = new tr.ui.TimelineDisplayTransform(); - var pixelRatio = window.devicePixelRatio || 1; - var chartPixelWidth = - (window.innerWidth - tr.ui.b.constants.HEADING_WIDTH) * pixelRatio; - dt.xSetWorldBounds(bounds.min, bounds.max, chartPixelWidth); - viewport.setDisplayTransformImmediately(dt); - }; - - test('instantiate', function() { - var device = new Device(new Model()); - device.powerSeries = new PowerSeries(device); - device.powerSeries.addPowerSample(0, 1); - device.powerSeries.addPowerSample(0.5, 2); - device.powerSeries.addPowerSample(1, 3); - device.powerSeries.addPowerSample(1.5, 4); - - var drawingContainer = createDrawingContainer(device.powerSeries); - var track = new DeviceTrack(drawingContainer.viewport); - track.device = device; - drawingContainer.appendChild(track); - - this.addHTMLOutput(drawingContainer); - }); - - test('instantiate_noPowerSeries', function() { - var device = new Device(new Model()); - - var drawingContainer = createDrawingContainer(device.powerSeries); - var track = new DeviceTrack(drawingContainer.viewport); - track.device = device; - drawingContainer.appendChild(track); - - // Adding output should throw due to no visible content. - assert.throw(function() { this.addHTMLOutput(drawingContainer); }); - }); - - test('setDevice_clearsTrackBeforeUpdating', function() { - var device = new Device(new Model()); - device.powerSeries = new PowerSeries(device); - device.powerSeries.addPowerSample(0, 1); - device.powerSeries.addPowerSample(0.5, 2); - device.powerSeries.addPowerSample(1, 3); - device.powerSeries.addPowerSample(1.5, 4); - - var drawingContainer = createDrawingContainer(device.powerSeries); - - // Set the device twice and make sure that this doesn't result in - // the track appearing twice. - var track = new DeviceTrack(drawingContainer.viewport); - track.device = device; - track.device = device; - drawingContainer.appendChild(track); - - this.addHTMLOutput(drawingContainer); - - // The device track should still have two subtracks: one counter track and - // one spacing track. - assert.equal(track.tracks_.length, 2); - }); - - test('addContainersToTrackMap', function() { - var device = new Device(new Model()); - device.powerSeries = new PowerSeries(device); - device.powerSeries.addPowerSample(0, 1); - - var drawingContainer = createDrawingContainer(device.series); - var track = new DeviceTrack(drawingContainer.viewport); - track.device = device; - - var containerToTrackMap = new tr.ui.tracks.ContainerToTrackMap(); - track.addContainersToTrackMap(containerToTrackMap); - - assert.equal(containerToTrackMap.getTrackByStableId('Device'), track); - assert.equal( - containerToTrackMap.getTrackByStableId('Device.PowerSeries'), - track.powerSeriesTrack); - }); - - test('addEventsToTrackMap', function() { - var device = new Device(new Model()); - device.powerSeries = new PowerSeries(device); - device.powerSeries.addPowerSample(0, 1); - device.powerSeries.addPowerSample(0.5, 2); - - var div = document.createElement('div'); - var viewport = new tr.ui.TimelineViewport(div); - - var track = new DeviceTrack(viewport); - track.device = device; - - var eventToTrackMap = new tr.ui.tracks.EventToTrackMap(); - track.addEventsToTrackMap(eventToTrackMap); - - var expected = new tr.ui.tracks.EventToTrackMap(); - expected[device.powerSeries.samples[0].guid] = track.powerSeriesTrack; - expected[device.powerSeries.samples[1].guid] = track.powerSeriesTrack; - - assert.deepEqual(eventToTrackMap, expected); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/drawing_container.css b/chromium/third_party/catapult/tracing/tracing/ui/tracks/drawing_container.css deleted file mode 100644 index a4a8cdb5b89..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/drawing_container.css +++ /dev/null @@ -1,20 +0,0 @@ -/* Copyright (c) 2012 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -.drawing-container { - -webkit-box-flex: 1; - display: inline; - overflow: auto; - overflow-x: hidden; - position: relative; -} - -.drawing-container-canvas { - -webkit-box-flex: 1; - display: block; - pointer-events: none; - position: absolute; - top: 0; -} diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/drawing_container.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/drawing_container.html deleted file mode 100644 index 69a8ca43026..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/drawing_container.html +++ /dev/null @@ -1,176 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="stylesheet" href="/tracing/ui/tracks/drawing_container.css"> - -<link rel="import" href="/tracing/base/raf.html"> -<link rel="import" href="/tracing/ui/tracks/track.html"> -<link rel="import" href="/tracing/ui/base/constants.html"> -<link rel="import" href="/tracing/ui/base/ui.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.tracks', function() { - var DrawType = { - GENERAL_EVENT: 1, - INSTANT_EVENT: 2, - BACKGROUND: 3, - GRID: 4, - FLOW_ARROWS: 5, - MARKERS: 6, - HIGHLIGHTS: 7, - ANNOTATIONS: 8 - }; - - var DrawingContainer = tr.ui.b.define('drawing-container', - tr.ui.tracks.Track); - - DrawingContainer.prototype = { - __proto__: tr.ui.tracks.Track.prototype, - - decorate: function(viewport) { - tr.ui.tracks.Track.prototype.decorate.call(this, viewport); - this.classList.add('drawing-container'); - - this.canvas_ = document.createElement('canvas'); - this.canvas_.className = 'drawing-container-canvas'; - this.canvas_.style.left = tr.ui.b.constants.HEADING_WIDTH + 'px'; - this.appendChild(this.canvas_); - - this.ctx_ = this.canvas_.getContext('2d'); - - this.viewportChange_ = this.viewportChange_.bind(this); - this.viewport.addEventListener('change', this.viewportChange_); - }, - - // Needed to support the calls in TimelineTrackView. - get canvas() { - return this.canvas_; - }, - - context: function() { - return this.ctx_; - }, - - viewportChange_: function() { - this.invalidate(); - }, - - invalidate: function() { - if (this.rafPending_) - return; - this.rafPending_ = true; - - tr.b.requestPreAnimationFrame(this.preDraw_, this); - }, - - preDraw_: function() { - this.rafPending_ = false; - this.updateCanvasSizeIfNeeded_(); - - tr.b.requestAnimationFrameInThisFrameIfPossible(this.draw_, this); - }, - - draw_: function() { - this.ctx_.clearRect(0, 0, this.canvas_.width, this.canvas_.height); - - var typesToDraw = [ - DrawType.BACKGROUND, - DrawType.HIGHLIGHTS, - DrawType.GRID, - DrawType.INSTANT_EVENT, - DrawType.GENERAL_EVENT, - DrawType.MARKERS, - DrawType.ANNOTATIONS, - DrawType.FLOW_ARROWS - ]; - - for (var idx in typesToDraw) { - for (var i = 0; i < this.children.length; ++i) { - if (!(this.children[i] instanceof tr.ui.tracks.Track)) - continue; - this.children[i].drawTrack(typesToDraw[idx]); - } - } - - var pixelRatio = window.devicePixelRatio || 1; - var bounds = this.canvas_.getBoundingClientRect(); - var dt = this.viewport.currentDisplayTransform; - var viewLWorld = dt.xViewToWorld(0); - var viewRWorld = dt.xViewToWorld( - bounds.width * pixelRatio); - - this.viewport.drawGridLines(this.ctx_, viewLWorld, viewRWorld); - }, - - updateCanvasSizeIfNeeded_: function() { - var visibleChildTracks = - tr.b.asArray(this.children).filter(this.visibleFilter_); - - var thisBounds = this.getBoundingClientRect(); - - var firstChildTrackBounds = visibleChildTracks[0].getBoundingClientRect(); - var lastChildTrackBounds = - visibleChildTracks[visibleChildTracks.length - 1]. - getBoundingClientRect(); - - var innerWidth = firstChildTrackBounds.width - - tr.ui.b.constants.HEADING_WIDTH; - var innerHeight = lastChildTrackBounds.bottom - firstChildTrackBounds.top; - - var pixelRatio = window.devicePixelRatio || 1; - if (this.canvas_.width != innerWidth * pixelRatio) { - this.canvas_.width = innerWidth * pixelRatio; - this.canvas_.style.width = innerWidth + 'px'; - } - - if (this.canvas_.height != innerHeight * pixelRatio) { - this.canvas_.height = innerHeight * pixelRatio; - this.canvas_.style.height = innerHeight + 'px'; - } - }, - - visibleFilter_: function(element) { - if (!(element instanceof tr.ui.tracks.Track)) - return false; - return window.getComputedStyle(element).display !== 'none'; - }, - - addClosestEventToSelection: function( - worldX, worldMaxDist, loY, hiY, selection) { - for (var i = 0; i < this.children.length; ++i) { - if (!(this.children[i] instanceof tr.ui.tracks.Track)) - continue; - var trackClientRect = this.children[i].getBoundingClientRect(); - var a = Math.max(loY, trackClientRect.top); - var b = Math.min(hiY, trackClientRect.bottom); - if (a <= b) { - this.children[i].addClosestEventToSelection( - worldX, worldMaxDist, loY, hiY, selection); - } - } - - tr.ui.tracks.Track.prototype.addClosestEventToSelection. - apply(this, arguments); - }, - - addEventsToTrackMap: function(eventToTrackMap) { - for (var i = 0; i < this.children.length; ++i) { - if (!(this.children[i] instanceof tr.ui.tracks.Track)) - continue; - this.children[i].addEventsToTrackMap(eventToTrackMap); - } - } - }; - - return { - DrawingContainer: DrawingContainer, - DrawType: DrawType - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/drawing_container_perf_test.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/drawing_container_perf_test.html deleted file mode 100644 index 9cb3d727c66..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/drawing_container_perf_test.html +++ /dev/null @@ -1,136 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/xhr.html"> -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/ui/extras/full_config.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var generalModel; - function getOrCreateGeneralModel() { - if (generalModel !== undefined) - generalModel; - var fileUrl = '/test_data/thread_time_visualisation.json.gz'; - var events = tr.b.getSync(fileUrl); - generalModel = tr.c.TestUtils.newModelWithEvents([events]); - return generalModel; - } - - function DCPerfTestCase(testName, opt_options) { - tr.b.unittest.PerfTestCase.call(this, testName, undefined, opt_options); - this.viewportDiv = undefined; - this.drawingContainer = undefined; - this.viewport = undefined; - } - DCPerfTestCase.prototype = { - __proto__: tr.b.unittest.PerfTestCase.prototype, - - setUp: function(model) { - this.viewportDiv = document.createElement('div'); - - this.viewport = new tr.ui.TimelineViewport(this.viewportDiv); - - this.drawingContainer = new tr.ui.tracks.DrawingContainer(this.viewport); - this.viewport.modelTrackContainer = this.drawingContainer; - - var modelTrack = new tr.ui.tracks.ModelTrack(this.viewport); - this.drawingContainer.appendChild(modelTrack); - - modelTrack.model = model; - - this.viewportDiv.appendChild(this.drawingContainer); - - this.addHTMLOutput(this.viewportDiv); - - // Size the canvas. - this.drawingContainer.updateCanvasSizeIfNeeded_(); - - // Size the viewport. - var w = this.drawingContainer.canvas.width; - var min = model.bounds.min; - var range = model.bounds.range; - - var boost = range * 0.15; - var dt = new tr.ui.TimelineDisplayTransform(); - dt.xSetWorldBounds(min - boost, min + range + boost, w); - this.viewport.setDisplayTransformImmediately(dt); - }, - - runOneIteration: function() { - this.drawingContainer.draw_(); - } - }; - - - function GeneralDCPerfTestCase(testName, opt_options) { - DCPerfTestCase.call(this, testName, opt_options); - } - - GeneralDCPerfTestCase.prototype = { - __proto__: DCPerfTestCase.prototype, - - setUp: function() { - var model = getOrCreateGeneralModel(); - DCPerfTestCase.prototype.setUp.call(this, model); - } - }; - - // Failing on Chrome canary, see - // https://github.com/catapult-project/catapult/issues/1826 - flakyTest(new GeneralDCPerfTestCase('draw_softwareCanvas_One', - {iterations: 1})); - // Failing on Chrome stable on Windows, see - // https://github.com/catapult-project/catapult/issues/1908 - flakyTest(new GeneralDCPerfTestCase('draw_softwareCanvas_Ten', - {iterations: 10})); - test(new GeneralDCPerfTestCase('draw_softwareCanvas_AHundred', - {iterations: 100})); - - function AsyncDCPerfTestCase(testName, opt_options) { - DCPerfTestCase.call(this, testName, opt_options); - } - - AsyncDCPerfTestCase.prototype = { - __proto__: DCPerfTestCase.prototype, - - setUp: function() { - var model = tr.c.TestUtils.newModel(function(m) { - var proc = m.getOrCreateProcess(1); - for (var tid = 1; tid <= 5; tid++) { - var thread = proc.getOrCreateThread(tid); - for (var i = 0; i < 5000; i++) { - var mod = Math.floor(i / 100) % 4; - var slice = tr.c.TestUtils.newAsyncSliceEx({ - name: 'Test' + i, - colorId: tid + mod, - id: tr.b.GUID.allocateSimple(), - start: i * 10, - duration: 9, - isTopLevel: true - }); - thread.asyncSliceGroup.push(slice); - } - } - }); - DCPerfTestCase.prototype.setUp.call(this, model); - - var w = this.drawingContainer.canvas.width; - - var dt = new tr.ui.TimelineDisplayTransform(); - dt.xSetWorldBounds(-2000, 54000, w); - this.viewport.setDisplayTransformImmediately(dt); - } - }; - test(new AsyncDCPerfTestCase('draw_asyncSliceHeavy_Twenty', - {iterations: 20})); -}); -</script> - diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/event_to_track_map.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/event_to_track_map.html deleted file mode 100644 index 27da2820c61..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/event_to_track_map.html +++ /dev/null @@ -1,34 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/base.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.tracks', function() { - - /** - * EventToTrackMap provides a mapping mechanism between events and the - * tracks those events belong on. - * @constructor - */ - function EventToTrackMap() {} - - EventToTrackMap.prototype = { - addEvent: function(event, track) { - if (!track) - throw new Error('Must provide a track.'); - this[event.guid] = track; - } - }; - - return { - EventToTrackMap: EventToTrackMap - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/frame_track.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/frame_track.html deleted file mode 100644 index c3d6bc6830c..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/frame_track.html +++ /dev/null @@ -1,72 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/color_scheme.html"> -<link rel="import" href="/tracing/ui/base/event_presenter.html"> -<link rel="import" href="/tracing/ui/base/ui.html"> -<link rel="import" href="/tracing/ui/tracks/letter_dot_track.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.tracks', function() { - var startCompare = function(x, y) { return x.start - y.start; } - - /** - * Track enabling quick selection of frame slices/events. - * @constructor - */ - var FrameTrack = tr.ui.b.define( - 'frame-track', tr.ui.tracks.LetterDotTrack); - - FrameTrack.prototype = { - __proto__: tr.ui.tracks.LetterDotTrack.prototype, - - decorate: function(viewport) { - tr.ui.tracks.LetterDotTrack.prototype.decorate.call(this, viewport); - this.heading = 'Frames'; - - this.frames_ = undefined; - this.items = undefined; - }, - - get frames() { - return this.frames_; - }, - - set frames(frames) { - this.frames_ = frames; - if (frames === undefined) - return; - - this.frames_ = this.frames_.slice(); - this.frames_.sort(startCompare); - - // letter dots - this.items = this.frames_.map(function(frame) { - return new FrameDot(frame); - }); - } - }; - - /** - * @constructor - * @extends {LetterDot} - */ - function FrameDot(frame) { - tr.ui.tracks.LetterDot.call(this, frame, 'F', frame.colorId, frame.start); - } - - FrameDot.prototype = { - __proto__: tr.ui.tracks.LetterDot.prototype - }; - - return { - FrameTrack: FrameTrack - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/frame_track_test.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/frame_track_test.html deleted file mode 100644 index 943e245b37c..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/frame_track_test.html +++ /dev/null @@ -1,106 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/model/frame.html"> -<link rel="import" href="/tracing/ui/timeline_viewport.html"> -<link rel="import" href="/tracing/ui/tracks/drawing_container.html"> -<link rel="import" href="/tracing/ui/tracks/frame_track.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var Frame = tr.model.Frame; - var FrameTrack = tr.ui.tracks.FrameTrack; - var EventSet = tr.model.EventSet; - var SelectionState = tr.model.SelectionState; - var Viewport = tr.ui.TimelineViewport; - - var createFrames = function() { - var frames = undefined; - var model = tr.c.TestUtils.newModel(function(model) { - var process = model.getOrCreateProcess(1); - var thread = process.getOrCreateThread(1); - for (var i = 1; i < 5; i++) { - var slice = tr.c.TestUtils.newSliceEx( - {title: 'work for frame', start: i * 20, duration: 10}); - thread.sliceGroup.pushSlice(slice); - var events = [slice]; - var threadTimeRanges = - [{thread: thread, start: slice.start, end: slice.end}]; - process.frames.push(new Frame(events, threadTimeRanges)); - } - frames = process.frames; - }); - return frames; - }; - - test('instantiate', function() { - var frames = createFrames(); - frames[1].selectionState = SelectionState.SELECTED; - - var div = document.createElement('div'); - var viewport = new Viewport(div); - var drawingContainer = new tr.ui.tracks.DrawingContainer(viewport); - div.appendChild(drawingContainer); - - var track = FrameTrack(viewport); - drawingContainer.appendChild(track); - - this.addHTMLOutput(div); - drawingContainer.invalidate(); - - track.frames = frames; - var dt = new tr.ui.TimelineDisplayTransform(); - dt.xSetWorldBounds(0, 50, track.clientWidth); - track.viewport.setDisplayTransformImmediately(dt); - - assert.equal(track.items[0].start, 20); - }); - - test('modelMapping', function() { - var frames = createFrames(); - - var div = document.createElement('div'); - var viewport = new Viewport(div); - var track = FrameTrack(viewport); - track.frames = frames; - - var a0 = track.items[0].modelItem; - assert.equal(a0, frames[0]); - }); - - test('selectionMapping', function() { - var frames = createFrames(); - - var div = document.createElement('div'); - var viewport = new Viewport(div); - var track = FrameTrack(viewport); - track.frames = frames; - - var selection = new EventSet(); - track.items[0].addToSelection(selection); - - // select both frame, but not its component slice - assert.equal(selection.length, 1); - - var frameCount = 0; - var eventCount = 0; - selection.forEach(function(event) { - if (event instanceof Frame) { - assert.equal(event, frames[0]); - frameCount++; - } else - eventCount++; - }); - assert.equal(frameCount, 1); - assert.equal(eventCount, 0); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/global_memory_dump_track.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/global_memory_dump_track.html deleted file mode 100644 index 0e2e4d54c24..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/global_memory_dump_track.html +++ /dev/null @@ -1,102 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/tracks/chart_track.html"> -<link rel="import" href="/tracing/ui/tracks/container_track.html"> -<link rel="import" href="/tracing/ui/tracks/letter_dot_track.html"> -<link rel="import" href="/tracing/ui/tracks/memory_dump_track_util.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.tracks', function() { - - var USED_MEMORY_TRACK_HEIGHT = 50; - var ALLOCATED_MEMORY_TRACK_HEIGHT = 50; - - /** - * A track that displays an array of GlobalMemoryDump objects. - * @constructor - * @extends {ContainerTrack} - */ - var GlobalMemoryDumpTrack = tr.ui.b.define( - 'global-memory-dump-track', tr.ui.tracks.ContainerTrack); - - GlobalMemoryDumpTrack.prototype = { - __proto__: tr.ui.tracks.ContainerTrack.prototype, - - decorate: function(viewport) { - tr.ui.tracks.ContainerTrack.prototype.decorate.call(this, viewport); - this.memoryDumps_ = undefined; - }, - - get memoryDumps() { - return this.memoryDumps_; - }, - - set memoryDumps(memoryDumps) { - this.memoryDumps_ = memoryDumps; - this.updateContents_(); - }, - - updateContents_: function() { - this.clearTracks_(); - - // Show no tracks if there are no dumps. - if (!this.memoryDumps_ || !this.memoryDumps_.length) - return; - - this.appendDumpDotsTrack_(); - this.appendUsedMemoryTrack_(); - this.appendAllocatedMemoryTrack_(); - }, - - appendDumpDotsTrack_: function() { - var items = tr.ui.tracks.buildMemoryLetterDots(this.memoryDumps_); - if (!items) - return; - - var track = new tr.ui.tracks.LetterDotTrack(this.viewport); - track.heading = 'Memory Dumps'; - track.items = items; - this.appendChild(track); - }, - - appendUsedMemoryTrack_: function() { - var series = tr.ui.tracks.buildGlobalUsedMemoryChartSeries( - this.memoryDumps_); - if (!series) - return; - - var track = new tr.ui.tracks.ChartTrack(this.viewport); - track.heading = 'Memory per process'; - track.height = USED_MEMORY_TRACK_HEIGHT + 'px'; - track.series = series; - track.autoSetAllAxes({expandMax: true}); - this.appendChild(track); - }, - - appendAllocatedMemoryTrack_: function() { - var series = tr.ui.tracks.buildGlobalAllocatedMemoryChartSeries( - this.memoryDumps_); - if (!series) - return; - - var track = new tr.ui.tracks.ChartTrack(this.viewport); - track.heading = 'Memory per component'; - track.height = ALLOCATED_MEMORY_TRACK_HEIGHT + 'px'; - track.series = series; - track.autoSetAllAxes({expandMax: true}); - this.appendChild(track); - } - }; - - return { - GlobalMemoryDumpTrack: GlobalMemoryDumpTrack - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/global_memory_dump_track_test.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/global_memory_dump_track_test.html deleted file mode 100644 index 268da37bcf7..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/global_memory_dump_track_test.html +++ /dev/null @@ -1,61 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/ui/timeline_viewport.html"> -<link rel="import" href="/tracing/ui/tracks/drawing_container.html"> -<link rel="import" href="/tracing/ui/tracks/global_memory_dump_track.html"> -<link rel="import" href="/tracing/ui/tracks/memory_dump_track_test_utils.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var Viewport = tr.ui.TimelineViewport; - var GlobalMemoryDumpTrack = tr.ui.tracks.GlobalMemoryDumpTrack; - var createTestGlobalMemoryDumps = tr.ui.tracks.createTestGlobalMemoryDumps; - - function instantiateTrack(withVMRegions, withAllocatorDumps, - expectedTrackCount) { - var dumps = createTestGlobalMemoryDumps(withVMRegions, withAllocatorDumps); - - var div = document.createElement('div'); - var viewport = new Viewport(div); - var drawingContainer = new tr.ui.tracks.DrawingContainer(viewport); - div.appendChild(drawingContainer); - - var track = new GlobalMemoryDumpTrack(viewport); - drawingContainer.appendChild(track); - drawingContainer.invalidate(); - - track.memoryDumps = dumps; - this.addHTMLOutput(div); - - var dt = new tr.ui.TimelineDisplayTransform(); - dt.xSetWorldBounds(0, 50, track.clientWidth); - track.viewport.setDisplayTransformImmediately(dt); - - assert.lengthOf(track.tracks_, expectedTrackCount); - }; - - test('instantiate_dotsOnly', function() { - instantiateTrack.call(this, false, false, 1); - }); - - test('instantiate_withVMRegions', function() { - instantiateTrack.call(this, true, false, 2); - }); - - test('instantiate_withMemoryAllocatorDumps', function() { - instantiateTrack.call(this, false, true, 2); - }); - - test('instantiate_withBoth', function() { - instantiateTrack.call(this, true, true, 3); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/highlighter.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/highlighter.html deleted file mode 100644 index 6b3a7e69c70..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/highlighter.html +++ /dev/null @@ -1,53 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/base.html"> -<link rel="import" href="/tracing/base/extension_registry.html"> - -<script> -'use strict'; - -/** - * @fileoverview Allows custom highlighting to be added to the full model track. - */ -tr.exportTo('tr.ui.tracks', function() { - - /** - * Highlights cetrain features of the model. - * @constructor - */ - function Highlighter(viewport) { - if (viewport === undefined) { - throw new Error('viewport must be provided'); - } - this.viewport_ = viewport; - }; - - Highlighter.prototype = { - __proto__: Object.prototype, - - processModel: function(model) { - throw new Error('processModel implementation missing'); - }, - - drawHighlight: function(ctx, dt, viewLWorld, viewRWorld, viewHeight) { - throw new Error('drawHighlight implementation missing'); - } - }; - - - var options = new tr.b.ExtensionRegistryOptions(tr.b.BASIC_REGISTRY_MODE); - options.defaultMetadata = {}; - options.mandatoryBaseClass = Highlighter; - tr.b.decorateExtensionRegistry(Highlighter, options); - - return { - Highlighter: Highlighter - }; -}); -</script> - diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/interaction_track.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/interaction_track.html deleted file mode 100644 index 8e8f181ff90..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/interaction_track.html +++ /dev/null @@ -1,68 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/base/draw_helpers.html"> -<link rel="import" href="/tracing/ui/base/ui.html"> -<link rel="import" href="/tracing/ui/tracks/alert_track.html"> -<link rel="import" href="/tracing/ui/tracks/container_track.html"> -<link rel="import" href="/tracing/ui/tracks/drawing_container.html"> -<link rel="import" href="/tracing/ui/tracks/highlighter.html"> -<link rel="import" href="/tracing/ui/tracks/kernel_track.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.tracks', function() { - /** - * A track that displays an array of interaction records. - * @constructor - * @extends {MultiRowTrack} - */ - var InteractionTrack = tr.ui.b.define( - 'interaction-track', tr.ui.tracks.MultiRowTrack); - - InteractionTrack.prototype = { - __proto__: tr.ui.tracks.MultiRowTrack.prototype, - - decorate: function(viewport) { - tr.ui.tracks.MultiRowTrack.prototype.decorate.call(this, viewport); - this.heading = 'Interactions'; - this.subRows_ = []; - }, - - set model(model) { - this.setItemsToGroup(model.userModel.expectations, { - guid: tr.b.GUID.allocateSimple(), - model: model, - getSettingsKey: function() { - return undefined; - } - }); - }, - - buildSubRows_: function(slices) { - if (this.subRows_.length) - return this.subRows_; - this.subRows_.push.apply(this.subRows_, - tr.ui.tracks.AsyncSliceGroupTrack.prototype.buildSubRows_.call( - {}, slices, true)); - return this.subRows_; - }, - - addSubTrack_: function(slices) { - var track = new tr.ui.tracks.SliceTrack(this.viewport); - track.slices = slices; - this.appendChild(track); - return track; - } - }; - - return { - InteractionTrack: InteractionTrack - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/interaction_track_test.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/interaction_track_test.html deleted file mode 100644 index 1b2c1346a16..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/interaction_track_test.html +++ /dev/null @@ -1,51 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/model/user_model/stub_expectation.html"> -<link rel="import" href="/tracing/ui/timeline_viewport.html"> -<link rel="import" href="/tracing/ui/tracks/interaction_track.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - // UserExpectations should be sorted by start time, not title, so that - // AsyncSliceGroupTrack.buildSubRows_ can lay them out in as few tracks as - // possible, so that they mesh instead of stacking unnecessarily. - test('instantiate', function() { - var div = document.createElement('div'); - var viewport = new tr.ui.TimelineViewport(div); - var drawingContainer = new tr.ui.tracks.DrawingContainer(viewport); - div.appendChild(drawingContainer); - var track = new tr.ui.tracks.InteractionTrack(viewport); - track.model = tr.c.TestUtils.newModel(function(model) { - var process = model.getOrCreateProcess(1); - var thread = process.getOrCreateThread(1); - thread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx( - {start: 0, duration: 200})); - model.userModel.expectations.push(new tr.model.um.StubExpectation( - {parentModel: model, start: 100, duration: 100})); - model.userModel.expectations.push(new tr.model.um.StubExpectation( - {parentModel: model, start: 0, duration: 100})); - model.userModel.expectations.push(new tr.model.um.StubExpectation( - {parentModel: model, start: 150, duration: 50})); - model.userModel.expectations.push(new tr.model.um.StubExpectation( - {parentModel: model, start: 50, duration: 100})); - model.userModel.expectations.push(new tr.model.um.StubExpectation( - {parentModel: model, start: 0, duration: 50})); - // Model.createImportTracesTask() automatically sorts IRs by start time. - }); - assert.equal(2, track.subRows_.length); - assert.equal(2, track.subRows_[0].length); - assert.equal(3, track.subRows_[1].length); - drawingContainer.appendChild(track); - this.addHTMLOutput(div); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/kernel_track.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/kernel_track.html deleted file mode 100644 index 20ffea84d05..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/kernel_track.html +++ /dev/null @@ -1,83 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/tracks/process_track_base.html"> -<link rel="import" href="/tracing/ui/tracks/cpu_track.html"> -<link rel="import" href="/tracing/ui/tracks/spacing_track.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.tracks', function() { - var Cpu = tr.model.Cpu; - var CpuTrack = tr.ui.tracks.cpu_track; - var ProcessTrackBase = tr.ui.tracks.ProcessTrackBase; - var SpacingTrack = tr.ui.tracks.SpacingTrack; - - /** - * @constructor - */ - var KernelTrack = tr.ui.b.define('kernel-track', ProcessTrackBase); - - KernelTrack.prototype = { - __proto__: ProcessTrackBase.prototype, - - decorate: function(viewport) { - ProcessTrackBase.prototype.decorate.call(this, viewport); - }, - - - // Kernel maps to processBase because we derive from ProcessTrackBase. - set kernel(kernel) { - this.processBase = kernel; - }, - - get kernel() { - return this.processBase; - }, - - get eventContainer() { - return this.kernel; - }, - - get hasVisibleContent() { - return this.children.length > 1; - }, - - addContainersToTrackMap: function(containerToTrackMap) { - tr.ui.tracks.ProcessTrackBase.prototype.addContainersToTrackMap.call( - this, containerToTrackMap); - containerToTrackMap.addContainer(this.kernel, this); - }, - - willAppendTracks_: function() { - var cpus = tr.b.dictionaryValues(this.kernel.cpus); - cpus.sort(tr.model.Cpu.compare); - - var didAppendAtLeastOneTrack = false; - for (var i = 0; i < cpus.length; ++i) { - var cpu = cpus[i]; - var track = new tr.ui.tracks.CpuTrack(this.viewport); - track.detailedMode = this.expanded; - track.cpu = cpu; - if (!track.hasVisibleContent) - continue; - this.appendChild(track); - didAppendAtLeastOneTrack = true; - } - if (didAppendAtLeastOneTrack) - this.appendChild(new SpacingTrack(this.viewport)); - } - }; - - - return { - KernelTrack: KernelTrack - }; -}); -</script> - diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/letter_dot_track.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/letter_dot_track.html deleted file mode 100644 index 64f26e4fb4f..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/letter_dot_track.html +++ /dev/null @@ -1,260 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/color_scheme.html"> -<link rel="import" href="/tracing/base/sorted_array_utils.html"> -<link rel="import" href="/tracing/model/proxy_selectable_item.html"> -<link rel="import" href="/tracing/ui/base/event_presenter.html"> -<link rel="import" href="/tracing/ui/base/heading.html"> -<link rel="import" href="/tracing/ui/base/ui.html"> -<link rel="import" href="/tracing/ui/tracks/track.html"> - -<style> -.letter-dot-track { - height: 18px; -} -</style> - -<script> -'use strict'; - -tr.exportTo('tr.ui.tracks', function() { - var EventPresenter = tr.ui.b.EventPresenter; - var SelectionState = tr.model.SelectionState; - - /** - * A track that displays an array of dots with filled letters inside them. - * @constructor - * @extends {Track} - */ - var LetterDotTrack = tr.ui.b.define( - 'letter-dot-track', tr.ui.tracks.Track); - - LetterDotTrack.prototype = { - __proto__: tr.ui.tracks.Track.prototype, - - decorate: function(viewport) { - tr.ui.tracks.Track.prototype.decorate.call(this, viewport); - this.classList.add('letter-dot-track'); - this.items_ = undefined; - - this.heading_ = document.createElement('tr-ui-heading'); - this.appendChild(this.heading_); - }, - - set heading(heading) { - this.heading_.heading = heading; - }, - - get heading() { - return this.heading_.heading; - }, - - set tooltip(tooltip) { - this.heading_.tooltip = tooltip; - }, - - get items() { - return this.items_; - }, - - set items(items) { - this.items_ = items; - this.invalidateDrawingContainer(); - }, - - get height() { - return window.getComputedStyle(this).height; - }, - - set height(height) { - this.style.height = height; - }, - - get dumpRadiusView() { - return 7 * (window.devicePixelRatio || 1); - }, - - draw: function(type, viewLWorld, viewRWorld) { - if (this.items_ === undefined) - return; - switch (type) { - case tr.ui.tracks.DrawType.GENERAL_EVENT: - this.drawLetterDots_(viewLWorld, viewRWorld); - break; - } - }, - - drawLetterDots_: function(viewLWorld, viewRWorld) { - var ctx = this.context(); - var pixelRatio = window.devicePixelRatio || 1; - - var bounds = this.getBoundingClientRect(); - var height = bounds.height * pixelRatio; - var halfHeight = height * 0.5; - var twoPi = Math.PI * 2; - - // Culling parameters. - var dt = this.viewport.currentDisplayTransform; - var dumpRadiusView = this.dumpRadiusView; - var itemRadiusWorld = dt.xViewVectorToWorld(height); - - // Draw the memory dumps. - var items = this.items_; - var loI = tr.b.findLowIndexInSortedArray( - items, - function(item) { return item.start; }, - viewLWorld); - - var oldFont = ctx.font; - ctx.font = '400 ' + Math.floor(9 * pixelRatio) + 'px Arial'; - ctx.strokeStyle = 'rgb(0,0,0)'; - ctx.textBaseline = 'middle'; - ctx.textAlign = 'center'; - - var drawItems = function(selected) { - for (var i = loI; i < items.length; ++i) { - var item = items[i]; - var x = item.start; - if (x - itemRadiusWorld > viewRWorld) - break; - if (item.selected !== selected) - continue; - var xView = dt.xWorldToView(x); - - ctx.fillStyle = EventPresenter.getSelectableItemColorAsString(item); - ctx.beginPath(); - ctx.arc(xView, halfHeight, dumpRadiusView + 0.5, 0, twoPi); - ctx.fill(); - if (item.selected) { - ctx.lineWidth = 3; - ctx.strokeStyle = 'rgb(100,100,0)'; - ctx.stroke(); - - ctx.beginPath(); - ctx.arc(xView, halfHeight, dumpRadiusView, 0, twoPi); - ctx.lineWidth = 1.5; - ctx.strokeStyle = 'rgb(255,255,0)'; - ctx.stroke(); - } else { - ctx.lineWidth = 1; - ctx.strokeStyle = 'rgb(0,0,0)'; - ctx.stroke(); - } - - ctx.fillStyle = 'rgb(255, 255, 255)'; - ctx.fillText(item.dotLetter, xView, halfHeight); - } - }; - - // Draw unselected items first to make sure they don't occlude selected - // items. - drawItems(false); - drawItems(true); - - ctx.lineWidth = 1; - ctx.font = oldFont; - }, - - addEventsToTrackMap: function(eventToTrackMap) { - if (this.items_ === undefined) - return; - - this.items_.forEach(function(item) { - item.addToTrackMap(eventToTrackMap, this); - }, this); - }, - - addIntersectingEventsInRangeToSelectionInWorldSpace: function( - loWX, hiWX, viewPixWidthWorld, selection) { - if (this.items_ === undefined) - return; - - var itemRadiusWorld = viewPixWidthWorld * this.dumpRadiusView; - tr.b.iterateOverIntersectingIntervals( - this.items_, - function(x) { return x.start - itemRadiusWorld; }, - function(x) { return 2 * itemRadiusWorld; }, - loWX, hiWX, - function(item) { - item.addToSelection(selection); - }.bind(this)); - }, - - /** - * Add the item to the left or right of the provided event, if any, to the - * selection. - * @param {event} The current event item. - * @param {Number} offset Number of slices away from the event to look. - * @param {Selection} selection The selection to add an event to, - * if found. - * @return {boolean} Whether an event was found. - * @private - */ - addEventNearToProvidedEventToSelection: function(event, offset, selection) { - if (this.items_ === undefined) - return; - - var items = this.items_; - var index = tr.b.findFirstIndexInArray(items, function(item) { - return item.modelItem === event; - }); - if (index === -1) - return false; - - var newIndex = index + offset; - if (newIndex >= 0 && newIndex < items.length) { - items[newIndex].addToSelection(selection); - return true; - } - return false; - }, - - addAllEventsMatchingFilterToSelection: function(filter, selection) { - }, - - addClosestEventToSelection: function(worldX, worldMaxDist, loY, hiY, - selection) { - if (this.items_ === undefined) - return; - - var item = tr.b.findClosestElementInSortedArray( - this.items_, - function(x) { return x.start; }, - worldX, - worldMaxDist); - - if (!item) - return; - - item.addToSelection(selection); - } - }; - - /** - * A filled dot with a letter inside it. - * - * @constructor - * @extends {ProxySelectableItem} - */ - function LetterDot(modelItem, dotLetter, colorId, start) { - tr.model.ProxySelectableItem.call(this, modelItem); - this.dotLetter = dotLetter; - this.colorId = colorId; - this.start = start; - }; - - LetterDot.prototype = { - __proto__: tr.model.ProxySelectableItem.prototype - }; - - return { - LetterDotTrack: LetterDotTrack, - LetterDot: LetterDot - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/letter_dot_track_test.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/letter_dot_track_test.html deleted file mode 100644 index 93c2bcfbb9a..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/letter_dot_track_test.html +++ /dev/null @@ -1,121 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/model/selection_state.html"> -<link rel="import" href="/tracing/ui/timeline_viewport.html"> -<link rel="import" href="/tracing/ui/tracks/drawing_container.html"> -<link rel="import" href="/tracing/ui/tracks/letter_dot_track.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var LetterDotTrack = tr.ui.tracks.LetterDotTrack; - var LetterDot = tr.ui.tracks.LetterDot; - var SelectionState = tr.model.SelectionState; - var Viewport = tr.ui.TimelineViewport; - - var createItems = function() { - var items = [ - new LetterDot({selectionState: SelectionState.SELECTED}, 'a', 7, 5), - new LetterDot({selectionState: SelectionState.SELECTED}, 'b', 2, 20), - new LetterDot({selectionState: SelectionState.NONE}, 'c', 4, 35), - new LetterDot({selectionState: SelectionState.NONE}, 'd', 4, 50) - ]; - return items; - }; - - test('instantiate', function() { - var items = createItems(); - - var div = document.createElement('div'); - - var viewport = new Viewport(div); - var drawingContainer = new tr.ui.tracks.DrawingContainer(viewport); - div.appendChild(drawingContainer); - - var track = LetterDotTrack(viewport); - drawingContainer.appendChild(track); - - this.addHTMLOutput(div); - drawingContainer.invalidate(); - - track.items = items; - var dt = new tr.ui.TimelineDisplayTransform(); - dt.xSetWorldBounds(0, 60, track.clientWidth); - track.viewport.setDisplayTransformImmediately(dt); - }); - - test('selectionHitTesting', function() { - var items = createItems(); - - var track = new LetterDotTrack(new Viewport()); - track.items = items; - - // Fake a view pixel size. - var devicePixelRatio = window.devicePixelRatio || 1; - var viewPixWidthWorld = 0.1 / devicePixelRatio; - - // Hit outside range - var selection = []; - track.addIntersectingEventsInRangeToSelectionInWorldSpace( - 3, 4, viewPixWidthWorld, selection); - assert.equal(selection.length, 0); - - // Hit the first item, via pixel-nearness. - selection = []; - track.addIntersectingEventsInRangeToSelectionInWorldSpace( - 19.98, 19.99, viewPixWidthWorld, selection); - assert.equal(selection.length, 1); - assert.equal(selection[0], items[1].modelItem); - - // Hit the instance, between the 1st and 2nd snapshots - selection = []; - track.addIntersectingEventsInRangeToSelectionInWorldSpace( - 30, 50, viewPixWidthWorld, selection); - assert.equal(selection.length, 2); - assert.equal(selection[0], items[2].modelItem); - assert.equal(selection[1], items[3].modelItem); - }); - - test('addEventNearToProvidedEventToSelection', function() { - var items = createItems(); - - var track = new LetterDotTrack(new Viewport()); - track.items = items; - - // Right from the middle of items. - var selection1 = []; - assert.isTrue(track.addEventNearToProvidedEventToSelection( - items[2].modelItem, 1, selection1)); - assert.equal(selection1.length, 1); - assert.equal(selection1[0], items[3].modelItem); - - // Left from the middle of items. - var selection2 = []; - assert.isTrue(track.addEventNearToProvidedEventToSelection( - items[2].modelItem, -1, selection2)); - assert.equal(selection2.length, 1); - assert.equal(selection2[0], items[1].modelItem); - - // Right from the right edge of items. - var selection3 = []; - assert.isFalse(track.addEventNearToProvidedEventToSelection( - items[3].modelItem, 1, selection3)); - assert.equal(selection3.length, 0); - - // Left from the left edge of items. - var selection4 = []; - assert.isFalse(track.addEventNearToProvidedEventToSelection( - items[0].modelItem, -1, selection4)); - assert.equal(selection4.length, 0); - }); -}); -</script> - diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/memory_dump_track_test_utils.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/memory_dump_track_test_utils.html deleted file mode 100644 index 2d13a901ba8..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/memory_dump_track_test_utils.html +++ /dev/null @@ -1,143 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/model/container_memory_dump.html"> -<link rel="import" href="/tracing/model/global_memory_dump.html"> -<link rel="import" href="/tracing/model/memory_dump_test_utils.html"> -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/model/process_memory_dump.html"> -<link rel="import" href="/tracing/model/selection_state.html"> -<link rel="import" href="/tracing/model/vm_region.html"> - -<script> -'use strict'; - -/** - * @fileoverview Helper functions for memory dump track tests. - */ -tr.exportTo('tr.ui.tracks', function() { - var ProcessMemoryDump = tr.model.ProcessMemoryDump; - var GlobalMemoryDump = tr.model.GlobalMemoryDump; - var VMRegion = tr.model.VMRegion; - var VMRegionClassificationNode = tr.model.VMRegionClassificationNode; - var SelectionState = tr.model.SelectionState; - var addGlobalMemoryDump = tr.model.MemoryDumpTestUtils.addGlobalMemoryDump; - var addProcessMemoryDump = tr.model.MemoryDumpTestUtils.addProcessMemoryDump; - var newAllocatorDump = tr.model.MemoryDumpTestUtils.newAllocatorDump; - var addOwnershipLink = tr.model.MemoryDumpTestUtils.addOwnershipLink; - var LIGHT = tr.model.ContainerMemoryDump.LevelOfDetail.LIGHT; - var DETAILED = tr.model.ContainerMemoryDump.LevelOfDetail.DETAILED; - - function createVMRegions(pssValues) { - return VMRegionClassificationNode.fromRegions( - pssValues.map(function(pssValue, i) { - return VMRegion.fromDict({ - startAddress: 1000 * i, - sizeInBytes: 1000, - protectionFlags: VMRegion.PROTECTION_FLAG_READ, - mappedFile: '[stack' + i + ']', - byteStats: { - privateDirtyResident: pssValue / 3, - swapped: pssValue * 3, - proportionalResident: pssValue - } - }); - })); - } - - function createAllocatorDumps(memoryDump, dumpData) { - // Create the individual allocator dumps. - var allocatorDumps = tr.b.mapItems(dumpData, function(allocatorName, data) { - var size = data.size; - assert.typeOf(size, 'number'); // Sanity check. - return newAllocatorDump(memoryDump, allocatorName, { size: size }); - }); - - // Add ownership links between them. - tr.b.iterItems(dumpData, function(allocatorName, data) { - var owns = data.owns; - if (owns === undefined) - return; - - var ownerDump = allocatorDumps[allocatorName]; - assert.isDefined(ownerDump); // Sanity check. - var ownedDump = allocatorDumps[owns]; - assert.isDefined(ownedDump); // Sanity check. - - addOwnershipLink(ownerDump, ownedDump); - }); - - return tr.b.dictionaryValues(allocatorDumps); - } - - function addProcessMemoryDumpWithFields(globalMemoryDump, process, start, - opt_pssValues, opt_dumpData) { - var pmd = addProcessMemoryDump(globalMemoryDump, process, start); - if (opt_pssValues !== undefined) - pmd.vmRegions = createVMRegions(opt_pssValues); - if (opt_dumpData !== undefined) - pmd.memoryAllocatorDumps = createAllocatorDumps(pmd, opt_dumpData); - } - - function createModelWithDumps(withVMRegions, withAllocatorDumps) { - var maybePssValues = function(pssValues) { - return withVMRegions ? pssValues : undefined; - }; - var maybeDumpData = function(dumpData) { - return withAllocatorDumps ? dumpData : undefined; - }; - return tr.c.TestUtils.newModel(function(model) { - // Construct a model with three processes. - var pa = model.getOrCreateProcess(3); - var pb = model.getOrCreateProcess(6); - var pc = model.getOrCreateProcess(9); - - var gmd1 = addGlobalMemoryDump(model, 0, LIGHT); - addProcessMemoryDumpWithFields(gmd1, pa, 0, maybePssValues([111])); - addProcessMemoryDumpWithFields(gmd1, pb, 0.2, undefined, - maybeDumpData({oilpan: {size: 1024}})); - - var gmd2 = addGlobalMemoryDump(model, 5, DETAILED); - addProcessMemoryDumpWithFields(gmd2, pa, 0); - addProcessMemoryDumpWithFields(gmd2, pb, 4.99, maybePssValues([100, 50]), - maybeDumpData({v8: {size: 512}})); - addProcessMemoryDumpWithFields(gmd2, pc, 5.12, undefined, - maybeDumpData({oilpan: {size: 128, owns: 'v8'}, - v8: {size: 384, owns: 'tracing'}, tracing: {size: 65920}})); - - var gmd3 = addGlobalMemoryDump(model, 15, DETAILED); - addProcessMemoryDumpWithFields(gmd3, pa, 15.5, maybePssValues([]), - maybeDumpData({v8: {size: 768}})); - addProcessMemoryDumpWithFields(gmd3, pc, 14.5, - maybePssValues([70, 70, 70]), maybeDumpData({oilpan: {size: 512}})); - - var gmd4 = addGlobalMemoryDump(model, 18, LIGHT); - }); - } - - function createTestGlobalMemoryDumps(withVMRegions, withAllocatorDumps) { - var model = createModelWithDumps(withVMRegions, withAllocatorDumps); - var dumps = model.globalMemoryDumps; - dumps[1].selectionState = SelectionState.HIGHLIGHTED; - dumps[2].selectionState = SelectionState.SELECTED; - return dumps; - } - - function createTestProcessMemoryDumps(withVMRegions, withAllocatorDumps) { - var model = createModelWithDumps(withVMRegions, withAllocatorDumps); - var dumps = model.getProcess(9).memoryDumps; - dumps[0].selectionState = SelectionState.SELECTED; - dumps[1].selectionState = SelectionState.HIGHLIGHTED; - return dumps; - } - - return { - createTestGlobalMemoryDumps: createTestGlobalMemoryDumps, - createTestProcessMemoryDumps: createTestProcessMemoryDumps - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/memory_dump_track_util.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/memory_dump_track_util.html deleted file mode 100644 index 821186182b4..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/memory_dump_track_util.html +++ /dev/null @@ -1,262 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/model/container_memory_dump.html"> -<link rel="import" href="/tracing/model/memory_allocator_dump.html"> -<link rel="import" href="/tracing/ui/tracks/chart_axis.html"> -<link rel="import" href="/tracing/ui/tracks/chart_point.html"> -<link rel="import" href="/tracing/ui/tracks/chart_series.html"> -<link rel="import" href="/tracing/ui/tracks/chart_track.html"> -<link rel="import" href="/tracing/ui/tracks/container_track.html"> -<link rel="import" href="/tracing/ui/tracks/letter_dot_track.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.tracks', function() { - var ColorScheme = tr.b.ColorScheme; - - var DISPLAYED_SIZE_NUMERIC_NAME = - tr.model.MemoryAllocatorDump.DISPLAYED_SIZE_NUMERIC_NAME; - var LIGHT = tr.model.ContainerMemoryDump.LevelOfDetail.LIGHT; - var DETAILED = tr.model.ContainerMemoryDump.LevelOfDetail.DETAILED; - - /** - * Add numeric values from a source dictionary to the numeric values in - * a destination dictionary. Undefined values are treated as zeros. Note that - * this method modifies the destination dictionary in place. - * - * Example: addDictionary({a: 1, b: 2}, {b: 3, c: 4}) will update the - * destination dictionary (first argument) to {a: 1, b: 5, c: 4}. - */ - function addDictionary(dstDict, srcDict) { - tr.b.iterItems(srcDict, function(key, value) { - var existingValue = dstDict[key]; - if (existingValue === undefined) - existingValue = 0; - dstDict[key] = existingValue + value; - }); - } - - /** - * Get a dictionary mapping root allocator names (e.g. 'v8') to the - * corresponding sizes (e.g. 1024) in a process memory dump. - */ - function getProcessMemoryDumpAllocatorSizes(processMemoryDump) { - var allocatorDumps = processMemoryDump.memoryAllocatorDumps; - if (allocatorDumps === undefined) - return {}; - var allocatorSizes = {}; - allocatorDumps.forEach(function(allocatorDump) { - // Don't show tracing overhead in the charts. - // TODO(petrcermak): Find a less hacky way to do this. - if (allocatorDump.fullName === 'tracing') - return; - var allocatorSize = allocatorDump.numerics[DISPLAYED_SIZE_NUMERIC_NAME]; - if (allocatorSize === undefined) - return; - var allocatorSizeValue = allocatorSize.value; - if (allocatorSizeValue === undefined) - return; - allocatorSizes[allocatorDump.fullName] = allocatorSizeValue; - }); - return allocatorSizes; - }; - - /** - * Get a dictionary mapping root allocator names (e.g. 'v8') to the - * corresponding sizes (e.g. 1024) in a global memory dump (i.e. summed over - * all simultaneous process memory dumps). - */ - function getGlobalMemoryDumpAllocatorSizes(globalMemoryDump) { - var globalAllocatorSizes = {}; - tr.b.iterItems(globalMemoryDump.processMemoryDumps, - function(pid, processMemoryDump) { - addDictionary(globalAllocatorSizes, - getProcessMemoryDumpAllocatorSizes(processMemoryDump)); - }); - return globalAllocatorSizes; - } - - /** - * A generic function which converts a list of memory dumps to a list of chart - * series (one per root allocator). Each series represents the evolution of - * the size of a the corresponding root allocator (e.g. 'v8') over time. - */ - function buildAllocatedMemoryChartSeries(memoryDumps, - memoryDumpToAllocatorSizesFn) { - var allocatorNameToPoints = {}; - var dumpsData = memoryDumps.map(function(memoryDump) { - var allocatorSizes = memoryDumpToAllocatorSizesFn(memoryDump); - tr.b.iterItems(allocatorSizes, function(allocatorName) { - allocatorNameToPoints[allocatorName] = []; - }); - return {dump: memoryDump, sizes: allocatorSizes}; - }); - - // Do not generate any chart series if no process memory dump contains any - // allocator dumps. - if (Object.keys(allocatorNameToPoints).length === 0) - return undefined; - - dumpsData.forEach(function(dumpData) { - var memoryDump = dumpData.dump; - var allocatorSizes = dumpData.sizes; - tr.b.iterItems(allocatorNameToPoints, function(allocatorName, points) { - var allocatorSize = allocatorSizes[allocatorName] || 0; - points.push(new tr.ui.tracks.ChartPoint( - memoryDump, memoryDump.start, allocatorSize)); - }); - }); - - // Create one common axis for all allocated memory chart series. - var axis = new tr.ui.tracks.ChartAxis(0); - - // Build a chart series for each allocator. - var series = []; - tr.b.iterItems(allocatorNameToPoints, function(allocatorName, points) { - var colorId = ColorScheme.getColorIdForGeneralPurposeString( - allocatorName); - var renderingConfig = { - chartType: tr.ui.tracks.ChartSeriesType.LINE, - colorId: colorId - }; - series.push(new tr.ui.tracks.ChartSeries(points, axis, renderingConfig)); - }); - - return series; - } - - /** - * Transform a list of memory dumps to a list of letter dots (with letter 'M' - * inside). - */ - function buildMemoryLetterDots(memoryDumps) { - var lightMemoryColorId = - ColorScheme.getColorIdForReservedName('light_memory_dump'); - var detailedMemoryColorId = - ColorScheme.getColorIdForReservedName('detailed_memory_dump'); - return memoryDumps.map(function(memoryDump) { - var memoryColorId; - switch (memoryDump.levelOfDetail) { - case DETAILED: - memoryColorId = detailedMemoryColorId; - break; - case LIGHT: - default: - memoryColorId = lightMemoryColorId; - } - return new tr.ui.tracks.LetterDot( - memoryDump, 'M', memoryColorId, memoryDump.start); - }); - } - - /** - * Convert a list of global memory dumps to a list of chart series (one per - * process). Each series represents the evolution of the memory used by the - * process over time. - */ - function buildGlobalUsedMemoryChartSeries(globalMemoryDumps) { - // Do not generate the chart if no process memory dump contains VM regions. - var containsVmRegions = globalMemoryDumps.some(function(globalDump) { - for (var pid in globalDump.processMemoryDumps) - if (globalDump.processMemoryDumps[pid].mostRecentVmRegions) - return true; - return false; - }); - if (!containsVmRegions) - return undefined; - - // Find all processes that dump memory at least once. - var pidToProcess = {}; - globalMemoryDumps.forEach(function(globalDump) { - tr.b.iterItems(globalDump.processMemoryDumps, function(pid, processDump) { - pidToProcess[pid] = processDump.process; - }); - }); - - // Build one list of points for each instrumented process. - var pidToPoints = {}; - tr.b.iterItems(pidToProcess, function(pid, process) { - pidToPoints[pid] = []; - }); - - // For every timestamp, calculate the total PSS (proportional set size) of - // each process and append it to the corresponding list of points. - globalMemoryDumps.forEach(function(globalDump) { - var pssBase = 0; - tr.b.iterItems(pidToPoints, function(pid, points) { - var processMemoryDump = globalDump.processMemoryDumps[pid]; - var cumulativePss = pssBase; - // If no dump was found (probably dead) or it does not provide the - // necessary information (namely most recent VM regions), assume zero. - if (processMemoryDump !== undefined) { - var vmRegions = processMemoryDump.mostRecentVmRegions; - if (vmRegions !== undefined) - cumulativePss += vmRegions.byteStats.proportionalResident || 0; - } - points.push(new tr.ui.tracks.ChartPoint( - globalDump, globalDump.start, cumulativePss, pssBase)); - pssBase = cumulativePss; - }); - }); - - // Create one common axis for all used memory chart series. - var axis = new tr.ui.tracks.ChartAxis(0); - - // Build a chart series for each instrumented process. - var series = []; - tr.b.iterItems(pidToPoints, function(pid, points) { - var process = pidToProcess[pid]; - var colorId = ColorScheme.getColorIdForGeneralPurposeString( - process.userFriendlyName); - var renderingConfig = { - chartType: tr.ui.tracks.ChartSeriesType.AREA, - colorId: colorId, - backgroundOpacity: 0.8 - }; - series.push(new tr.ui.tracks.ChartSeries(points, axis, renderingConfig)); - }); - - // Show the first series (with the smallest cumulative value) at the top. - series.reverse(); - - return series; - } - - /** - * Convert a list of process memory dumps to a list of chart series (one per - * root allocator). Each series represents the evolution of the size of a the - * corresponding root allocator (e.g. 'v8') over time. - */ - function buildProcessAllocatedMemoryChartSeries(processMemoryDumps) { - return buildAllocatedMemoryChartSeries(processMemoryDumps, - getProcessMemoryDumpAllocatorSizes); - } - - /** - * Convert a list of global memory dumps to a list of chart series (one per - * root allocator). Each series represents the evolution of the size of a the - * corresponding root allocator (e.g. 'v8') over time. - */ - function buildGlobalAllocatedMemoryChartSeries(globalMemoryDumps) { - return buildAllocatedMemoryChartSeries(globalMemoryDumps, - getGlobalMemoryDumpAllocatorSizes); - } - - return { - buildMemoryLetterDots: - buildMemoryLetterDots, - buildGlobalUsedMemoryChartSeries: - buildGlobalUsedMemoryChartSeries, - buildProcessAllocatedMemoryChartSeries: - buildProcessAllocatedMemoryChartSeries, - buildGlobalAllocatedMemoryChartSeries: - buildGlobalAllocatedMemoryChartSeries - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/memory_dump_track_util_test.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/memory_dump_track_util_test.html deleted file mode 100644 index 58e46078245..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/memory_dump_track_util_test.html +++ /dev/null @@ -1,228 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/selection_state.html"> -<link rel="import" href="/tracing/ui/tracks/memory_dump_track_test_utils.html"> -<link rel="import" href="/tracing/ui/tracks/memory_dump_track_util.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var SelectionState = tr.model.SelectionState; - var createTestGlobalMemoryDumps = tr.ui.tracks.createTestGlobalMemoryDumps; - var createTestProcessMemoryDumps = tr.ui.tracks.createTestProcessMemoryDumps; - - test('buildMemoryLetterDots_withoutVMRegions', function() { - var dumps = createTestGlobalMemoryDumps(false, false); - var items = tr.ui.tracks.buildMemoryLetterDots(dumps); - - assert.lengthOf(items, 4); - assert.equal(items[0].start, 0); - assert.equal(items[1].start, 5); - assert.equal(items[2].start, 15); - assert.equal(items[3].start, 18); - - // Check model mapping. - assert.equal(items[1].selectionState, SelectionState.HIGHLIGHTED); - assert.isTrue(items[2].selected); - assert.equal(items[3].modelItem, dumps[3]); - }); - - test('buildMemoryLetterDots_withVMRegions', function() { - var dumps = createTestGlobalMemoryDumps(false, false); - var items = tr.ui.tracks.buildMemoryLetterDots(dumps); - - assert.lengthOf(items, 4); - assert.equal(items[0].start, 0); - assert.equal(items[1].start, 5); - assert.equal(items[2].start, 15); - assert.equal(items[3].start, 18); - - // Check model mapping. - assert.equal(items[1].selectionState, SelectionState.HIGHLIGHTED); - assert.isTrue(items[2].selected); - assert.equal(items[3].modelItem, dumps[3]); - }); - - test('buildGlobalUsedMemoryChartSeries_withoutVMRegions', function() { - var dumps = createTestGlobalMemoryDumps(false, false); - var series = tr.ui.tracks.buildGlobalUsedMemoryChartSeries(dumps); - - assert.isUndefined(series); - }); - - test('buildGlobalUsedMemoryChartSeries_withVMRegions', function() { - var dumps = createTestGlobalMemoryDumps(true, false); - var series = tr.ui.tracks.buildGlobalUsedMemoryChartSeries(dumps); - - assert.lengthOf(series, 3); - - var sa = series[2]; - var sb = series[1]; - var sc = series[0]; - - assert.lengthOf(sa.points, 4); - assert.lengthOf(sb.points, 4); - assert.lengthOf(sc.points, 4); - - // Process A: VM regions defined -> sum their PSS values (111). - // Process B: VM regions undefined and no previous value -> assume zero. - // Process C: Memory dump not present -> assume process not alive (0). - assert.equal(sa.points[0].x, 0); - assert.equal(sb.points[0].x, 0); - assert.equal(sc.points[0].x, 0); - assert.equal(sa.points[0].y, 111); - assert.equal(sb.points[0].y, 111); - assert.equal(sc.points[0].y, 111); - assert.equal(sa.points[0].yBase, 0); - assert.equal(sb.points[0].yBase, 111); - assert.equal(sc.points[0].yBase, 111); - - // Process A: VM regions undefined -> assume previous value (111). - // Process B: VM regions defined -> sum their PSS values (555). - // Process C: VM regions undefined -> assume previous value (0). - assert.equal(sa.points[1].x, 5); - assert.equal(sb.points[1].x, 5); - assert.equal(sc.points[1].x, 5); - assert.equal(sa.points[1].y, 111); - assert.equal(sb.points[1].y, 261); - assert.equal(sc.points[1].y, 261); - assert.equal(sa.points[1].yBase, 0); - assert.equal(sb.points[1].yBase, 111); - assert.equal(sc.points[1].yBase, 261); - - // Process A: VM regions defined -> sum their PSS values (0). - // Process B: Memory dump not present -> assume process not alive (0). - // Process C: VM regions defined -> sum their PSS values (999). - assert.equal(sa.points[2].x, 15); - assert.equal(sb.points[2].x, 15); - assert.equal(sc.points[2].x, 15); - assert.equal(sa.points[2].y, 0); - assert.equal(sb.points[2].y, 0); - assert.equal(sc.points[2].y, 210); - assert.equal(sa.points[2].yBase, 0); - assert.equal(sb.points[2].yBase, 0); - assert.equal(sc.points[2].yBase, 0); - - // All processes: Memory dump not present -> assume process not alive (0). - assert.equal(sa.points[3].x, 18); - assert.equal(sb.points[3].x, 18); - assert.equal(sc.points[3].x, 18); - assert.equal(sa.points[3].y, 0); - assert.equal(sb.points[3].y, 0); - assert.equal(sc.points[3].y, 0); - assert.equal(sc.points[3].yBase, 0); - assert.equal(sc.points[3].yBase, 0); - assert.equal(sc.points[3].yBase, 0); - - // Check model mapping. - assert.equal(sa.points[1].selectionState, SelectionState.HIGHLIGHTED); - assert.isTrue(sb.points[2].selected); - assert.equal(sc.points[3].modelItem, dumps[3]); - }); - - test('buildGlobalAllocatedMemoryChartSeries_withoutMemoryAllocatorDumps', - function() { - var dumps = createTestGlobalMemoryDumps(false, false); - var series = tr.ui.tracks.buildGlobalAllocatedMemoryChartSeries(dumps); - - assert.isUndefined(series); - }); - - test('buildGlobalAllocatedMemoryChartSeries_withMemoryAllocatorDumps', - function() { - var dumps = createTestGlobalMemoryDumps(false, true); - var series = tr.ui.tracks.buildGlobalAllocatedMemoryChartSeries(dumps); - - assert.lengthOf(series, 2); - - var so = series[0]; - var sv = series[1]; - - assert.lengthOf(so.points, 4); - assert.lengthOf(sv.points, 4); - - // Oilpan: Only process B dumps allocated objects size (1024). - // V8: No process dumps allocated objects size (0). - assert.equal(so.points[0].x, 0); - assert.equal(sv.points[0].x, 0); - assert.equal(so.points[0].y, 1024); - assert.equal(sv.points[0].y, 0); - - // Oilpan: Process B did not provide a value and process C dumps (128). - // V8: Processes B and C dump (512 + 256). - assert.equal(so.points[1].x, 5); - assert.equal(sv.points[1].x, 5); - assert.equal(so.points[1].y, 128); - assert.equal(sv.points[1].y, 768); - - // Oilpan: Process B assumed not alive and process C dumps (512) - // V8: Process A dumps now, process B assumed not alive, process C did not - // provide a value (768). - assert.equal(so.points[2].x, 15); - assert.equal(sv.points[2].x, 15); - assert.equal(so.points[2].y, 512); - assert.equal(sv.points[2].y, 768); - - // All processes: Memory dump not present -> assume process not alive (0). - assert.equal(so.points[3].x, 18); - assert.equal(sv.points[3].x, 18); - assert.equal(so.points[3].y, 0); - assert.equal(sv.points[3].y, 0); - - // Check model mapping. - assert.equal(so.points[1].selectionState, SelectionState.HIGHLIGHTED); - assert.isTrue(sv.points[2].selected); - assert.equal(so.points[3].modelItem, dumps[3]); - }); - - test('buildProcessAllocatedMemoryChartSeries_withoutMemoryAllocatorDumps', - function() { - var dumps = createTestProcessMemoryDumps(false, false); - var series = tr.ui.tracks.buildProcessAllocatedMemoryChartSeries(dumps); - - assert.isUndefined(series); - }); - - test('buildProcessAllocatedMemoryChartSeries_withMemoryAllocatorDumps', - function() { - var dumps = createTestProcessMemoryDumps(false, true); - var series = tr.ui.tracks.buildProcessAllocatedMemoryChartSeries(dumps); - - // There should be only 2 series (because 'tracing' is not shown in the - // charts). - assert.lengthOf(series, 2); - - var so = series[0]; - var sv = series[1]; - - assert.lengthOf(so.points, 2); - assert.lengthOf(sv.points, 2); - - // Oilpan: Process dumps (128). - // V8: Process dumps (256). - assert.equal(so.points[0].x, 5.12); - assert.equal(sv.points[0].x, 5.12); - assert.equal(so.points[0].y, 128); - assert.equal(sv.points[0].y, 256); - - // Oilpan: Process dumps (512). - // V8: Process did not provide a value (0). - assert.equal(so.points[1].x, 14.5); - assert.equal(sv.points[1].x, 14.5); - assert.equal(so.points[1].y, 512); - assert.equal(sv.points[1].y, 0); - - // Check model mapping. - assert.equal(so.points[1].selectionState, SelectionState.HIGHLIGHTED); - assert.isTrue(sv.points[0].selected); - assert.equal(so.points[1].modelItem, dumps[1]); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/model_track.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/model_track.html deleted file mode 100644 index 29e8b94c85e..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/model_track.html +++ /dev/null @@ -1,432 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/base/draw_helpers.html"> -<link rel="import" href="/tracing/ui/base/ui.html"> -<link rel="import" href="/tracing/ui/tracks/alert_track.html"> -<link rel="import" href="/tracing/ui/tracks/container_track.html"> -<link rel="import" href="/tracing/ui/tracks/cpu_usage_track.html"> -<link rel="import" href="/tracing/ui/tracks/device_track.html"> -<link rel="import" href="/tracing/ui/tracks/global_memory_dump_track.html"> -<link rel="import" href="/tracing/ui/tracks/highlighter.html"> -<link rel="import" href="/tracing/ui/tracks/interaction_track.html"> -<link rel="import" href="/tracing/ui/tracks/kernel_track.html"> -<link rel="import" href="/tracing/ui/tracks/process_track.html"> - -<style> -.model-track { - -webkit-box-flex: 1; -} -</style> - -<script> -'use strict'; - -tr.exportTo('tr.ui.tracks', function() { - var SelectionState = tr.model.SelectionState; - var EventPresenter = tr.ui.b.EventPresenter; - - /** - * Visualizes a Model by building ProcessTracks and CpuTracks. - * @constructor - */ - var ModelTrack = tr.ui.b.define('model-track', tr.ui.tracks.ContainerTrack); - - - ModelTrack.prototype = { - - __proto__: tr.ui.tracks.ContainerTrack.prototype, - - decorate: function(viewport) { - tr.ui.tracks.ContainerTrack.prototype.decorate.call(this, viewport); - this.classList.add('model-track'); - - var typeInfos = tr.ui.tracks.Highlighter.getAllRegisteredTypeInfos(); - this.highlighters_ = typeInfos.map( - function(typeInfo) { - return new typeInfo.constructor(viewport); - }); - - this.upperMode_ = false; - this.annotationViews_ = []; - }, - - // upperMode is true if the track is being used on the ruler. - get upperMode() { - return this.upperMode_; - }, - - set upperMode(upperMode) { - this.upperMode_ = upperMode; - this.updateContents_(); - }, - - detach: function() { - tr.ui.tracks.ContainerTrack.prototype.detach.call(this); - }, - - get model() { - return this.model_; - }, - - set model(model) { - this.model_ = model; - this.updateContents_(); - - this.model_.addEventListener('annotationChange', - this.updateAnnotations_.bind(this)); - }, - - get hasVisibleContent() { - return this.children.length > 0; - }, - - updateContents_: function() { - this.textContent = ''; - if (!this.model_) - return; - - if (this.upperMode_) - this.updateContentsForUpperMode_(); - else - this.updateContentsForLowerMode_(); - }, - - updateContentsForUpperMode_: function() { - }, - - updateContentsForLowerMode_: function() { - if (this.model_.userModel.expectations.length) { - var mrt = new tr.ui.tracks.InteractionTrack(this.viewport_); - mrt.model = this.model_; - this.appendChild(mrt); - } - - if (this.model_.alerts.length) { - var at = new tr.ui.tracks.AlertTrack(this.viewport_); - at.alerts = this.model_.alerts; - this.appendChild(at); - } - - if (this.model_.globalMemoryDumps.length) { - var gmdt = new tr.ui.tracks.GlobalMemoryDumpTrack(this.viewport_); - gmdt.memoryDumps = this.model_.globalMemoryDumps; - this.appendChild(gmdt); - } - - this.appendDeviceTrack_(); - this.appendCpuUsageTrack_(); - this.appendKernelTrack_(); - - // Get a sorted list of processes. - var processes = this.model_.getAllProcesses(); - processes.sort(tr.model.Process.compare); - - for (var i = 0; i < processes.length; ++i) { - var process = processes[i]; - - var track = new tr.ui.tracks.ProcessTrack(this.viewport); - track.process = process; - if (!track.hasVisibleContent) - continue; - - this.appendChild(track); - } - this.viewport_.rebuildEventToTrackMap(); - this.viewport_.rebuildContainerToTrackMap(); - - for (var i = 0; i < this.highlighters_.length; i++) { - this.highlighters_[i].processModel(this.model_); - } - - this.updateAnnotations_(); - }, - - updateAnnotations_: function() { - this.annotationViews_ = []; - var annotations = this.model_.getAllAnnotations(); - for (var i = 0; i < annotations.length; i++) { - this.annotationViews_.push( - annotations[i].getOrCreateView(this.viewport_)); - } - this.invalidateDrawingContainer(); - }, - - addEventsToTrackMap: function(eventToTrackMap) { - if (!this.model_) - return; - - var tracks = this.children; - for (var i = 0; i < tracks.length; ++i) - tracks[i].addEventsToTrackMap(eventToTrackMap); - - if (this.instantEvents === undefined) - return; - - var vp = this.viewport_; - this.instantEvents.forEach(function(ev) { - eventToTrackMap.addEvent(ev, this); - }.bind(this)); - }, - - appendDeviceTrack_: function() { - var device = this.model.device; - var track = new tr.ui.tracks.DeviceTrack(this.viewport); - track.device = this.model.device; - if (!track.hasVisibleContent) - return; - this.appendChild(track); - }, - - appendKernelTrack_: function() { - var kernel = this.model.kernel; - var track = new tr.ui.tracks.KernelTrack(this.viewport); - track.kernel = this.model.kernel; - if (!track.hasVisibleContent) - return; - this.appendChild(track); - }, - - appendCpuUsageTrack_: function() { - var track = new tr.ui.tracks.CpuUsageTrack(this.viewport); - track.initialize(this.model); - if (!track.hasVisibleContent) - return; - this.appendChild(track); - }, - - drawTrack: function(type) { - var ctx = this.context(); - if (!this.model_) - return; - - var pixelRatio = window.devicePixelRatio || 1; - var bounds = this.getBoundingClientRect(); - var canvasBounds = ctx.canvas.getBoundingClientRect(); - - ctx.save(); - ctx.translate(0, pixelRatio * (bounds.top - canvasBounds.top)); - - var dt = this.viewport.currentDisplayTransform; - var viewLWorld = dt.xViewToWorld(0); - var viewRWorld = dt.xViewToWorld(bounds.width * pixelRatio); - - switch (type) { - case tr.ui.tracks.DrawType.GRID: - this.viewport.drawMajorMarkLines(ctx); - // The model is the only thing that draws grid lines. - ctx.restore(); - return; - - case tr.ui.tracks.DrawType.FLOW_ARROWS: - if (this.model_.flowIntervalTree.size === 0) { - ctx.restore(); - return; - } - - this.drawFlowArrows_(viewLWorld, viewRWorld); - ctx.restore(); - return; - - case tr.ui.tracks.DrawType.INSTANT_EVENT: - if (!this.model_.instantEvents || - this.model_.instantEvents.length === 0) - break; - - tr.ui.b.drawInstantSlicesAsLines( - ctx, - this.viewport.currentDisplayTransform, - viewLWorld, - viewRWorld, - bounds.height, - this.model_.instantEvents, - 4); - - break; - - case tr.ui.tracks.DrawType.MARKERS: - if (!this.viewport.interestRange.isEmpty) { - this.viewport.interestRange.draw(ctx, viewLWorld, viewRWorld); - this.viewport.interestRange.drawIndicators( - ctx, viewLWorld, viewRWorld); - } - ctx.restore(); - return; - - case tr.ui.tracks.DrawType.HIGHLIGHTS: - for (var i = 0; i < this.highlighters_.length; i++) { - this.highlighters_[i].drawHighlight(ctx, dt, viewLWorld, viewRWorld, - bounds.height); - } - ctx.restore(); - return; - - case tr.ui.tracks.DrawType.ANNOTATIONS: - for (var i = 0; i < this.annotationViews_.length; i++) { - this.annotationViews_[i].draw(ctx); - } - ctx.restore(); - return; - } - ctx.restore(); - - tr.ui.tracks.ContainerTrack.prototype.drawTrack.call(this, type); - }, - - drawFlowArrows_: function(viewLWorld, viewRWorld) { - var ctx = this.context(); - var dt = this.viewport.currentDisplayTransform; - dt.applyTransformToCanvas(ctx); - - var pixWidth = dt.xViewVectorToWorld(1); - - ctx.strokeStyle = 'rgba(0, 0, 0, 0.4)'; - ctx.fillStyle = 'rgba(0, 0, 0, 0.4)'; - ctx.lineWidth = pixWidth > 1.0 ? 1 : pixWidth; - - var events = - this.model_.flowIntervalTree.findIntersection(viewLWorld, viewRWorld); - - // When not showing flow events, show only highlighted/selected ones. - var onlyHighlighted = !this.viewport.showFlowEvents; - var canvasBounds = ctx.canvas.getBoundingClientRect(); - for (var i = 0; i < events.length; ++i) { - if (onlyHighlighted && - events[i].selectionState !== SelectionState.SELECTED && - events[i].selectionState !== SelectionState.HIGHLIGHTED) - continue; - this.drawFlowArrow_(ctx, events[i], canvasBounds, pixWidth); - } - }, - - drawFlowArrow_: function(ctx, flowEvent, - canvasBounds, pixWidth) { - var pixelRatio = window.devicePixelRatio || 1; - - var startTrack = this.viewport.trackForEvent(flowEvent.startSlice); - var endTrack = this.viewport.trackForEvent(flowEvent.endSlice); - - // TODO(nduca): Figure out how to draw flow arrows even when - // processes are collapsed, bug #931. - if (startTrack === undefined || endTrack === undefined) - return; - - var startBounds = startTrack.getBoundingClientRect(); - var endBounds = endTrack.getBoundingClientRect(); - - if (flowEvent.selectionState == SelectionState.SELECTED) { - ctx.shadowBlur = 1; - ctx.shadowColor = 'red'; - ctx.shadowOffsety = 2; - ctx.strokeStyle = 'red'; - } else if (flowEvent.selectionState == SelectionState.HIGHLIGHTED) { - ctx.shadowBlur = 1; - ctx.shadowColor = 'red'; - ctx.shadowOffsety = 2; - ctx.strokeStyle = 'red'; - } else if (flowEvent.selectionState == SelectionState.DIMMED) { - ctx.shadowBlur = 0; - ctx.shadowOffsetX = 0; - ctx.strokeStyle = 'rgba(0, 0, 0, 0.2)'; - } else { - var hasBoost = false; - var startSlice = flowEvent.startSlice; - hasBoost |= startSlice.selectionState === SelectionState.SELECTED; - hasBoost |= startSlice.selectionState === SelectionState.HIGHLIGHTED; - var endSlice = flowEvent.endSlice; - hasBoost |= endSlice.selectionState === SelectionState.SELECTED; - hasBoost |= endSlice.selectionState === SelectionState.HIGHLIGHTED; - if (hasBoost) { - ctx.shadowBlur = 1; - ctx.shadowColor = 'rgba(255, 0, 0, 0.4)'; - ctx.shadowOffsety = 2; - ctx.strokeStyle = 'rgba(255, 0, 0, 0.4)'; - } else { - ctx.shadowBlur = 0; - ctx.shadowOffsetX = 0; - ctx.strokeStyle = 'rgba(0, 0, 0, 0.4)'; - } - } - - var startSize = startBounds.left + startBounds.top + - startBounds.bottom + startBounds.right; - var endSize = endBounds.left + endBounds.top + - endBounds.bottom + endBounds.right; - // Nothing to do if both ends of the track are collapsed. - if (startSize === 0 && endSize === 0) - return; - - var startY = this.calculateTrackY_(startTrack, canvasBounds); - var endY = this.calculateTrackY_(endTrack, canvasBounds); - - var pixelStartY = pixelRatio * startY; - var pixelEndY = pixelRatio * endY; - var half = (flowEvent.end - flowEvent.start) / 2; - - ctx.beginPath(); - ctx.moveTo(flowEvent.start, pixelStartY); - ctx.bezierCurveTo( - flowEvent.start + half, pixelStartY, - flowEvent.start + half, pixelEndY, - flowEvent.end, pixelEndY); - ctx.stroke(); - - var arrowWidth = 5 * pixWidth * pixelRatio; - var distance = flowEvent.end - flowEvent.start; - if (distance <= (2 * arrowWidth)) - return; - - var tipX = flowEvent.end; - var tipY = pixelEndY; - var arrowHeight = (endBounds.height / 4) * pixelRatio; - tr.ui.b.drawTriangle(ctx, - tipX, tipY, - tipX - arrowWidth, tipY - arrowHeight, - tipX - arrowWidth, tipY + arrowHeight); - ctx.fill(); - }, - - calculateTrackY_: function(track, canvasBounds) { - var bounds = track.getBoundingClientRect(); - var size = bounds.left + bounds.top + bounds.bottom + bounds.right; - if (size === 0) - return this.calculateTrackY_(track.parentNode, canvasBounds); - - return bounds.top - canvasBounds.top + (bounds.height / 2); - }, - - addIntersectingEventsInRangeToSelectionInWorldSpace: function( - loWX, hiWX, viewPixWidthWorld, selection) { - function onPickHit(instantEvent) { - selection.push(instantEvent); - } - var instantEventWidth = 3 * viewPixWidthWorld; - tr.b.iterateOverIntersectingIntervals(this.model_.instantEvents, - function(x) { return x.start; }, - function(x) { return x.duration + instantEventWidth; }, - loWX, hiWX, - onPickHit.bind(this)); - - tr.ui.tracks.ContainerTrack.prototype. - addIntersectingEventsInRangeToSelectionInWorldSpace. - apply(this, arguments); - }, - - addClosestEventToSelection: function(worldX, worldMaxDist, loY, hiY, - selection) { - this.addClosestInstantEventToSelection(this.model_.instantEvents, - worldX, worldMaxDist, selection); - tr.ui.tracks.ContainerTrack.prototype.addClosestEventToSelection. - apply(this, arguments); - } - }; - - return { - ModelTrack: ModelTrack - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/multi_row_track.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/multi_row_track.html deleted file mode 100644 index 04637ef2d2a..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/multi_row_track.html +++ /dev/null @@ -1,218 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/tracks/container_track.html"> -<link rel="import" href="/tracing/base/sorted_array_utils.html"> -<link rel="import" href="/tracing/model/model_settings.html"> -<link rel="import" href="/tracing/ui/base/ui.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.tracks', function() { - /** - * A track that displays a group of objects in multiple rows. - * @constructor - * @extends {ContainerTrack} - */ - var MultiRowTrack = tr.ui.b.define( - 'multi-row-track', tr.ui.tracks.ContainerTrack); - - MultiRowTrack.prototype = { - - __proto__: tr.ui.tracks.ContainerTrack.prototype, - - decorate: function(viewport) { - tr.ui.tracks.ContainerTrack.prototype.decorate.call(this, viewport); - this.tooltip_ = ''; - this.heading_ = ''; - - this.groupingSource_ = undefined; - this.itemsToGroup_ = undefined; - - this.defaultToCollapsedWhenSubRowCountMoreThan = 1; - - this.itemsGroupedOnLastUpdateContents_ = undefined; - - this.currentSubRows_ = []; - this.expanded_ = true; - }, - - get itemsToGroup() { - return this.itemsToGroup_; - }, - - setItemsToGroup: function(itemsToGroup, opt_groupingSource) { - this.itemsToGroup_ = itemsToGroup; - this.groupingSource_ = opt_groupingSource; - this.updateContents_(); - this.updateExpandedStateFromGroupingSource_(); - }, - - get heading() { - return this.heading_; - }, - - set heading(h) { - this.heading_ = h; - this.updateContents_(); - }, - - get tooltip() { - return this.tooltip_; - }, - - set tooltip(t) { - this.tooltip_ = t; - this.updateContents_(); - }, - - get subRows() { - return this.currentSubRows_; - }, - - get hasVisibleContent() { - return this.children.length > 0; - }, - - get expanded() { - return this.expanded_; - }, - - set expanded(expanded) { - if (this.expanded_ == expanded) - return; - this.expanded_ = expanded; - this.expandedStateChanged_(); - }, - - onHeadingClicked_: function(e) { - if (this.subRows.length <= 1) - return; - this.expanded = !this.expanded; - - if (this.groupingSource_) { - var modelSettings = new tr.model.ModelSettings( - this.groupingSource_.model); - modelSettings.setSettingFor(this.groupingSource_, 'expanded', - this.expanded); - } - - e.stopPropagation(); - }, - - updateExpandedStateFromGroupingSource_: function() { - if (this.groupingSource_) { - var numSubRows = this.subRows.length; - var modelSettings = new tr.model.ModelSettings( - this.groupingSource_.model); - if (numSubRows > 1) { - var defaultExpanded; - if (numSubRows > this.defaultToCollapsedWhenSubRowCountMoreThan) { - defaultExpanded = false; - } else { - defaultExpanded = true; - } - this.expanded = modelSettings.getSettingFor( - this.groupingSource_, 'expanded', defaultExpanded); - } else { - this.expanded = undefined; - } - } - }, - - expandedStateChanged_: function() { - var minH = Math.max(2, Math.ceil(18 / this.children.length)); - var h = (this.expanded_ ? 18 : minH) + 'px'; - - for (var i = 0; i < this.children.length; i++) { - this.children[i].height = h; - if (i === 0) - this.children[i].arrowVisible = true; - this.children[i].expanded = this.expanded; - } - - if (this.children.length === 1) { - this.children[0].expanded = true; - this.children[0].arrowVisible = false; - } - }, - - updateContents_: function() { - tr.ui.tracks.ContainerTrack.prototype.updateContents_.call(this); - if (!this.itemsToGroup_) { - this.updateHeadingAndTooltip_(); - this.currentSubRows_ = []; - return; - } - - if (this.areArrayContentsSame_(this.itemsGroupedOnLastUpdateContents_, - this.itemsToGroup_)) { - this.updateHeadingAndTooltip_(); - return; - } - - this.itemsGroupedOnLastUpdateContents_ = this.itemsToGroup_; - - this.detach(); - if (!this.itemsToGroup_.length) { - this.currentSubRows_ = []; - return; - } - var subRows = this.buildSubRows_(this.itemsToGroup_); - this.currentSubRows_ = subRows; - for (var srI = 0; srI < subRows.length; srI++) { - var subRow = subRows[srI]; - if (!subRow.length) - continue; - var track = this.addSubTrack_(subRow); - track.addEventListener( - 'heading-clicked', this.onHeadingClicked_.bind(this)); - } - this.updateHeadingAndTooltip_(); - this.expandedStateChanged_(); - }, - - updateHeadingAndTooltip_: function() { - if (!this.firstChild) - return; - this.firstChild.heading = this.heading_; - this.firstChild.tooltip = this.tooltip_; - }, - - /** - * Breaks up the list of slices into N rows, each of which is a list of - * slices that are non overlapping. - */ - buildSubRows_: function(itemsToGroup) { - throw new Error('Not implemented'); - }, - - addSubTrack_: function(subRowItems) { - throw new Error('Not implemented'); - }, - - areArrayContentsSame_: function(a, b) { - if (!a || !b) - return false; - if (!a.length || !b.length) - return false; - if (a.length != b.length) - return false; - for (var i = 0; i < a.length; ++i) { - if (a[i] != b[i]) - return false; - } - return true; - } - }; - - return { - MultiRowTrack: MultiRowTrack - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/object_instance_group_track.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/object_instance_group_track.html deleted file mode 100644 index 6bb39093015..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/object_instance_group_track.html +++ /dev/null @@ -1,87 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/analysis/object_snapshot_view.html"> -<link rel="import" href="/tracing/ui/analysis/object_instance_view.html"> -<link rel="import" href="/tracing/ui/tracks/multi_row_track.html"> -<link rel="import" href="/tracing/ui/tracks/object_instance_track.html"> -<link rel="import" href="/tracing/base/sorted_array_utils.html"> -<link rel="import" href="/tracing/ui/base/ui.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.tracks', function() { - /** - * A track that displays a ObjectInstanceGroup. - * @constructor - * @extends {ContainerTrack} - */ - var ObjectInstanceGroupTrack = tr.ui.b.define( - 'object-instance-group-track', tr.ui.tracks.MultiRowTrack); - - ObjectInstanceGroupTrack.prototype = { - - __proto__: tr.ui.tracks.MultiRowTrack.prototype, - - decorate: function(viewport) { - tr.ui.tracks.MultiRowTrack.prototype.decorate.call(this, viewport); - this.classList.add('object-instance-group-track'); - this.objectInstances_ = undefined; - }, - - get objectInstances() { - return this.itemsToGroup; - }, - - set objectInstances(objectInstances) { - this.setItemsToGroup(objectInstances); - }, - - addSubTrack_: function(objectInstances) { - var hasMultipleRows = this.subRows.length > 1; - var track = new tr.ui.tracks.ObjectInstanceTrack(this.viewport); - track.objectInstances = objectInstances; - this.appendChild(track); - return track; - }, - - buildSubRows_: function(objectInstances) { - objectInstances.sort(function(x, y) { - return x.creationTs - y.creationTs; - }); - - var subRows = []; - for (var i = 0; i < objectInstances.length; i++) { - var objectInstance = objectInstances[i]; - - var found = false; - for (var j = 0; j < subRows.length; j++) { - var subRow = subRows[j]; - var lastItemInSubRow = subRow[subRow.length - 1]; - if (objectInstance.creationTs >= lastItemInSubRow.deletionTs) { - found = true; - subRow.push(objectInstance); - break; - } - } - if (!found) { - var subRow = [objectInstance]; - subRows.push(subRow); - } - } - return subRows; - }, - updateHeadingAndTooltip_: function() { - } - }; - - return { - ObjectInstanceGroupTrack: ObjectInstanceGroupTrack - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/object_instance_track.css b/chromium/third_party/catapult/tracing/tracing/ui/tracks/object_instance_track.css deleted file mode 100644 index 0919e85524e..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/object_instance_track.css +++ /dev/null @@ -1,8 +0,0 @@ -/* Copyright (c) 2012 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -.object-instance-track { - height: 18px; -} diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/object_instance_track.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/object_instance_track.html deleted file mode 100644 index 4b6d3cacf11..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/object_instance_track.html +++ /dev/null @@ -1,299 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="stylesheet" href="/tracing/ui/tracks/object_instance_track.css"> - -<link rel="import" href="/tracing/base/extension_registry.html"> -<link rel="import" href="/tracing/base/sorted_array_utils.html"> -<link rel="import" href="/tracing/model/event.html"> -<link rel="import" href="/tracing/ui/base/event_presenter.html"> -<link rel="import" href="/tracing/ui/base/heading.html"> -<link rel="import" href="/tracing/ui/base/ui.html"> -<link rel="import" href="/tracing/ui/tracks/track.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.tracks', function() { - - var SelectionState = tr.model.SelectionState; - var EventPresenter = tr.ui.b.EventPresenter; - - /** - * A track that displays an array of Slice objects. - * @constructor - * @extends {Track} - */ - var ObjectInstanceTrack = tr.ui.b.define( - 'object-instance-track', tr.ui.tracks.Track); - - ObjectInstanceTrack.prototype = { - __proto__: tr.ui.tracks.Track.prototype, - - decorate: function(viewport) { - tr.ui.tracks.Track.prototype.decorate.call(this, viewport); - this.classList.add('object-instance-track'); - this.objectInstances_ = []; - this.objectSnapshots_ = []; - - this.heading_ = document.createElement('tr-ui-heading'); - this.appendChild(this.heading_); - }, - - set heading(heading) { - this.heading_.heading = heading; - }, - - get heading() { - return this.heading_.heading; - }, - - set tooltip(tooltip) { - this.heading_.tooltip = tooltip; - }, - - get objectInstances() { - return this.objectInstances_; - }, - - set objectInstances(objectInstances) { - if (!objectInstances || objectInstances.length == 0) { - this.heading = ''; - this.objectInstances_ = []; - this.objectSnapshots_ = []; - return; - } - this.heading = objectInstances[0].typeName; - this.objectInstances_ = objectInstances; - this.objectSnapshots_ = []; - this.objectInstances_.forEach(function(instance) { - this.objectSnapshots_.push.apply( - this.objectSnapshots_, instance.snapshots); - }, this); - this.objectSnapshots_.sort(function(a, b) { - return a.ts - b.ts; - }); - }, - - get height() { - return window.getComputedStyle(this).height; - }, - - set height(height) { - this.style.height = height; - }, - - get snapshotRadiusView() { - return 7 * (window.devicePixelRatio || 1); - }, - - draw: function(type, viewLWorld, viewRWorld) { - switch (type) { - case tr.ui.tracks.DrawType.GENERAL_EVENT: - this.drawLetterDots_(viewLWorld, viewRWorld); - break; - } - }, - - drawLetterDots_: function(viewLWorld, viewRWorld) { - var ctx = this.context(); - var pixelRatio = window.devicePixelRatio || 1; - - var bounds = this.getBoundingClientRect(); - var height = bounds.height * pixelRatio; - var halfHeight = height * 0.5; - var twoPi = Math.PI * 2; - - // Culling parameters. - var dt = this.viewport.currentDisplayTransform; - var snapshotRadiusView = this.snapshotRadiusView; - var snapshotRadiusWorld = dt.xViewVectorToWorld(height); - var loI; - - // Begin rendering in world space. - ctx.save(); - dt.applyTransformToCanvas(ctx); - - // Instances - var objectInstances = this.objectInstances_; - var loI = tr.b.findLowIndexInSortedArray( - objectInstances, - function(instance) { - return instance.deletionTs; - }, - viewLWorld); - ctx.strokeStyle = 'rgb(0,0,0)'; - for (var i = loI; i < objectInstances.length; ++i) { - var instance = objectInstances[i]; - var x = instance.creationTs; - if (x > viewRWorld) - break; - - var right = instance.deletionTs == Number.MAX_VALUE ? - viewRWorld : instance.deletionTs; - ctx.fillStyle = EventPresenter.getObjectInstanceColor(instance); - ctx.fillRect(x, pixelRatio, right - x, height - 2 * pixelRatio); - } - ctx.restore(); - - // Snapshots. Has to run in worldspace because ctx.arc gets transformed. - var objectSnapshots = this.objectSnapshots_; - loI = tr.b.findLowIndexInSortedArray( - objectSnapshots, - function(snapshot) { - return snapshot.ts + snapshotRadiusWorld; - }, - viewLWorld); - for (var i = loI; i < objectSnapshots.length; ++i) { - var snapshot = objectSnapshots[i]; - var x = snapshot.ts; - if (x - snapshotRadiusWorld > viewRWorld) - break; - var xView = dt.xWorldToView(x); - - ctx.fillStyle = EventPresenter.getObjectSnapshotColor(snapshot); - ctx.beginPath(); - ctx.arc(xView, halfHeight, snapshotRadiusView, 0, twoPi); - ctx.fill(); - if (snapshot.selected) { - ctx.lineWidth = 5; - ctx.strokeStyle = 'rgb(100,100,0)'; - ctx.stroke(); - - ctx.beginPath(); - ctx.arc(xView, halfHeight, snapshotRadiusView - 1, 0, twoPi); - ctx.lineWidth = 2; - ctx.strokeStyle = 'rgb(255,255,0)'; - ctx.stroke(); - } else { - ctx.lineWidth = 1; - ctx.strokeStyle = 'rgb(0,0,0)'; - ctx.stroke(); - } - } - ctx.lineWidth = 1; - - // For performance reasons we only check the SelectionState of the first - // instance. If it's DIMMED we assume that all are DIMMED. - // TODO(egraether): Allow partial highlight. - var selectionState = SelectionState.NONE; - if (objectInstances.length && - objectInstances[0].selectionState === SelectionState.DIMMED) { - selectionState = SelectionState.DIMMED; - } - - // Dim the track when there is an active highlight. - if (selectionState === SelectionState.DIMMED) { - var width = bounds.width * pixelRatio; - ctx.fillStyle = 'rgba(255,255,255,0.5)'; - ctx.fillRect(0, 0, width, height); - ctx.restore(); - } - }, - - addEventsToTrackMap: function(eventToTrackMap) { - if (this.objectInstance_ !== undefined) { - this.objectInstance_.forEach(function(obj) { - eventToTrackMap.addEvent(obj, this); - }, this); - } - - if (this.objectSnapshots_ !== undefined) { - this.objectSnapshots_.forEach(function(obj) { - eventToTrackMap.addEvent(obj, this); - }, this); - } - }, - - addIntersectingEventsInRangeToSelectionInWorldSpace: function( - loWX, hiWX, viewPixWidthWorld, selection) { - // Pick snapshots first. - var foundSnapshot = false; - function onSnapshot(snapshot) { - selection.push(snapshot); - foundSnapshot = true; - } - var snapshotRadiusView = this.snapshotRadiusView; - var snapshotRadiusWorld = viewPixWidthWorld * snapshotRadiusView; - tr.b.iterateOverIntersectingIntervals( - this.objectSnapshots_, - function(x) { return x.ts - snapshotRadiusWorld; }, - function(x) { return 2 * snapshotRadiusWorld; }, - loWX, hiWX, - onSnapshot); - if (foundSnapshot) - return; - - // Try picking instances. - tr.b.iterateOverIntersectingIntervals( - this.objectInstances_, - function(x) { return x.creationTs; }, - function(x) { return x.deletionTs - x.creationTs; }, - loWX, hiWX, - selection.push.bind(selection)); - }, - - /** - * Add the item to the left or right of the provided event, if any, to the - * selection. - * @param {event} The current event item. - * @param {Number} offset Number of slices away from the event to look. - * @param {Selection} selection The selection to add an event to, - * if found. - * @return {boolean} Whether an event was found. - * @private - */ - addEventNearToProvidedEventToSelection: function(event, offset, selection) { - var events; - if (event instanceof tr.model.ObjectSnapshot) - events = this.objectSnapshots_; - else if (event instanceof tr.model.ObjectInstance) - events = this.objectInstances_; - else - throw new Error('Unrecognized event'); - - var index = events.indexOf(event); - var newIndex = index + offset; - if (newIndex >= 0 && newIndex < events.length) { - selection.push(events[newIndex]); - return true; - } - return false; - }, - - addAllEventsMatchingFilterToSelection: function(filter, selection) { - }, - - addClosestEventToSelection: function(worldX, worldMaxDist, loY, hiY, - selection) { - var snapshot = tr.b.findClosestElementInSortedArray( - this.objectSnapshots_, - function(x) { return x.ts; }, - worldX, - worldMaxDist); - - if (!snapshot) - return; - - selection.push(snapshot); - - // TODO(egraether): Search for object instances as well, which was not - // implemented because it makes little sense with the current visual and - // needs to take care of overlapping intervals. - } - }; - - - var options = new tr.b.ExtensionRegistryOptions( - tr.b.TYPE_BASED_REGISTRY_MODE); - tr.b.decorateExtensionRegistry(ObjectInstanceTrack, options); - - return { - ObjectInstanceTrack: ObjectInstanceTrack - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/object_instance_track_test.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/object_instance_track_test.html deleted file mode 100644 index 1ba79b9db6c..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/object_instance_track_test.html +++ /dev/null @@ -1,111 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/iteration_helpers.html"> -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/model/object_collection.html"> -<link rel="import" href="/tracing/model/scoped_id.html"> -<link rel="import" href="/tracing/model/selection_state.html"> -<link rel="import" href="/tracing/ui/timeline_viewport.html"> -<link rel="import" href="/tracing/ui/tracks/drawing_container.html"> -<link rel="import" href="/tracing/ui/tracks/object_instance_track.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var EventSet = tr.model.EventSet; - var ObjectInstanceTrack = tr.ui.tracks.ObjectInstanceTrack; - var Viewport = tr.ui.TimelineViewport; - - var createObjects = function() { - var objects = new tr.model.ObjectCollection({}); - var scopedId1 = new tr.model.ScopedId('ptr', '0x1000'); - objects.idWasCreated(scopedId1, 'tr.e.cc', 'Frame', 10); - objects.addSnapshot(scopedId1, 'tr.e.cc', 'Frame', 10, 'snapshot-1'); - objects.addSnapshot(scopedId1, 'tr.e.cc', 'Frame', 25, 'snapshot-2'); - objects.addSnapshot(scopedId1, 'tr.e.cc', 'Frame', 40, 'snapshot-3'); - objects.idWasDeleted(scopedId1, 'tr.e.cc', 'Frame', 45); - - var scopedId2 = new tr.model.ScopedId('ptr', '0x1001'); - objects.idWasCreated(scopedId2, 'skia', 'Picture', 20); - objects.addSnapshot(scopedId2, 'skia', 'Picture', 20, 'snapshot-1'); - objects.idWasDeleted(scopedId2, 'skia', 'Picture', 25); - return objects; - }; - - test('instantiate', function() { - var objects = createObjects(); - var frames = objects.getAllInstancesByTypeName()['Frame']; - frames[0].snapshots[1].selectionState = - tr.model.SelectionState.SELECTED; - - var div = document.createElement('div'); - - var viewport = new Viewport(div); - var drawingContainer = new tr.ui.tracks.DrawingContainer(viewport); - div.appendChild(drawingContainer); - - var track = ObjectInstanceTrack(viewport); - drawingContainer.appendChild(track); - - this.addHTMLOutput(div); - drawingContainer.invalidate(); - - track.heading = 'testBasic'; - track.objectInstances = frames; - var dt = new tr.ui.TimelineDisplayTransform(); - dt.xSetWorldBounds(0, 50, track.clientWidth); - track.viewport.setDisplayTransformImmediately(dt); - }); - - test('selectionHitTestingWithThreadTrack', function() { - var objects = createObjects(); - var frames = objects.getAllInstancesByTypeName()['Frame']; - - var track = ObjectInstanceTrack(new Viewport()); - track.objectInstances = frames; - - // Hit outside range - var selection = new EventSet(); - track.addIntersectingEventsInRangeToSelectionInWorldSpace( - 8, 8.1, 0.1, selection); - assert.equal(selection.length, 0); - - // Hit the first snapshot, via pixel-nearness. - selection = new EventSet(); - track.addIntersectingEventsInRangeToSelectionInWorldSpace( - 9.98, 9.99, 0.1, selection); - assert.equal(selection.length, 1); - assert.instanceOf(tr.b.getOnlyElement(selection), tr.model.ObjectSnapshot); - - // Hit the instance, between the 1st and 2nd snapshots - selection = new EventSet(); - track.addIntersectingEventsInRangeToSelectionInWorldSpace( - 20, 20.1, 0.1, selection); - assert.equal(selection.length, 1); - assert.instanceOf(tr.b.getOnlyElement(selection), tr.model.ObjectInstance); - }); - - test('addEventNearToProvidedEventToSelection', function() { - var objects = createObjects(); - var frames = objects.getAllInstancesByTypeName()['Frame']; - - var track = ObjectInstanceTrack(new Viewport()); - track.objectInstances = frames; - - var instance = new tr.model.ObjectInstance( - {}, new tr.model.ScopedId('ptr', '0x1000'), 'cat', 'n', 10); - - assert.doesNotThrow(function() { - track.addEventNearToProvidedEventToSelection(instance, 0, undefined); - }); - }); -}); -</script> - diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/power_series_track.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/power_series_track.html deleted file mode 100644 index 5905882acff..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/power_series_track.html +++ /dev/null @@ -1,83 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/color_scheme.html"> -<link rel="import" href="/tracing/ui/base/ui.html"> -<link rel="import" href="/tracing/ui/tracks/chart_axis.html"> -<link rel="import" href="/tracing/ui/tracks/chart_point.html"> -<link rel="import" href="/tracing/ui/tracks/chart_series.html"> -<link rel="import" href="/tracing/ui/tracks/chart_track.html"> - -<style> -.power-series-track { - height: 90px; -} -</style> - -<script> -'use strict'; - -tr.exportTo('tr.ui.tracks', function() { - - var ColorScheme = tr.b.ColorScheme; - var ChartTrack = tr.ui.tracks.ChartTrack; - - /** - * A track that displays a PowerSeries. - * - * @constructor - * @extends {ChartTrack} - */ - var PowerSeriesTrack = tr.ui.b.define('power-series-track', ChartTrack); - - PowerSeriesTrack.prototype = { - __proto__: ChartTrack.prototype, - - decorate: function(viewport) { - ChartTrack.prototype.decorate.call(this, viewport); - this.classList.add('power-series-track'); - this.heading = 'Power'; - this.powerSeries_ = undefined; - }, - - set powerSeries(powerSeries) { - this.powerSeries_ = powerSeries; - - this.series = this.buildChartSeries_(); - this.autoSetAllAxes({expandMax: true}); - }, - - get hasVisibleContent() { - return (this.powerSeries_ && this.powerSeries_.samples.length > 0); - }, - - addContainersToTrackMap: function(containerToTrackMap) { - containerToTrackMap.addContainer(this.powerSeries_, this); - }, - - buildChartSeries_: function() { - if (!this.hasVisibleContent) - return []; - - var axis = new tr.ui.tracks.ChartAxis(0, undefined); - var pts = this.powerSeries_.samples.map(function(smpl) { - return new tr.ui.tracks.ChartPoint(smpl, smpl.start, smpl.power); - }); - var renderingConfig = { - chartType: tr.ui.tracks.ChartSeriesType.AREA, - colorId: ColorScheme.getColorIdForGeneralPurposeString(this.heading) - }; - - return [new tr.ui.tracks.ChartSeries(pts, axis, renderingConfig)]; - } - }; - - return { - PowerSeriesTrack: PowerSeriesTrack - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/power_series_track_test.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/power_series_track_test.html deleted file mode 100644 index 29997361918..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/power_series_track_test.html +++ /dev/null @@ -1,122 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel='import' href='/tracing/model/device.html'> -<link rel='import' href='/tracing/model/model.html'> -<link rel='import' href='/tracing/model/power_series.html'> -<link rel='import' href='/tracing/ui/base/constants.html'> -<link rel='import' href='/tracing/ui/timeline_viewport.html'> -<link rel='import' href='/tracing/ui/tracks/container_to_track_map.html'> -<link rel='import' href='/tracing/ui/tracks/drawing_container.html'> -<link rel="import" href="/tracing/ui/tracks/power_series_track.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - - var Device = tr.model.Device; - var Model = tr.Model; - var PowerSeries = tr.model.PowerSeries; - var PowerSeriesTrack = tr.ui.tracks.PowerSeriesTrack; - - var createDrawingContainer = function(series) { - var div = document.createElement('div'); - var viewport = new tr.ui.TimelineViewport(div); - var drawingContainer = new tr.ui.tracks.DrawingContainer(viewport); - div.appendChild(drawingContainer); - - if (series) { - series.updateBounds(); - setDisplayTransformFromBounds(viewport, series.bounds); - } - - return drawingContainer; - }; - - /** - * Sets the mapping between the input range of timestamps and the output range - * of horizontal pixels. - */ - var setDisplayTransformFromBounds = function(viewport, bounds) { - var dt = new tr.ui.TimelineDisplayTransform(); - var pixelRatio = window.devicePixelRatio || 1; - var chartPixelWidth = - (window.innerWidth - tr.ui.b.constants.HEADING_WIDTH) * pixelRatio; - dt.xSetWorldBounds(bounds.min, bounds.max, chartPixelWidth); - viewport.setDisplayTransformImmediately(dt); - }; - - test('instantiate', function() { - var series = new PowerSeries(new Model().device); - series.addPowerSample(0, 1); - series.addPowerSample(0.5, 2); - series.addPowerSample(1, 3); - series.addPowerSample(1.5, 4); - - var drawingContainer = createDrawingContainer(series); - var track = new PowerSeriesTrack(drawingContainer.viewport); - track.powerSeries = series; - drawingContainer.appendChild(track); - - this.addHTMLOutput(drawingContainer); - }); - - test('hasVisibleContent_trueWithPowerSamplesPresent', function() { - var series = new PowerSeries(new Model().device); - series.addPowerSample(0, 1); - series.addPowerSample(0.5, 2); - series.addPowerSample(1, 3); - series.addPowerSample(1.5, 4); - - var div = document.createElement('div'); - var viewport = new tr.ui.TimelineViewport(div); - - var track = new PowerSeriesTrack(viewport); - track.powerSeries = series; - - assert.isTrue(track.hasVisibleContent); - }); - - test('hasVisibleContent_falseWithUndefinedPowerSeries', function() { - var div = document.createElement('div'); - var viewport = new tr.ui.TimelineViewport(div); - - var track = new PowerSeriesTrack(viewport); - track.powerSeries = undefined; - - assert.notOk(track.hasVisibleContent); - }); - - test('hasVisibleContent_falseWithEmptyPowerSeries', function() { - var div = document.createElement('div'); - var viewport = new tr.ui.TimelineViewport(div); - - var track = new PowerSeriesTrack(viewport); - var series = new PowerSeries(new Model().device); - track.powerSeries = series; - - assert.notOk(track.hasVisibleContent); - }); - - test('addContainersToTrackMap', function() { - var div = document.createElement('div'); - var viewport = new tr.ui.TimelineViewport(div); - - var powerSeriesTrack = new PowerSeriesTrack(viewport); - var series = new PowerSeries(new Model().device); - powerSeriesTrack.powerSeries = series; - - var containerToTrackMap = new tr.ui.tracks.ContainerToTrackMap(); - powerSeriesTrack.addContainersToTrackMap(containerToTrackMap); - - assert.equal( - containerToTrackMap.getTrackByStableId('Device.PowerSeries'), - powerSeriesTrack); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/process_memory_dump_track.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/process_memory_dump_track.html deleted file mode 100644 index c197bd9d010..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/process_memory_dump_track.html +++ /dev/null @@ -1,73 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/tracks/chart_track.html"> -<link rel="import" href="/tracing/ui/tracks/container_track.html"> -<link rel="import" href="/tracing/ui/tracks/memory_dump_track_util.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.tracks', function() { - - var ALLOCATED_MEMORY_TRACK_HEIGHT = 50; - - /** - * A track that displays an array of ProcessMemoryDump objects. - * @constructor - * @extends {ContainerTrack} - */ - var ProcessMemoryDumpTrack = tr.ui.b.define( - 'process-memory-dump-track', tr.ui.tracks.ContainerTrack); - - ProcessMemoryDumpTrack.prototype = { - __proto__: tr.ui.tracks.ContainerTrack.prototype, - - decorate: function(viewport) { - tr.ui.tracks.ContainerTrack.prototype.decorate.call(this, viewport); - this.memoryDumps_ = undefined; - }, - - get memoryDumps() { - return this.memoryDumps_; - }, - - set memoryDumps(memoryDumps) { - this.memoryDumps_ = memoryDumps; - this.updateContents_(); - }, - - updateContents_: function() { - this.clearTracks_(); - - // Show no tracks if there are no dumps. - if (!this.memoryDumps_ || !this.memoryDumps_.length) - return; - - this.appendAllocatedMemoryTrack_(); - }, - - appendAllocatedMemoryTrack_: function() { - var series = tr.ui.tracks.buildProcessAllocatedMemoryChartSeries( - this.memoryDumps_); - if (!series) - return; - - var track = new tr.ui.tracks.ChartTrack(this.viewport); - track.heading = 'Memory per component'; - track.height = ALLOCATED_MEMORY_TRACK_HEIGHT + 'px'; - track.series = series; - track.autoSetAllAxes({expandMax: true}); - this.appendChild(track); - } - }; - - return { - ProcessMemoryDumpTrack: ProcessMemoryDumpTrack - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/process_memory_dump_track_test.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/process_memory_dump_track_test.html deleted file mode 100644 index a4515d50403..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/process_memory_dump_track_test.html +++ /dev/null @@ -1,55 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/ui/timeline_viewport.html"> -<link rel="import" href="/tracing/ui/tracks/drawing_container.html"> -<link rel="import" href="/tracing/ui/tracks/process_memory_dump_track.html"> -<link rel="import" href="/tracing/ui/tracks/memory_dump_track_test_utils.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var Viewport = tr.ui.TimelineViewport; - var ProcessMemoryDumpTrack = tr.ui.tracks.ProcessMemoryDumpTrack; - var createTestProcessMemoryDumps = tr.ui.tracks.createTestProcessMemoryDumps; - - function instantiateTrack(withVMRegions, withAllocatorDumps, - expectedTrackCount) { - var dumps = createTestProcessMemoryDumps(withVMRegions, withAllocatorDumps); - - var div = document.createElement('div'); - var viewport = new Viewport(div); - var drawingContainer = new tr.ui.tracks.DrawingContainer(viewport); - div.appendChild(drawingContainer); - - var track = new ProcessMemoryDumpTrack(viewport); - drawingContainer.appendChild(track); - drawingContainer.invalidate(); - - track.memoryDumps = dumps; - - // TODO(petrcermak): Check that the div has indeed zero size. - if (expectedTrackCount > 0) - this.addHTMLOutput(div); - - var dt = new tr.ui.TimelineDisplayTransform(); - dt.xSetWorldBounds(0, 50, track.clientWidth); - track.viewport.setDisplayTransformImmediately(dt); - - assert.lengthOf(track.tracks_, expectedTrackCount); - }; - - test('instantiate_withoutMemoryAllocatorDumps', function() { - instantiateTrack.call(this, false, false, 0); - }); - test('instantiate_withMemoryAllocatorDumps', function() { - instantiateTrack.call(this, false, true, 1); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/process_summary_track.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/process_summary_track.html deleted file mode 100644 index 4390766292d..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/process_summary_track.html +++ /dev/null @@ -1,130 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/color_scheme.html"> -<link rel="import" href="/tracing/ui/base/ui.html"> -<link rel="import" href="/tracing/ui/tracks/rect_track.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.tracks', function() { - var ColorScheme = tr.b.ColorScheme; - - /** - * Visualizes a Process's state using a series of rects to represent activity. - * @constructor - */ - var ProcessSummaryTrack = tr.ui.b.define('process-summary-track', - tr.ui.tracks.RectTrack); - - ProcessSummaryTrack.buildRectsFromProcess = function(process) { - if (!process) - return []; - - var ops = []; - // build list of start/end ops for each top level or important slice - var pushOp = function(isStart, time, slice) { - ops.push({ - isStart: isStart, - time: time, - slice: slice - }); - }; - for (var tid in process.threads) { - var sliceGroup = process.threads[tid].sliceGroup; - - sliceGroup.topLevelSlices.forEach(function(slice) { - pushOp(true, slice.start, undefined); - pushOp(false, slice.end, undefined); - }); - sliceGroup.slices.forEach(function(slice) { - if (slice.important) { - pushOp(true, slice.start, slice); - pushOp(false, slice.end, slice); - } - }); - } - ops.sort(function(a, b) { return a.time - b.time; }); - - var rects = []; - /** - * Build a row of rects which display one way for unimportant activity, - * and during important slices, show up as those important slices. - * - * If an important slice starts in the middle of another, - * just drop it on the floor. - */ - var genericColorId = ColorScheme.getColorIdForReservedName('generic_work'); - var pushRect = function(start, end, slice) { - rects.push(new tr.ui.tracks.Rect( - slice, /* modelItem: show selection state of slice if present */ - slice ? slice.title : '', /* title */ - slice ? slice.colorId : genericColorId, /* colorId */ - start, /* start */ - end - start /* duration */)); - } - var depth = 0; - var currentSlice = undefined; - var lastStart = undefined; - ops.forEach(function(op) { - depth += op.isStart ? 1 : -1; - - if (currentSlice) { - // simply find end of current important slice - if (!op.isStart && op.slice == currentSlice) { - // important slice has ended - pushRect(lastStart, op.time, currentSlice); - lastStart = depth >= 1 ? op.time : undefined; - currentSlice = undefined; - } - } else { - if (op.isStart) { - if (depth == 1) { - lastStart = op.time; - currentSlice = op.slice; - } else if (op.slice) { - // switch to slice - if (op.time != lastStart) { - pushRect(lastStart, op.time, undefined); - lastStart = op.time; - } - currentSlice = op.slice; - } - } else { - if (depth == 0) { - pushRect(lastStart, op.time, undefined); - lastStart = undefined; - } - } - } - }); - return rects; - }; - - ProcessSummaryTrack.prototype = { - __proto__: tr.ui.tracks.RectTrack.prototype, - - decorate: function(viewport) { - tr.ui.tracks.RectTrack.prototype.decorate.call(this, viewport); - }, - - get process() { - return this.process_; - }, - - set process(process) { - this.process_ = process; - this.rects = ProcessSummaryTrack.buildRectsFromProcess(process); - } - }; - - return { - ProcessSummaryTrack: ProcessSummaryTrack - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/process_summary_track_test.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/process_summary_track_test.html deleted file mode 100644 index 11a68527a2e..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/process_summary_track_test.html +++ /dev/null @@ -1,110 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/model/slice_group.html"> -<link rel="import" href="/tracing/ui/tracks/process_summary_track.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var ProcessSummaryTrack = tr.ui.tracks.ProcessSummaryTrack; - - test('buildRectSimple', function() { - var process; - var model = tr.c.TestUtils.newModel(function(model) { - process = model.getOrCreateProcess(1); - // XXXX - // XXXX - var thread1 = process.getOrCreateThread(1); - thread1.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx( - {start: 1, duration: 4})); - var thread2 = process.getOrCreateThread(2); - thread2.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx( - {start: 4, duration: 4})); - }); - - var rects = ProcessSummaryTrack.buildRectsFromProcess(process); - - assert.equal(rects.length, 1); - var rect = rects[0]; - assert.closeTo(rect.start, 1, 1e-5); - assert.closeTo(rect.end, 8, 1e-5); - }); - - test('buildRectComplex', function() { - var process; - var model = tr.c.TestUtils.newModel(function(model) { - process = model.getOrCreateProcess(1); - // XXXX X X XX - // XXXX XXX X - var thread1 = process.getOrCreateThread(1); - thread1.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx( - {start: 1, duration: 4})); - thread1.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx( - {start: 9, duration: 1})); - thread1.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx( - {start: 11, duration: 1})); - thread1.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx( - {start: 13, duration: 2})); - var thread2 = process.getOrCreateThread(2); - thread2.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx( - {start: 4, duration: 4})); - thread2.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx( - {start: 9, duration: 3})); - thread2.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx( - {start: 16, duration: 1})); - }); - - var rects = ProcessSummaryTrack.buildRectsFromProcess(process); - - assert.equal(4, rects.length); - assert.closeTo(rects[0].start, 1, 1e-5); - assert.closeTo(rects[0].end, 8, 1e-5); - assert.closeTo(rects[1].start, 9, 1e-5); - assert.closeTo(rects[1].end, 12, 1e-5); - assert.closeTo(rects[2].start, 13, 1e-5); - assert.closeTo(rects[2].end, 15, 1e-5); - assert.closeTo(rects[3].start, 16, 1e-5); - assert.closeTo(rects[3].end, 17, 1e-5); - }); - - test('buildRectImportantSlice', function() { - var process; - var model = tr.c.TestUtils.newModel(function(model) { - // [ unimportant ] - // [important] - var a = tr.c.TestUtils.newSliceEx( - {title: 'unimportant', start: 4, duration: 21}); - var b = tr.c.TestUtils.newSliceEx( - {title: 'important', start: 9, duration: 11}); - b.important = true; - process = model.getOrCreateProcess(1); - process.getOrCreateThread(1).sliceGroup.pushSlices([a, b]); - - model.importantSlice = b; - }); - - var rects = ProcessSummaryTrack.buildRectsFromProcess(process); - - assert.equal(3, rects.length); - assert.closeTo(rects[0].start, 4, 1e-5); - assert.closeTo(rects[0].end, 9, 1e-5); - assert.closeTo(rects[1].start, 9, 1e-5); - assert.closeTo(rects[1].end, 20, 1e-5); - assert.closeTo(rects[2].start, 20, 1e-5); - assert.closeTo(rects[2].end, 25, 1e-5); - - // middle rect represents important slice, so colorId & title are preserved - assert.equal(rects[1].title, model.importantSlice.title); - assert.equal(rects[1].colorId, model.importantSlice.colorId); - }); -}); -</script> - diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/process_track.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/process_track.html deleted file mode 100644 index 42451c042d9..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/process_track.html +++ /dev/null @@ -1,155 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/tracks/process_memory_dump_track.html"> -<link rel="import" href="/tracing/ui/tracks/process_track_base.html"> -<link rel="import" href="/tracing/ui/base/draw_helpers.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.tracks', function() { - var ProcessTrackBase = tr.ui.tracks.ProcessTrackBase; - - /** - * @constructor - */ - var ProcessTrack = tr.ui.b.define('process-track', ProcessTrackBase); - - ProcessTrack.prototype = { - __proto__: ProcessTrackBase.prototype, - - decorate: function(viewport) { - tr.ui.tracks.ProcessTrackBase.prototype.decorate.call(this, viewport); - }, - - drawTrack: function(type) { - switch (type) { - case tr.ui.tracks.DrawType.INSTANT_EVENT: - if (!this.processBase.instantEvents || - this.processBase.instantEvents.length === 0) - break; - - var ctx = this.context(); - - var pixelRatio = window.devicePixelRatio || 1; - var bounds = this.getBoundingClientRect(); - var canvasBounds = ctx.canvas.getBoundingClientRect(); - - ctx.save(); - ctx.translate(0, pixelRatio * (bounds.top - canvasBounds.top)); - - var dt = this.viewport.currentDisplayTransform; - var viewLWorld = dt.xViewToWorld(0); - var viewRWorld = dt.xViewToWorld( - bounds.width * pixelRatio); - - tr.ui.b.drawInstantSlicesAsLines( - ctx, - this.viewport.currentDisplayTransform, - viewLWorld, - viewRWorld, - bounds.height, - this.processBase.instantEvents, - 2); - - ctx.restore(); - - break; - - case tr.ui.tracks.DrawType.BACKGROUND: - this.drawBackground_(); - // Don't bother recursing further, Process is the only level that - // draws backgrounds. - return; - } - - tr.ui.tracks.ContainerTrack.prototype.drawTrack.call(this, type); - }, - - drawBackground_: function() { - var ctx = this.context(); - var canvasBounds = ctx.canvas.getBoundingClientRect(); - var pixelRatio = window.devicePixelRatio || 1; - - var draw = false; - ctx.fillStyle = '#eee'; - for (var i = 0; i < this.children.length; ++i) { - if (!(this.children[i] instanceof tr.ui.tracks.Track) || - (this.children[i] instanceof tr.ui.tracks.SpacingTrack)) - continue; - - draw = !draw; - if (!draw) - continue; - - var bounds = this.children[i].getBoundingClientRect(); - ctx.fillRect(0, pixelRatio * (bounds.top - canvasBounds.top), - ctx.canvas.width, pixelRatio * bounds.height); - } - }, - - // Process maps to processBase because we derive from ProcessTrackBase. - set process(process) { - this.processBase = process; - }, - - get process() { - return this.processBase; - }, - - get eventContainer() { - return this.process; - }, - - addContainersToTrackMap: function(containerToTrackMap) { - tr.ui.tracks.ProcessTrackBase.prototype.addContainersToTrackMap.apply( - this, arguments); - containerToTrackMap.addContainer(this.process, this); - }, - - appendMemoryDumpTrack_: function() { - var processMemoryDumps = this.process.memoryDumps; - if (processMemoryDumps.length) { - var pmdt = new tr.ui.tracks.ProcessMemoryDumpTrack(this.viewport_); - pmdt.memoryDumps = processMemoryDumps; - this.appendChild(pmdt); - } - }, - - addIntersectingEventsInRangeToSelectionInWorldSpace: function( - loWX, hiWX, viewPixWidthWorld, selection) { - function onPickHit(instantEvent) { - selection.push(instantEvent); - } - var instantEventWidth = 2 * viewPixWidthWorld; - tr.b.iterateOverIntersectingIntervals(this.processBase.instantEvents, - function(x) { return x.start; }, - function(x) { return x.duration + instantEventWidth; }, - loWX, hiWX, - onPickHit.bind(this)); - - tr.ui.tracks.ContainerTrack.prototype. - addIntersectingEventsInRangeToSelectionInWorldSpace. - apply(this, arguments); - }, - - addClosestEventToSelection: function(worldX, worldMaxDist, loY, hiY, - selection) { - this.addClosestInstantEventToSelection(this.processBase.instantEvents, - worldX, worldMaxDist, selection); - tr.ui.tracks.ContainerTrack.prototype.addClosestEventToSelection. - apply(this, arguments); - } - }; - - return { - ProcessTrack: ProcessTrack - }; -}); -</script> - diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/process_track_base.css b/chromium/third_party/catapult/tracing/tracing/ui/tracks/process_track_base.css deleted file mode 100644 index 5f42096bbff..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/process_track_base.css +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright (c) 2013 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -.process-track-header { - -webkit-flex: 0 0 auto; - background-image: -webkit-gradient(linear, - 0 0, 100% 0, - from(#E5E5E5), - to(#D1D1D1)); - border-bottom: 1px solid #8e8e8e; - border-top: 1px solid white; - font-size: 75%; -} - -.process-track-name:before { - content: '\25B8'; /* Right triangle */ - padding: 0 5px; -} - -.process-track-base.expanded .process-track-name:before { - content: '\25BE'; /* Down triangle */ -} diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/process_track_base.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/process_track_base.html deleted file mode 100644 index d96f1ce02cb..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/process_track_base.html +++ /dev/null @@ -1,273 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="stylesheet" href="/tracing/ui/tracks/process_track_base.css"> - -<link rel="import" href="/tracing/core/filter.html"> -<link rel="import" href="/tracing/model/model_settings.html"> -<link rel="import" href="/tracing/ui/base/dom_helpers.html"> -<link rel="import" href="/tracing/ui/base/ui.html"> -<link rel="import" href="/tracing/ui/tracks/container_track.html"> -<link rel="import" href="/tracing/ui/tracks/counter_track.html"> -<link rel="import" href="/tracing/ui/tracks/frame_track.html"> -<link rel="import" href="/tracing/ui/tracks/object_instance_group_track.html"> -<link rel="import" href="/tracing/ui/tracks/process_summary_track.html"> -<link rel="import" href="/tracing/ui/tracks/spacing_track.html"> -<link rel="import" href="/tracing/ui/tracks/thread_track.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.tracks', function() { - - var ObjectSnapshotView = tr.ui.analysis.ObjectSnapshotView; - var ObjectInstanceView = tr.ui.analysis.ObjectInstanceView; - var SpacingTrack = tr.ui.tracks.SpacingTrack; - - /** - * Visualizes a Process by building ThreadTracks and CounterTracks. - * @constructor - */ - var ProcessTrackBase = - tr.ui.b.define('process-track-base', tr.ui.tracks.ContainerTrack); - - ProcessTrackBase.prototype = { - - __proto__: tr.ui.tracks.ContainerTrack.prototype, - - decorate: function(viewport) { - tr.ui.tracks.ContainerTrack.prototype.decorate.call(this, viewport); - - this.processBase_ = undefined; - - this.classList.add('process-track-base'); - this.classList.add('expanded'); - - this.processNameEl_ = tr.ui.b.createSpan(); - this.processNameEl_.classList.add('process-track-name'); - - this.headerEl_ = tr.ui.b.createDiv({className: 'process-track-header'}); - this.headerEl_.appendChild(this.processNameEl_); - this.headerEl_.addEventListener('click', this.onHeaderClick_.bind(this)); - - this.appendChild(this.headerEl_); - }, - - get processBase() { - return this.processBase_; - }, - - set processBase(processBase) { - this.processBase_ = processBase; - - if (this.processBase_) { - var modelSettings = new tr.model.ModelSettings(this.processBase_.model); - var defaultValue = this.processBase_.important; - this.expanded = modelSettings.getSettingFor( - this.processBase_, 'expanded', defaultValue); - } - - this.updateContents_(); - }, - - get expanded() { - return this.classList.contains('expanded'); - }, - - set expanded(expanded) { - expanded = !!expanded; - - if (this.expanded === expanded) - return; - - this.classList.toggle('expanded'); - - // Expanding and collapsing tracks is, essentially, growing and shrinking - // the viewport. We dispatch a change event to trigger any processing - // to happen. - this.viewport_.dispatchChangeEvent(); - - if (!this.processBase_) - return; - - var modelSettings = new tr.model.ModelSettings(this.processBase_.model); - modelSettings.setSettingFor(this.processBase_, 'expanded', expanded); - this.updateContents_(); - this.viewport.rebuildEventToTrackMap(); - this.viewport.rebuildContainerToTrackMap(); - }, - - get hasVisibleContent() { - if (this.expanded) - return this.children.length > 1; - return true; - }, - - onHeaderClick_: function(e) { - e.stopPropagation(); - e.preventDefault(); - this.expanded = !this.expanded; - }, - - updateContents_: function() { - this.clearTracks_(); - - if (!this.processBase_) - return; - - this.processNameEl_.textContent = this.processBase_.userFriendlyName; - this.headerEl_.title = this.processBase_.userFriendlyDetails; - - // Create the object instance tracks for this process. - this.willAppendTracks_(); - if (this.expanded) { - this.appendMemoryDumpTrack_(); - this.appendObjectInstanceTracks_(); - this.appendCounterTracks_(); - this.appendFrameTrack_(); - this.appendThreadTracks_(); - } else { - this.appendSummaryTrack_(); - } - this.didAppendTracks_(); - }, - - addEventsToTrackMap: function(eventToTrackMap) { - this.tracks_.forEach(function(track) { - track.addEventsToTrackMap(eventToTrackMap); - }); - }, - - willAppendTracks_: function() { - }, - - didAppendTracks_: function() { - }, - - appendMemoryDumpTrack_: function() { - }, - - appendSummaryTrack_: function() { - var track = new tr.ui.tracks.ProcessSummaryTrack(this.viewport); - track.process = this.process; - if (!track.hasVisibleContent) - return; - this.appendChild(track); - // no spacing track, since this track only shown in collapsed state - }, - - appendFrameTrack_: function() { - var frames = this.process ? this.process.frames : undefined; - if (!frames || !frames.length) - return; - - var track = new tr.ui.tracks.FrameTrack(this.viewport); - track.frames = frames; - this.appendChild(track); - }, - - appendObjectInstanceTracks_: function() { - var instancesByTypeName = - this.processBase_.objects.getAllInstancesByTypeName(); - var instanceTypeNames = tr.b.dictionaryKeys(instancesByTypeName); - instanceTypeNames.sort(); - - var didAppendAtLeastOneTrack = false; - instanceTypeNames.forEach(function(typeName) { - var allInstances = instancesByTypeName[typeName]; - - // If a object snapshot has a view it will be shown, - // unless the view asked for it to not be shown. - var instanceViewInfo = ObjectInstanceView.getTypeInfo( - undefined, typeName); - var snapshotViewInfo = ObjectSnapshotView.getTypeInfo( - undefined, typeName); - if (instanceViewInfo && !instanceViewInfo.metadata.showInTrackView) - instanceViewInfo = undefined; - if (snapshotViewInfo && !snapshotViewInfo.metadata.showInTrackView) - snapshotViewInfo = undefined; - var hasViewInfo = instanceViewInfo || snapshotViewInfo; - - // There are some instances that don't merit their own track in - // the UI. Filter them out. - var visibleInstances = []; - for (var i = 0; i < allInstances.length; i++) { - var instance = allInstances[i]; - - // Do not create tracks for instances that have no snapshots. - if (instance.snapshots.length === 0) - continue; - - // Do not create tracks for instances that have implicit snapshots - // and don't have a view. - if (instance.hasImplicitSnapshots && !hasViewInfo) - continue; - - visibleInstances.push(instance); - } - if (visibleInstances.length === 0) - return; - - // Look up the constructor for this track, or use the default - // constructor if none exists. - var trackConstructor = - tr.ui.tracks.ObjectInstanceTrack.getConstructor( - undefined, typeName); - if (!trackConstructor) { - var snapshotViewInfo = ObjectSnapshotView.getTypeInfo( - undefined, typeName); - if (snapshotViewInfo && snapshotViewInfo.metadata.showInstances) { - trackConstructor = tr.ui.tracks.ObjectInstanceGroupTrack; - } else { - trackConstructor = tr.ui.tracks.ObjectInstanceTrack; - } - } - var track = new trackConstructor(this.viewport); - track.objectInstances = visibleInstances; - this.appendChild(track); - didAppendAtLeastOneTrack = true; - }, this); - if (didAppendAtLeastOneTrack) - this.appendChild(new SpacingTrack(this.viewport)); - }, - - appendCounterTracks_: function() { - // Add counter tracks for this process. - var counters = tr.b.dictionaryValues(this.processBase.counters); - counters.sort(tr.model.Counter.compare); - - // Create the counters for this process. - counters.forEach(function(counter) { - var track = new tr.ui.tracks.CounterTrack(this.viewport); - track.counter = counter; - this.appendChild(track); - this.appendChild(new SpacingTrack(this.viewport)); - }.bind(this)); - }, - - appendThreadTracks_: function() { - // Get a sorted list of threads. - var threads = tr.b.dictionaryValues(this.processBase.threads); - threads.sort(tr.model.Thread.compare); - - // Create the threads. - threads.forEach(function(thread) { - var track = new tr.ui.tracks.ThreadTrack(this.viewport); - track.thread = thread; - if (!track.hasVisibleContent) - return; - this.appendChild(track); - this.appendChild(new SpacingTrack(this.viewport)); - }.bind(this)); - } - }; - - return { - ProcessTrackBase: ProcessTrackBase - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/rect_track.css b/chromium/third_party/catapult/tracing/tracing/ui/tracks/rect_track.css deleted file mode 100644 index 0467c91562c..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/rect_track.css +++ /dev/null @@ -1,8 +0,0 @@ -/* Copyright (c) 2014 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -.rect-track { - height: 18px; -} diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/rect_track.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/rect_track.html deleted file mode 100644 index 70da91be408..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/rect_track.html +++ /dev/null @@ -1,251 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="stylesheet" href="/tracing/ui/tracks/rect_track.css"> - -<link rel="import" href="/tracing/base/sorted_array_utils.html"> -<link rel="import" href="/tracing/model/proxy_selectable_item.html"> -<link rel="import" href="/tracing/ui/base/draw_helpers.html"> -<link rel="import" href="/tracing/ui/base/fast_rect_renderer.html"> -<link rel="import" href="/tracing/ui/base/heading.html"> -<link rel="import" href="/tracing/ui/base/ui.html"> -<link rel="import" href="/tracing/ui/tracks/track.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.tracks', function() { - - /** - * A track that displays an array of Rect objects. - * @constructor - * @extends {Track} - */ - var RectTrack = tr.ui.b.define( - 'rect-track', tr.ui.tracks.Track); - - RectTrack.prototype = { - - __proto__: tr.ui.tracks.Track.prototype, - - decorate: function(viewport) { - tr.ui.tracks.Track.prototype.decorate.call(this, viewport); - this.classList.add('rect-track'); - this.asyncStyle_ = false; - this.rects_ = null; - - this.heading_ = document.createElement('tr-ui-heading'); - this.appendChild(this.heading_); - }, - - set heading(heading) { - this.heading_.heading = heading; - }, - - get heading() { - return this.heading_.heading; - }, - - set tooltip(tooltip) { - this.heading_.tooltip = tooltip; - }, - - set selectionGenerator(generator) { - this.heading_.selectionGenerator = generator; - }, - - set expanded(expanded) { - this.heading_.expanded = !!expanded; - }, - - set arrowVisible(arrowVisible) { - this.heading_.arrowVisible = !!arrowVisible; - }, - - get expanded() { - return this.heading_.expanded; - }, - - get asyncStyle() { - return this.asyncStyle_; - }, - - set asyncStyle(v) { - this.asyncStyle_ = !!v; - }, - - get rects() { - return this.rects_; - }, - - set rects(rects) { - this.rects_ = rects || []; - this.invalidateDrawingContainer(); - }, - - get height() { - return window.getComputedStyle(this).height; - }, - - set height(height) { - this.style.height = height; - this.invalidateDrawingContainer(); - }, - - get hasVisibleContent() { - return this.rects_.length > 0; - }, - - draw: function(type, viewLWorld, viewRWorld) { - switch (type) { - case tr.ui.tracks.DrawType.GENERAL_EVENT: - this.drawRects_(viewLWorld, viewRWorld); - break; - } - }, - - drawRects_: function(viewLWorld, viewRWorld) { - var ctx = this.context(); - - ctx.save(); - var bounds = this.getBoundingClientRect(); - tr.ui.b.drawSlices( - ctx, - this.viewport.currentDisplayTransform, - viewLWorld, - viewRWorld, - bounds.height, - this.rects_, - this.asyncStyle_); - ctx.restore(); - - if (bounds.height <= 6) - return; - - var fontSize, yOffset; - if (bounds.height < 15) { - fontSize = 6; - yOffset = 1.0; - } else { - fontSize = 10; - yOffset = 2.5; - } - tr.ui.b.drawLabels( - ctx, - this.viewport.currentDisplayTransform, - viewLWorld, - viewRWorld, - this.rects_, - this.asyncStyle_, - fontSize, - yOffset); - }, - - addEventsToTrackMap: function(eventToTrackMap) { - if (this.rects_ === undefined || this.rects_ === null) - return; - - this.rects_.forEach(function(rect) { - rect.addToTrackMap(eventToTrackMap, this); - }, this); - }, - - addIntersectingEventsInRangeToSelectionInWorldSpace: function( - loWX, hiWX, viewPixWidthWorld, selection) { - function onRect(rect) { - rect.addToSelection(selection); - } - onRect = onRect.bind(this); - var instantEventWidth = 2 * viewPixWidthWorld; - tr.b.iterateOverIntersectingIntervals(this.rects_, - function(x) { return x.start; }, - function(x) { return x.duration == 0 ? - x.duration + instantEventWidth : - x.duration; }, - loWX, hiWX, - onRect); - }, - - /** - * Add the item to the left or right of the provided event, if any, to the - * selection. - * @param {rect} The current rect. - * @param {Number} offset Number of rects away from the event to look. - * @param {Selection} selection The selection to add an event to, - * if found. - * @return {boolean} Whether an event was found. - * @private - */ - addEventNearToProvidedEventToSelection: function(event, offset, selection) { - var index = tr.b.findFirstIndexInArray(this.rects_, function(rect) { - return rect.modelItem === event; - }); - if (index === -1) - return false; - - var newIndex = index + offset; - if (newIndex < 0 || newIndex >= this.rects_.length) - return false; - - this.rects_[newIndex].addToSelection(selection); - return true; - }, - - addAllEventsMatchingFilterToSelection: function(filter, selection) { - for (var i = 0; i < this.rects_.length; ++i) { - // TODO(petrcermak): Rather than unpacking the proxy item here, - // we should probably add an addToSelectionIfMatching(selection, filter) - // method to SelectableItem (#900). - var modelItem = this.rects_[i].modelItem; - if (!modelItem) - continue; - if (filter.matchSlice(modelItem)) - selection.push(modelItem); - } - }, - - addClosestEventToSelection: function(worldX, worldMaxDist, loY, hiY, - selection) { - var rect = tr.b.findClosestIntervalInSortedIntervals( - this.rects_, - function(x) { return x.start; }, - function(x) { return x.end; }, - worldX, - worldMaxDist); - - if (!rect) - return; - - rect.addToSelection(selection); - } - }; - - /** - * A filled rectangle with a title. - * - * @constructor - * @extends {ProxySelectableItem} - */ - function Rect(modelItem, title, colorId, start, duration) { - tr.model.ProxySelectableItem.call(this, modelItem); - this.title = title; - this.colorId = colorId; - this.start = start; - this.duration = duration; - this.end = start + duration; - }; - - Rect.prototype = { - __proto__: tr.model.ProxySelectableItem.prototype - }; - - return { - RectTrack: RectTrack, - Rect: Rect - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/rect_track_test.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/rect_track_test.html deleted file mode 100644 index 6dcb905a304..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/rect_track_test.html +++ /dev/null @@ -1,407 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/model/slice.html"> -<link rel="import" href="/tracing/ui/base/dom_helpers.html"> -<link rel="import" href="/tracing/ui/base/draw_helpers.html"> -<link rel="import" href="/tracing/ui/timeline_track_view.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var EventSet = tr.model.EventSet; - var RectTrack = tr.ui.tracks.RectTrack; - var Rect = tr.ui.tracks.Rect; - var Slice = tr.model.Slice; - var Viewport = tr.ui.TimelineViewport; - - test('instantiate_withRects', function() { - var div = document.createElement('div'); - - var viewport = new Viewport(div); - var drawingContainer = new tr.ui.tracks.DrawingContainer(viewport); - div.appendChild(drawingContainer); - - var track = RectTrack(viewport); - drawingContainer.appendChild(track); - - this.addHTMLOutput(div); - drawingContainer.invalidate(); - - track.heading = 'testBasicRects'; - track.rects = [ - new Rect(undefined, 'a', 0, 1, 1), - new Rect(undefined, 'b', 1, 2.1, 4.8), - new Rect(undefined, 'b', 1, 7, 0.5), - new Rect(undefined, 'c', 2, 7.6, 0.4) - ]; - - var dt = new tr.ui.TimelineDisplayTransform(); - dt.xSetWorldBounds(0, 8.8, track.clientWidth); - track.viewport.setDisplayTransformImmediately(dt); - }); - - test('instantiate_withSlices', function() { - var div = document.createElement('div'); - - var viewport = new Viewport(div); - var drawingContainer = new tr.ui.tracks.DrawingContainer(viewport); - div.appendChild(drawingContainer); - - var track = RectTrack(viewport); - drawingContainer.appendChild(track); - - this.addHTMLOutput(div); - drawingContainer.invalidate(); - - track.heading = 'testBasicSlices'; - track.rects = [ - new Slice('', 'a', 0, 1, {}, 1), - new Slice('', 'b', 1, 2.1, {}, 4.8), - new Slice('', 'b', 1, 7, {}, 0.5), - new Slice('', 'c', 2, 7.6, {}, 0.4) - ]; - - var dt = new tr.ui.TimelineDisplayTransform(); - dt.xSetWorldBounds(0, 8.8, track.clientWidth); - track.viewport.setDisplayTransformImmediately(dt); - }); - - test('instantiate_shrinkingRectSize', function() { - var div = document.createElement('div'); - - var viewport = new Viewport(div); - var drawingContainer = new tr.ui.tracks.DrawingContainer(viewport); - div.appendChild(drawingContainer); - - var track = RectTrack(viewport); - drawingContainer.appendChild(track); - - this.addHTMLOutput(div); - drawingContainer.invalidate(); - - track.heading = 'testShrinkingRectSizes'; - var x = 0; - var widths = [10, 5, 4, 3, 2, 1, 0.5, 0.4, 0.3, 0.2, 0.1, 0.05]; - var slices = []; - for (var i = 0; i < widths.length; i++) { - var s = new Rect(undefined, 'a', 1, x, widths[i]); - x += s.duration + 0.5; - slices.push(s); - } - track.rects = slices; - var dt = new tr.ui.TimelineDisplayTransform(); - dt.xSetWorldBounds(0, 1.1 * x, track.clientWidth); - track.viewport.setDisplayTransformImmediately(dt); - }); - - test('instantiate_elide', function() { - var optDicts = [{ trackName: 'elideOff', elide: false }, - { trackName: 'elideOn', elide: true }]; - - var tooLongTitle = 'Unless eliding this SHOULD NOT BE DISPLAYED. '; - var bigTitle = 'Very big title name that goes on longer ' + - 'than you may expect'; - - for (var dictIndex in optDicts) { - var dict = optDicts[dictIndex]; - - var div = document.createElement('div'); - div.appendChild(document.createTextNode(dict.trackName)); - - var viewport = new Viewport(div); - var drawingContainer = new tr.ui.tracks.DrawingContainer(viewport); - div.appendChild(drawingContainer); - - var track = new RectTrack(viewport); - drawingContainer.appendChild(track); - - this.addHTMLOutput(div); - drawingContainer.invalidate(); - - track.SHOULD_ELIDE_TEXT = dict.elide; - track.heading = 'Visual: ' + dict.trackName; - track.rects = [ - // title, colorId, start, args, opt_duration - new Rect(undefined, 'a ' + tooLongTitle + bigTitle, 0, 1, 1), - new Rect(undefined, bigTitle, 1, 2.1, 4.8), - new Rect(undefined, 'cccc cccc cccc', 1, 7, 0.5), - new Rect(undefined, 'd', 2, 7.6, 1.0) - ]; - var dt = new tr.ui.TimelineDisplayTransform(); - dt.xSetWorldBounds(0, 9.5, track.clientWidth); - track.viewport.setDisplayTransformImmediately(dt); - } - }); - - test('findAllObjectsMatchingInRectTrack', function() { - var track = new RectTrack(new tr.ui.TimelineViewport()); - track.rects = [ - new Slice('', 'a', 0, 1, {}, 1), - new Slice('', 'b', 1, 2.1, {}, 4.8), - new Slice('', 'b', 1, 7, {}, 0.5), - new Slice('', 'c', 2, 7.6, {}, 0.4) - ]; - var selection = new EventSet(); - track.addAllEventsMatchingFilterToSelection( - new tr.c.TitleOrCategoryFilter('b'), selection); - - var predictedSelection = new EventSet( - [track.rects[1].modelItem, track.rects[2].modelItem]); - assert.isTrue(selection.equals(predictedSelection)); - }); - - test('selectionHitTesting', function() { - var testEl = document.createElement('div'); - testEl.appendChild(tr.ui.b.createScopedStyle('heading { width: 100px; }')); - testEl.style.width = '600px'; - - var viewport = new Viewport(testEl); - var drawingContainer = new tr.ui.tracks.DrawingContainer(viewport); - testEl.appendChild(drawingContainer); - - var track = new RectTrack(viewport); - drawingContainer.appendChild(track); - this.addHTMLOutput(testEl); - - drawingContainer.updateCanvasSizeIfNeeded_(); - - track.heading = 'testSelectionHitTesting'; - track.rects = [ - new Slice('', 'a', 0, 1, {}, 1), - new Slice('', 'b', 1, 5, {}, 4.8) - ]; - var y = track.getBoundingClientRect().top + 5; - var pixelRatio = window.devicePixelRatio || 1; - var wW = 10; - var vW = drawingContainer.canvas.getBoundingClientRect().width; - - var dt = new tr.ui.TimelineDisplayTransform(); - dt.xSetWorldBounds(0, wW, vW * pixelRatio); - track.viewport.setDisplayTransformImmediately(dt); - - var selection = new EventSet(); - var x = (1.5 / wW) * vW; - track.addIntersectingEventsInRangeToSelection( - x, x + 1, y, y + 1, selection); - assert.isTrue(selection.equals(new EventSet(track.rects[0].modelItem))); - - var selection = new EventSet(); - x = (2.1 / wW) * vW; - track.addIntersectingEventsInRangeToSelection( - x, x + 1, y, y + 1, selection); - assert.equal(0, selection.length); - - var selection = new EventSet(); - x = (6.8 / wW) * vW; - track.addIntersectingEventsInRangeToSelection( - x, x + 1, y, y + 1, selection); - assert.isTrue(selection.equals(new EventSet(track.rects[1].modelItem))); - - var selection = new EventSet(); - x = (9.9 / wW) * vW; - track.addIntersectingEventsInRangeToSelection( - x, x + 1, y, y + 1, selection); - assert.equal(0, selection.length); - }); - - test('elide', function() { - var testEl = document.createElement('div'); - - var viewport = new Viewport(testEl); - var drawingContainer = new tr.ui.tracks.DrawingContainer(viewport); - testEl.appendChild(drawingContainer); - - var track = new RectTrack(viewport); - drawingContainer.appendChild(track); - this.addHTMLOutput(testEl); - - drawingContainer.updateCanvasSizeIfNeeded_(); - - var bigtitle = 'Super duper long long title ' + - 'holy moly when did you get so verbose?'; - var smalltitle = 'small'; - track.heading = 'testElide'; - track.rects = [ - // title, colorId, start, args, opt_duration - new Slice('', bigtitle, 0, 1, {}, 1), - new Slice('', smalltitle, 1, 2, {}, 1) - ]; - var dt = new tr.ui.TimelineDisplayTransform(); - dt.xSetWorldBounds(0, 3.3, track.clientWidth); - track.viewport.setDisplayTransformImmediately(dt); - - var stringWidthPair = undefined; - var pixWidth = dt.xViewVectorToWorld(1); - - // Small titles on big slices are not elided. - stringWidthPair = - tr.ui.b.elidedTitleCache_.get( - track.context(), - pixWidth, - smalltitle, - tr.ui.b.elidedTitleCache_.labelWidth( - track.context(), - smalltitle), - 1); - assert.equal(smalltitle, stringWidthPair.string); - - // Keep shrinking the slice until eliding starts. - var elidedWhenSmallEnough = false; - for (var sliceLength = 1; sliceLength >= 0.00001; sliceLength /= 2.0) { - stringWidthPair = - tr.ui.b.elidedTitleCache_.get( - track.context(), - pixWidth, - smalltitle, - tr.ui.b.elidedTitleCache_.labelWidth( - track.context(), - smalltitle), - sliceLength); - if (stringWidthPair.string.length < smalltitle.length) { - elidedWhenSmallEnough = true; - break; - } - } - assert.isTrue(elidedWhenSmallEnough); - - // Big titles are elided immediately. - var superBigTitle = ''; - for (var x = 0; x < 10; x++) { - superBigTitle += bigtitle; - } - stringWidthPair = - tr.ui.b.elidedTitleCache_.get( - track.context(), - pixWidth, - superBigTitle, - tr.ui.b.elidedTitleCache_.labelWidth( - track.context(), - superBigTitle), - 1); - assert.isTrue(stringWidthPair.string.length < superBigTitle.length); - - // And elided text ends with ... - var len = stringWidthPair.string.length; - assert.equal('...', stringWidthPair.string.substring(len - 3, len)); - }); - - test('rectTrackAddItemNearToProvidedEvent', function() { - var track = new RectTrack(new tr.ui.TimelineViewport()); - track.rects = [ - new Slice('', 'a', 0, 1, {}, 1), - new Slice('', 'b', 1, 2.1, {}, 4.8), - new Slice('', 'b', 1, 7, {}, 0.5), - new Slice('', 'c', 2, 7.6, {}, 0.4) - ]; - var sel = new EventSet(); - track.addAllEventsMatchingFilterToSelection( - new tr.c.TitleOrCategoryFilter('b'), sel); - var ret; - - // Select to the right of B. - var selRight = new EventSet(); - ret = track.addEventNearToProvidedEventToSelection(sel[0], 1, selRight); - assert.isTrue(ret); - assert.equal(track.rects[2].modelItem, selRight[0]); - - // Select to the right of the 2nd b. - var selRight2 = new EventSet(); - ret = track.addEventNearToProvidedEventToSelection(sel[0], 2, selRight2); - assert.isTrue(ret); - assert.equal(track.rects[3].modelItem, selRight2[0]); - - // Select to 2 to the right of the 2nd b. - var selRightOfRight = new EventSet(); - ret = track.addEventNearToProvidedEventToSelection( - selRight[0], 1, selRightOfRight); - assert.isTrue(ret); - assert.equal(track.rects[3].modelItem, selRightOfRight[0]); - - // Select to the right of the rightmost slice. - var selNone = new EventSet(); - ret = track.addEventNearToProvidedEventToSelection( - selRightOfRight[0], 1, selNone); - assert.isFalse(ret); - assert.equal(0, selNone.length); - - // Select A and then select left. - var sel = new EventSet(); - track.addAllEventsMatchingFilterToSelection( - new tr.c.TitleOrCategoryFilter('a'), sel); - var ret; - - selNone = new EventSet(); - ret = track.addEventNearToProvidedEventToSelection(sel[0], -1, selNone); - assert.isFalse(ret); - assert.equal(0, selNone.length); - }); - - test('rectTrackAddClosestEventToSelection', function() { - var track = new RectTrack(new tr.ui.TimelineViewport()); - track.rects = [ - new Slice('', 'a', 0, 1, {}, 1), - new Slice('', 'b', 1, 2.1, {}, 4.8), - new Slice('', 'b', 1, 7, {}, 0.5), - new Slice('', 'c', 2, 7.6, {}, 0.4) - ]; - - // Before with not range. - var sel = new EventSet(); - track.addClosestEventToSelection(0, 0, 0, 0, sel); - assert.equal(0, sel.length); - - // Before with negative range. - var sel = new EventSet(); - track.addClosestEventToSelection(1.5, -10, 0, 0, sel); - assert.equal(0, sel.length); - - // Before first slice. - var sel = new EventSet(); - track.addClosestEventToSelection(0.5, 1, 0, 0, sel); - assert.isTrue(sel.equals(new EventSet(track.rects[0].modelItem))); - - // Within first slice closer to start. - var sel = new EventSet(); - track.addClosestEventToSelection(1.3, 1, 0, 0, sel); - assert.isTrue(sel.equals(new EventSet(track.rects[0].modelItem))); - - // Between slices with good range. - var sel = new EventSet(); - track.addClosestEventToSelection(2.08, 3, 0, 0, sel); - assert.isTrue(sel.equals(new EventSet(track.rects[1].modelItem))); - - // Between slices with bad range. - var sel = new EventSet(); - track.addClosestEventToSelection(2.05, 0.03, 0, 0, sel); - assert.equal(0, sel.length); - - // Within slice closer to end. - var sel = new EventSet(); - track.addClosestEventToSelection(6, 100, 0, 0, sel); - assert.isTrue(sel.equals(new EventSet(track.rects[1].modelItem))); - - // Within slice with bad range. - var sel = new EventSet(); - track.addClosestEventToSelection(1.8, 0.1, 0, 0, sel); - assert.equal(0, sel.length); - - // After last slice with good range. - var sel = new EventSet(); - track.addClosestEventToSelection(8.5, 1, 0, 0, sel); - assert.isTrue(sel.equals(new EventSet(track.rects[3].modelItem))); - - // After last slice with bad range. - var sel = new EventSet(); - track.addClosestEventToSelection(10, 1, 0, 0, sel); - assert.equal(0, sel.length); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/ruler_track.css b/chromium/third_party/catapult/tracing/tracing/ui/tracks/ruler_track.css deleted file mode 100644 index 67a04a987ae..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/ruler_track.css +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright (c) 2012 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -.ruler-track { - height: 12px; -} - -.ruler-track.tall-mode { - height: 30px; -} diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/ruler_track.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/ruler_track.html deleted file mode 100644 index 30ce44be39d..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/ruler_track.html +++ /dev/null @@ -1,374 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="stylesheet" href="/tracing/ui/tracks/ruler_track.css"> - -<link rel="import" href="/tracing/ui/base/draw_helpers.html"> -<link rel="import" href="/tracing/ui/base/heading.html"> -<link rel="import" href="/tracing/ui/base/ui.html"> -<link rel="import" href="/tracing/ui/tracks/track.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.tracks', function() { - /** - * A track that displays the ruler. - * @constructor - * @extends {Track} - */ - var RulerTrack = tr.ui.b.define('ruler-track', tr.ui.tracks.Track); - - var logOf10 = Math.log(10); - function log10(x) { - return Math.log(x) / logOf10; - } - - RulerTrack.prototype = { - __proto__: tr.ui.tracks.Track.prototype, - - decorate: function(viewport) { - tr.ui.tracks.Track.prototype.decorate.call(this, viewport); - this.classList.add('ruler-track'); - this.strings_secs_ = []; - this.strings_msecs_ = []; - this.strings_usecs_ = []; - this.strings_nsecs_ = []; - - this.viewportChange_ = this.viewportChange_.bind(this); - viewport.addEventListener('change', this.viewportChange_); - - var heading = document.createElement('tr-ui-heading'); - heading.arrowVisible = false; - this.appendChild(heading); - }, - - detach: function() { - tr.ui.tracks.Track.prototype.detach.call(this); - this.viewport.removeEventListener('change', - this.viewportChange_); - }, - - viewportChange_: function() { - if (this.viewport.interestRange.isEmpty) - this.classList.remove('tall-mode'); - else - this.classList.add('tall-mode'); - }, - - draw: function(type, viewLWorld, viewRWorld) { - switch (type) { - case tr.ui.tracks.DrawType.GRID: - this.drawGrid_(viewLWorld, viewRWorld); - break; - case tr.ui.tracks.DrawType.MARKERS: - if (!this.viewport.interestRange.isEmpty) - this.viewport.interestRange.draw(this.context(), - viewLWorld, viewRWorld); - break; - } - }, - - drawGrid_: function(viewLWorld, viewRWorld) { - var ctx = this.context(); - var pixelRatio = window.devicePixelRatio || 1; - - var canvasBounds = ctx.canvas.getBoundingClientRect(); - var trackBounds = this.getBoundingClientRect(); - var width = canvasBounds.width * pixelRatio; - var height = trackBounds.height * pixelRatio; - - var hasInterestRange = !this.viewport.interestRange.isEmpty; - - var rulerHeight = hasInterestRange ? (height * 2) / 5 : height; - - var vp = this.viewport; - var dt = vp.currentDisplayTransform; - - var idealMajorMarkDistancePix = 150 * pixelRatio; - var idealMajorMarkDistanceWorld = - dt.xViewVectorToWorld(idealMajorMarkDistancePix); - - var majorMarkDistanceWorld; - - // The conservative guess is the nearest enclosing 0.1, 1, 10, 100, etc. - var conservativeGuess = - Math.pow(10, Math.ceil(log10(idealMajorMarkDistanceWorld))); - - // Once we have a conservative guess, consider things that evenly add up - // to the conservative guess, e.g. 0.5, 0.2, 0.1 Pick the one that still - // exceeds the ideal mark distance. - var divisors = [10, 5, 2, 1]; - for (var i = 0; i < divisors.length; ++i) { - var tightenedGuess = conservativeGuess / divisors[i]; - if (dt.xWorldVectorToView(tightenedGuess) < idealMajorMarkDistancePix) - continue; - majorMarkDistanceWorld = conservativeGuess / divisors[i - 1]; - break; - } - - var unit; - var unitDivisor; - var tickLabels = undefined; - if (majorMarkDistanceWorld < 0.0001) { - unit = 'ns'; - unitDivisor = 0.000001; - tickLabels = this.strings_nsecs_; - } else if (majorMarkDistanceWorld < 0.1) { - unit = 'us'; - unitDivisor = 0.001; - tickLabels = this.strings_usecs_; - } else if (majorMarkDistanceWorld < 100) { - unit = 'ms'; - unitDivisor = 1; - tickLabels = this.strings_msecs_; - } else { - unit = 's'; - unitDivisor = 1000; - tickLabels = this.strings_secs_; - } - - var numTicksPerMajor = 5; - var minorMarkDistanceWorld = majorMarkDistanceWorld / numTicksPerMajor; - var minorMarkDistancePx = dt.xWorldVectorToView(minorMarkDistanceWorld); - - var firstMajorMark = - Math.floor(viewLWorld / majorMarkDistanceWorld) * - majorMarkDistanceWorld; - - var minorTickH = Math.floor(rulerHeight * 0.25); - - ctx.save(); - - var pixelRatio = window.devicePixelRatio || 1; - ctx.lineWidth = Math.round(pixelRatio); - - // Apply subpixel translate to get crisp lines. - // http://www.mobtowers.com/html5-canvas-crisp-lines-every-time/ - var crispLineCorrection = (ctx.lineWidth % 2) / 2; - ctx.translate(crispLineCorrection, -crispLineCorrection); - - ctx.fillStyle = 'rgb(0, 0, 0)'; - ctx.strokeStyle = 'rgb(0, 0, 0)'; - ctx.textAlign = 'left'; - ctx.textBaseline = 'top'; - - ctx.font = (9 * pixelRatio) + 'px sans-serif'; - - vp.majorMarkPositions = []; - - // Each iteration of this loop draws one major mark - // and numTicksPerMajor minor ticks. - // - // Rendering can't be done in world space because canvas transforms - // affect line width. So, do the conversions manually. - ctx.beginPath(); - for (var curX = firstMajorMark; - curX < viewRWorld; - curX += majorMarkDistanceWorld) { - - var curXView = Math.floor(dt.xWorldToView(curX)); - - var unitValue = curX / unitDivisor; - var roundedUnitValue = Math.round(unitValue * 100000) / 100000; - - if (!tickLabels[roundedUnitValue]) - tickLabels[roundedUnitValue] = roundedUnitValue + ' ' + unit; - ctx.fillText(tickLabels[roundedUnitValue], - curXView + (2 * pixelRatio), 0); - - vp.majorMarkPositions.push(curXView); - - // Major mark - tr.ui.b.drawLine(ctx, curXView, 0, curXView, rulerHeight); - - // Minor marks - for (var i = 1; i < numTicksPerMajor; ++i) { - var xView = Math.floor(curXView + minorMarkDistancePx * i); - tr.ui.b.drawLine(ctx, - xView, rulerHeight - minorTickH, - xView, rulerHeight); - } - } - - // Draw bottom bar. - ctx.strokeStyle = 'rgb(0, 0, 0)'; - tr.ui.b.drawLine(ctx, 0, height, width, height); - ctx.stroke(); - - // Give distance between directly adjacent markers. - if (!hasInterestRange) - return; - - // Draw middle bar. - tr.ui.b.drawLine(ctx, 0, rulerHeight, width, rulerHeight); - ctx.stroke(); - - // Distance Variables. - var displayDistance; - var displayTextColor = 'rgb(0,0,0)'; - - // Arrow Variables. - var arrowSpacing = 10 * pixelRatio; - var arrowColor = 'rgb(128,121,121)'; - var arrowPosY = rulerHeight * 1.75; - var arrowWidthView = 3 * pixelRatio; - var arrowLengthView = 10 * pixelRatio; - var spaceForArrowsView = 2 * (arrowWidthView + arrowSpacing); - - ctx.textBaseline = 'middle'; - ctx.font = (14 * pixelRatio) + 'px sans-serif'; - var textPosY = arrowPosY; - - var interestRange = vp.interestRange; - - // If the range is zero, draw it's min timestamp next to the line. - if (interestRange.range === 0) { - var markerWorld = interestRange.min; - var markerView = dt.xWorldToView(markerWorld); - var displayValue = markerWorld / unitDivisor; - displayValue = Math.abs((Math.round(displayValue * 1000) / 1000)); - - var textToDraw = displayValue + ' ' + unit; - var textLeftView = markerView + 4 * pixelRatio; - var textWidthView = ctx.measureText(textToDraw).width; - - // Put text to the left in case it gets cut off. - if (textLeftView + textWidthView > width) - textLeftView = markerView - 4 * pixelRatio - textWidthView; - - ctx.fillStyle = displayTextColor; - ctx.fillText(textToDraw, textLeftView, textPosY); - return; - } - - var leftMarker = interestRange.min; - var rightMarker = interestRange.max; - - var leftMarkerView = dt.xWorldToView(leftMarker); - var rightMarkerView = dt.xWorldToView(rightMarker); - - var distanceBetweenMarkers = interestRange.range; - var distanceBetweenMarkersView = - dt.xWorldVectorToView(distanceBetweenMarkers); - var positionInMiddleOfMarkersView = - leftMarkerView + (distanceBetweenMarkersView / 2); - - // Determine units. - if (distanceBetweenMarkers < 0.0001) { - unit = 'ns'; - unitDivisor = 0.000001; - } else if (distanceBetweenMarkers < 0.1) { - unit = 'us'; - unitDivisor = 0.001; - } else if (distanceBetweenMarkers < 100) { - unit = 'ms'; - unitDivisor = 1; - } else { - unit = 's'; - unitDivisor = 1000; - } - - // Calculate display value to print. - displayDistance = distanceBetweenMarkers / unitDivisor; - var roundedDisplayDistance = - Math.abs((Math.round(displayDistance * 1000) / 1000)); - var textToDraw = roundedDisplayDistance + ' ' + unit; - var textWidthView = ctx.measureText(textToDraw).width; - var spaceForArrowsAndTextView = - textWidthView + spaceForArrowsView + arrowSpacing; - - // Set text positions. - var textLeftView = positionInMiddleOfMarkersView - textWidthView / 2; - var textRightView = textLeftView + textWidthView; - - if (spaceForArrowsAndTextView > distanceBetweenMarkersView) { - // Print the display distance text right of the 2 markers. - textLeftView = rightMarkerView + 2 * arrowSpacing; - - // Put text to the left in case it gets cut off. - if (textLeftView + textWidthView > width) - textLeftView = leftMarkerView - 2 * arrowSpacing - textWidthView; - - ctx.fillStyle = displayTextColor; - ctx.fillText(textToDraw, textLeftView, textPosY); - - // Draw the arrows pointing from outside in and a line in between. - ctx.strokeStyle = arrowColor; - ctx.beginPath(); - tr.ui.b.drawLine(ctx, leftMarkerView, arrowPosY, rightMarkerView, - arrowPosY); - ctx.stroke(); - - ctx.fillStyle = arrowColor; - tr.ui.b.drawArrow(ctx, - leftMarkerView - 1.5 * arrowSpacing, arrowPosY, - leftMarkerView, arrowPosY, - arrowLengthView, arrowWidthView); - tr.ui.b.drawArrow(ctx, - rightMarkerView + 1.5 * arrowSpacing, arrowPosY, - rightMarkerView, arrowPosY, - arrowLengthView, arrowWidthView); - - } else if (spaceForArrowsView <= distanceBetweenMarkersView) { - var leftArrowStart; - var rightArrowStart; - if (spaceForArrowsAndTextView <= distanceBetweenMarkersView) { - // Print the display distance text. - ctx.fillStyle = displayTextColor; - ctx.fillText(textToDraw, textLeftView, textPosY); - - leftArrowStart = textLeftView - arrowSpacing; - rightArrowStart = textRightView + arrowSpacing; - } else { - leftArrowStart = positionInMiddleOfMarkersView; - rightArrowStart = positionInMiddleOfMarkersView; - } - - // Draw the arrows pointing inside out. - ctx.strokeStyle = arrowColor; - ctx.fillStyle = arrowColor; - tr.ui.b.drawArrow(ctx, - leftArrowStart, arrowPosY, - leftMarkerView, arrowPosY, - arrowLengthView, arrowWidthView); - tr.ui.b.drawArrow(ctx, - rightArrowStart, arrowPosY, - rightMarkerView, arrowPosY, - arrowLengthView, arrowWidthView); - } - - ctx.restore(); - }, - - /** - * Adds items intersecting the given range to a selection. - * @param {number} loVX Lower X bound of the interval to search, in - * viewspace. - * @param {number} hiVX Upper X bound of the interval to search, in - * viewspace. - * @param {number} loVY Lower Y bound of the interval to search, in - * viewspace. - * @param {number} hiVY Upper Y bound of the interval to search, in - * viewspace. - * @param {Selection} selection Selection to which to add results. - */ - addIntersectingEventsInRangeToSelection: function( - loVX, hiVX, loY, hiY, selection) { - // Does nothing. There's nothing interesting to pick on the ruler - // track. - }, - - addAllEventsMatchingFilterToSelection: function(filter, selection) { - } - }; - - return { - RulerTrack: RulerTrack - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/ruler_track_test.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/ruler_track_test.html deleted file mode 100644 index 3ca0d72fdf4..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/ruler_track_test.html +++ /dev/null @@ -1,36 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/ui/timeline_viewport.html"> -<link rel="import" href="/tracing/ui/tracks/drawing_container.html"> -<link rel="import" href="/tracing/ui/tracks/ruler_track.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - test('instantiate', function() { - var div = document.createElement('div'); - - var viewport = new tr.ui.TimelineViewport(div); - var drawingContainer = new tr.ui.tracks.DrawingContainer(viewport); - div.appendChild(drawingContainer); - - var track = tr.ui.tracks.RulerTrack(viewport); - drawingContainer.appendChild(track); - this.addHTMLOutput(div); - - drawingContainer.invalidate(); - - var dt = new tr.ui.TimelineDisplayTransform(); - dt.setPanAndScale(0, track.clientWidth / 1000); - track.viewport.setDisplayTransformImmediately(dt); - }); -}); -</script> - diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/sample_track.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/sample_track.html deleted file mode 100644 index 80010bbc2a3..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/sample_track.html +++ /dev/null @@ -1,44 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/tracks/rect_track.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.tracks', function() { - /** - * A track that displays an array of Sample objects. - * @constructor - * @extends {RectTrack} - */ - var SampleTrack = tr.ui.b.define( - 'sample-track', tr.ui.tracks.RectTrack); - - SampleTrack.prototype = { - - __proto__: tr.ui.tracks.RectTrack.prototype, - - decorate: function(viewport) { - tr.ui.tracks.RectTrack.prototype.decorate.call(this, viewport); - }, - - get samples() { - return this.rects; - }, - - set samples(samples) { - this.rects = samples; - } - }; - - return { - SampleTrack: SampleTrack - }; -}); -</script> - diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/sample_track_test.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/sample_track_test.html deleted file mode 100644 index c5c7342af0e..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/sample_track_test.html +++ /dev/null @@ -1,33 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/model/sample.html"> -<link rel="import" href="/tracing/model/stack_frame.html"> -<link rel="import" href="/tracing/ui/timeline_track_view.html"> -<link rel="import" href="/tracing/ui/tracks/sample_track.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var SampleTrack = tr.ui.tracks.SampleTrack; - var Sample = tr.model.Sample; - var StackFrame = tr.model.StackFrame; - - test('modelMapping', function() { - var track = new SampleTrack(new tr.ui.TimelineViewport()); - var fA = new StackFrame(undefined, 1, 'cat', 'a', 7); - var sample = new Sample(undefined, undefined, 'instructions_retired', - 10, fA, 10); - track.samples = [sample]; - var me0 = track.rects[0].modelItem; - assert.equal(me0, sample); - }); -}); -</script> - diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/slice_group_track.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/slice_group_track.html deleted file mode 100644 index 78ffd07cf00..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/slice_group_track.html +++ /dev/null @@ -1,168 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/tracks/multi_row_track.html"> -<link rel="import" href="/tracing/base/sorted_array_utils.html"> -<link rel="import" href="/tracing/ui/base/ui.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.tracks', function() { - /** - * A track that displays a SliceGroup. - * @constructor - * @extends {MultiRowTrack} - */ - var SliceGroupTrack = tr.ui.b.define( - 'slice-group-track', tr.ui.tracks.MultiRowTrack); - - SliceGroupTrack.prototype = { - - __proto__: tr.ui.tracks.MultiRowTrack.prototype, - - decorate: function(viewport) { - tr.ui.tracks.MultiRowTrack.prototype.decorate.call(this, viewport); - this.classList.add('slice-group-track'); - this.group_ = undefined; - // Set the collapse threshold so we don't collapse by default, but the - // user can explicitly collapse if they want it. - this.defaultToCollapsedWhenSubRowCountMoreThan = 100; - }, - - addSubTrack_: function(slices) { - var track = new tr.ui.tracks.SliceTrack(this.viewport); - track.slices = slices; - this.appendChild(track); - return track; - }, - - get group() { - return this.group_; - }, - - set group(group) { - this.group_ = group; - this.setItemsToGroup(this.group_.slices, this.group_); - }, - - get eventContainer() { - return this.group; - }, - - addContainersToTrackMap: function(containerToTrackMap) { - tr.ui.tracks.MultiRowTrack.prototype.addContainersToTrackMap.apply( - this, arguments); - containerToTrackMap.addContainer(this.group, this); - }, - - /** - * Breaks up the list of slices into N rows, each of which is a list of - * slices that are non overlapping. - */ - buildSubRows_: function(slices) { - var precisionUnit = this.group.model.intrinsicTimeUnit; - - // This function works by walking through slices by start time. - // - // The basic idea here is to insert each slice as deep into the subrow - // list as it can go such that every subSlice is fully contained by its - // parent slice. - // - // Visually, if we start with this: - // 0: [ a ] - // 1: [ b ] - // 2: [c][d] - // - // To place this slice: - // [e] - // We first check row 2's last item, [d]. [e] wont fit into [d] (they dont - // even intersect). So we go to row 1. That gives us [b], and [d] wont fit - // into that either. So, we go to row 0 and its last slice, [a]. That can - // completely contain [e], so that means we should add [e] as a subchild - // of [a]. That puts it on row 1, yielding: - // 0: [ a ] - // 1: [ b ][e] - // 2: [c][d] - // - // If we then get this slice: - // [f] - // We do the same deepest-to-shallowest walk of the subrows trying to fit - // it. This time, it doesn't fit in any open slice. So, we simply append - // it to row 0: - // 0: [ a ] [f] - // 1: [ b ][e] - // 2: [c][d] - if (!slices.length) - return []; - - var ops = []; - for (var i = 0; i < slices.length; i++) { - if (slices[i].subSlices) - slices[i].subSlices.splice(0, - slices[i].subSlices.length); - ops.push(i); - } - - ops.sort(function(ix, iy) { - var x = slices[ix]; - var y = slices[iy]; - if (x.start != y.start) - return x.start - y.start; - - // Elements get inserted into the slices array in order of when the - // slices start. Because slices must be properly nested, we break - // start-time ties by assuming that the elements appearing earlier in - // the slices array (and thus ending earlier) start earlier. - return ix - iy; - }); - - var subRows = [[]]; - this.badSlices_ = []; // TODO(simonjam): Connect this again. - - for (var i = 0; i < ops.length; i++) { - var op = ops[i]; - var slice = slices[op]; - - // Try to fit the slice into the existing subrows. - var inserted = false; - for (var j = subRows.length - 1; j >= 0; j--) { - if (subRows[j].length == 0) - continue; - - var insertedSlice = subRows[j][subRows[j].length - 1]; - if (slice.start < insertedSlice.start) { - this.badSlices_.push(slice); - inserted = true; - } - if (insertedSlice.bounds(slice, precisionUnit)) { - // Insert it into subRow j + 1. - while (subRows.length <= j + 1) - subRows.push([]); - subRows[j + 1].push(slice); - if (insertedSlice.subSlices) - insertedSlice.subSlices.push(slice); - inserted = true; - break; - } - } - if (inserted) - continue; - - // Append it to subRow[0] as a root. - subRows[0].push(slice); - } - - return subRows; - } - }; - - return { - SliceGroupTrack: SliceGroupTrack - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/slice_group_track_test.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/slice_group_track_test.html deleted file mode 100644 index 6e3ff9813c4..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/slice_group_track_test.html +++ /dev/null @@ -1,293 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/ui/timeline_track_view.html"> -<link rel="import" href="/tracing/model/slice_group.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var ProcessTrack = tr.ui.tracks.ProcessTrack; - var ThreadTrack = tr.ui.tracks.ThreadTrack; - var SliceGroup = tr.model.SliceGroup; - var SliceGroupTrack = tr.ui.tracks.SliceGroupTrack; - var newSliceEx = tr.c.TestUtils.newSliceEx; - - test('subRowBuilderBasic', function() { - var m = new tr.Model(); - var t1 = m.getOrCreateProcess(1).getOrCreateThread(2); - var group = t1.sliceGroup; - var sA = group.pushSlice(newSliceEx({title: 'a', start: 1, duration: 2})); - var sB = group.pushSlice(newSliceEx({title: 'a', start: 3, duration: 1})); - - var track = new SliceGroupTrack(new tr.ui.TimelineViewport()); - track.group = group; - var subRows = track.subRows; - - assert.equal(track.badSlices_.length, 0); - assert.equal(subRows.length, 1); - assert.equal(subRows[0].length, 2); - assert.deepEqual(subRows[0], [sA, sB]); - }); - - test('subRowBuilderBasic2', function() { - var m = new tr.Model(); - var t1 = m.getOrCreateProcess(1).getOrCreateThread(2); - var group = t1.sliceGroup; - var sA = group.pushSlice(newSliceEx({title: 'a', start: 1, duration: 4})); - var sB = group.pushSlice(newSliceEx({title: 'b', start: 3, duration: 1})); - - var track = new SliceGroupTrack(new tr.ui.TimelineViewport()); - track.group = group; - var subRows = track.subRows; - - assert.equal(track.badSlices_.length, 0); - assert.equal(subRows.length, 2); - assert.equal(subRows[0].length, 1); - assert.equal(subRows[1].length, 1); - assert.deepEqual(subRows[0], [sA]); - assert.deepEqual(subRows[1], [sB]); - }); - - test('subRowBuilderNestedExactly', function() { - var m = new tr.Model(); - var t1 = m.getOrCreateProcess(1).getOrCreateThread(2); - var group = t1.sliceGroup; - - var sB = group.pushSlice(newSliceEx({title: 'b', start: 1, duration: 4})); - var sA = group.pushSlice(newSliceEx({title: 'a', start: 1, duration: 4})); - - var track = new SliceGroupTrack(new tr.ui.TimelineViewport()); - track.group = group; - var subRows = track.subRows; - - assert.equal(track.badSlices_.length, 0); - assert.equal(subRows.length, 2); - assert.equal(subRows[0].length, 1); - assert.equal(subRows[1].length, 1); - assert.deepEqual(subRows[0], [sB]); - assert.deepEqual(subRows[1], [sA]); - }); - - test('subRowBuilderInstantEvents', function() { - var m = new tr.Model(); - var t1 = m.getOrCreateProcess(1).getOrCreateThread(2); - var group = t1.sliceGroup; - - var sA = group.pushSlice(newSliceEx({title: 'a', start: 1, duration: 0})); - var sB = group.pushSlice(newSliceEx({title: 'b', start: 2, duration: 0})); - - var track = new SliceGroupTrack(new tr.ui.TimelineViewport()); - track.group = group; - var subRows = track.subRows; - - assert.equal(track.badSlices_.length, 0); - assert.equal(subRows.length, 1); - assert.equal(subRows[0].length, 2); - assert.deepEqual(subRows[0], [sA, sB]); - }); - - test('subRowBuilderTwoInstantEvents', function() { - var m = new tr.Model(); - var t1 = m.getOrCreateProcess(1).getOrCreateThread(2); - var group = t1.sliceGroup; - - var sA = group.pushSlice(newSliceEx({title: 'a', start: 1, duration: 0})); - var sB = group.pushSlice(newSliceEx({title: 'b', start: 1, duration: 0})); - - var track = new SliceGroupTrack(new tr.ui.TimelineViewport()); - track.group = group; - var subRows = track.subRows; - - assert.equal(track.badSlices_.length, 0); - assert.equal(subRows.length, 2); - assert.deepEqual(subRows[0], [sA]); - assert.deepEqual(subRows[1], [sB]); - }); - - test('subRowBuilderOutOfOrderAddition', function() { - var m = new tr.Model(); - var t1 = m.getOrCreateProcess(1).getOrCreateThread(2); - var group = t1.sliceGroup; - - // Pattern being tested: - // [ a ][ b ] - // Where insertion is done backward. - var sB = group.pushSlice(newSliceEx({title: 'b', start: 3, duration: 1})); - var sA = group.pushSlice(newSliceEx({title: 'a', start: 1, duration: 2})); - - var track = new SliceGroupTrack(new tr.ui.TimelineViewport()); - track.group = group; - var subRows = track.subRows; - - assert.equal(track.badSlices_.length, 0); - assert.equal(subRows.length, 1); - assert.equal(subRows[0].length, 2); - assert.deepEqual(subRows[0], [sA, sB]); - }); - - test('subRowBuilderOutOfOrderAddition2', function() { - var m = new tr.Model(); - var t1 = m.getOrCreateProcess(1).getOrCreateThread(2); - var group = t1.sliceGroup; - - // Pattern being tested: - // [ a ] - // [ b ] - // Where insertion is done backward. - var sB = group.pushSlice(newSliceEx({title: 'b', start: 3, duration: 1})); - var sA = group.pushSlice(newSliceEx({title: 'a', start: 1, duration: 5})); - - var track = new SliceGroupTrack(new tr.ui.TimelineViewport()); - track.group = group; - var subRows = track.subRows; - - assert.equal(track.badSlices_.length, 0); - assert.equal(subRows.length, 2); - assert.equal(subRows[0].length, 1); - assert.equal(subRows[1].length, 1); - assert.deepEqual(subRows[0], [sA]); - assert.deepEqual(subRows[1], [sB]); - }); - - test('subRowBuilderOnNestedZeroLength', function() { - var m = new tr.Model(); - var t1 = m.getOrCreateProcess(1).getOrCreateThread(2); - var group = t1.sliceGroup; - - // Pattern being tested: - // [ a ] - // [ b1 ] []<- b2 where b2.duration = 0 and b2.end == a.end. - var sA = group.pushSlice(newSliceEx({title: 'a', start: 1, duration: 3})); - var sB1 = group.pushSlice(newSliceEx({title: 'b1', start: 1, duration: 2})); - var sB2 = group.pushSlice(newSliceEx({title: 'b2', start: 4, duration: 0})); - - var track = new SliceGroupTrack(new tr.ui.TimelineViewport()); - track.group = group; - var subRows = track.subRows; - - assert.equal(track.badSlices_.length, 0); - assert.equal(subRows.length, 2); - assert.deepEqual(subRows[0], [sA]); - assert.deepEqual(subRows[1], [sB1, sB2]); - }); - - test('subRowBuilderOnGroup1', function() { - var m = new tr.Model(); - var t1 = m.getOrCreateProcess(1).getOrCreateThread(2); - var group = t1.sliceGroup; - - // Pattern being tested: - // [ a ] [ c ] - // [ b ] - var sA = group.pushSlice(newSliceEx({title: 'a', start: 1, duration: 3})); - var sB = group.pushSlice(newSliceEx({title: 'b', start: 1.5, duration: 1})); - var sC = group.pushSlice(newSliceEx({title: 'c', start: 5, duration: 0})); - - var track = new SliceGroupTrack(new tr.ui.TimelineViewport()); - track.group = group; - var subRows = track.subRows; - - assert.equal(track.badSlices_.length, 0); - assert.equal(subRows.length, 2); - assert.deepEqual(subRows[0], [sA, sC]); - assert.deepEqual(subRows[1], [sB]); - }); - - test('subRowBuilderOnGroup2', function() { - var m = new tr.Model(); - var t1 = m.getOrCreateProcess(1).getOrCreateThread(2); - var group = t1.sliceGroup; - - // Pattern being tested: - // [ a ] [ d ] - // [ b ] - // [ c ] - var sA = group.pushSlice(newSliceEx({title: 'a', start: 1, duration: 3})); - var sB = group.pushSlice(newSliceEx({title: 'b', start: 1.5, duration: 1})); - var sC = group.pushSlice(newSliceEx( - {title: 'c', start: 1.75, duration: 0.5})); - var sD = group.pushSlice(newSliceEx( - {title: 'c', start: 5, duration: 0.25})); - - var track = new SliceGroupTrack(new tr.ui.TimelineViewport()); - track.group = group; - - var subRows = track.subRows; - assert.equal(track.badSlices_.length, 0); - assert.equal(subRows.length, 3); - assert.deepEqual(subRows[0], [sA, sD]); - assert.deepEqual(subRows[1], [sB]); - assert.deepEqual(subRows[2], [sC]); - }); - - test('trackFiltering', function() { - var m = new tr.Model(); - var t1 = m.getOrCreateProcess(1).getOrCreateThread(2); - var group = t1.sliceGroup; - - var sA = group.pushSlice(newSliceEx({title: 'a', start: 1, duration: 3})); - var sB = group.pushSlice(newSliceEx({title: 'b', start: 1.5, duration: 1})); - - var track = new SliceGroupTrack(new tr.ui.TimelineViewport()); - track.group = group; - - assert.equal(track.subRows.length, 2); - assert.isTrue(track.hasVisibleContent); - }); - -test('sliceGroupContainerMap', function() { - var vp = new tr.ui.TimelineViewport(); - var containerToTrack = vp.containerToTrackMap; - var model = new tr.Model(); - var process = model.getOrCreateProcess(123); - var thread = process.getOrCreateThread(456); - var group = new SliceGroup(thread); - - var processTrack = new ProcessTrack(vp); - var threadTrack = new ThreadTrack(vp); - var groupTrack = new SliceGroupTrack(vp); - processTrack.process = process; - threadTrack.thread = thread; - groupTrack.group = group; - processTrack.appendChild(threadTrack); - threadTrack.appendChild(groupTrack); - - assert.equal(processTrack.eventContainer, process); - assert.equal(threadTrack.eventContainer, thread); - assert.equal(groupTrack.eventContainer, group); - - assert.isUndefined(containerToTrack.getTrackByStableId('123')); - assert.isUndefined(containerToTrack.getTrackByStableId('123.456')); - assert.isUndefined( - containerToTrack.getTrackByStableId('123.456.SliceGroup')); - - vp.modelTrackContainer = { - addContainersToTrackMap: function(containerToTrackMap) { - processTrack.addContainersToTrackMap(containerToTrackMap); - }, - addEventListener: function() {} - }; - vp.rebuildContainerToTrackMap(); - - // Check that all tracks call childs' addContainersToTrackMap() - // by checking the resulting map. - assert.equal(containerToTrack.getTrackByStableId('123'), processTrack); - assert.equal(containerToTrack.getTrackByStableId('123.456'), threadTrack); - assert.equal(containerToTrack.getTrackByStableId('123.456.SliceGroup'), - groupTrack); - - // Check the track's eventContainer getter. - assert.equal(processTrack.eventContainer, process); - assert.equal(threadTrack.eventContainer, thread); - assert.equal(groupTrack.eventContainer, group); - }); -}); -</script> - diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/slice_track.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/slice_track.html deleted file mode 100644 index 87123811d62..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/slice_track.html +++ /dev/null @@ -1,44 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/tracks/rect_track.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.tracks', function() { - /** - * A track that displays an array of Slice objects. - * @constructor - * @extends {RectTrack} - */ - var SliceTrack = tr.ui.b.define( - 'slice-track', tr.ui.tracks.RectTrack); - - SliceTrack.prototype = { - - __proto__: tr.ui.tracks.RectTrack.prototype, - - decorate: function(viewport) { - tr.ui.tracks.RectTrack.prototype.decorate.call(this, viewport); - }, - - get slices() { - return this.rects; - }, - - set slices(slices) { - this.rects = slices; - } - }; - - return { - SliceTrack: SliceTrack - }; -}); -</script> - diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/slice_track_test.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/slice_track_test.html deleted file mode 100644 index 2c22784a848..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/slice_track_test.html +++ /dev/null @@ -1,29 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/model/slice.html"> -<link rel="import" href="/tracing/ui/timeline_track_view.html"> -<link rel="import" href="/tracing/ui/tracks/slice_track.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var SliceTrack = tr.ui.tracks.SliceTrack; - var Slice = tr.model.Slice; - - test('modelMapping', function() { - var track = new SliceTrack(new tr.ui.TimelineViewport()); - var slice = new Slice('', 'a', 0, 1, {}, 1); - track.slices = [slice]; - var me0 = track.rects[0].modelItem; - assert.equal(slice, me0); - }); -}); -</script> - diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/spacing_track.css b/chromium/third_party/catapult/tracing/tracing/ui/tracks/spacing_track.css deleted file mode 100644 index 094eee0862d..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/spacing_track.css +++ /dev/null @@ -1,7 +0,0 @@ -/* Copyright (c) 2013 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ -.spacing-track { - height: 4px; -} diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/spacing_track.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/spacing_track.html deleted file mode 100644 index 5eea1c903e0..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/spacing_track.html +++ /dev/null @@ -1,45 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="stylesheet" href="/tracing/ui/tracks/spacing_track.css"> - -<link rel="import" href="/tracing/ui/base/heading.html"> -<link rel="import" href="/tracing/ui/tracks/track.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.tracks', function() { - /** - * A track used to provide whitespace between the tracks above and below it. - * - * @constructor - * @extends {tr.ui.tracks.Track} - */ - var SpacingTrack = tr.ui.b.define('spacing-track', tr.ui.tracks.Track); - - SpacingTrack.prototype = { - __proto__: tr.ui.tracks.Track.prototype, - - decorate: function(viewport) { - tr.ui.tracks.Track.prototype.decorate.call(this, viewport); - this.classList.add('spacing-track'); - - this.heading_ = document.createElement('tr-ui-heading'); - this.appendChild(this.heading_); - }, - - addAllEventsMatchingFilterToSelection: function(filter, selection) { - } - }; - - return { - SpacingTrack: SpacingTrack - }; -}); -</script> - diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/stacked_bars_track.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/stacked_bars_track.html deleted file mode 100644 index e3e9ea89d40..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/stacked_bars_track.html +++ /dev/null @@ -1,130 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/base/heading.html"> -<link rel="import" href="/tracing/ui/base/ui.html"> -<link rel="import" href="/tracing/ui/tracks/track.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.tracks', function() { - /** - * A track that displays traces as stacked bars. - * @constructor - * @extends {Track} - */ - var StackedBarsTrack = tr.ui.b.define( - 'stacked-bars-track', tr.ui.tracks.Track); - - StackedBarsTrack.prototype = { - - __proto__: tr.ui.tracks.Track.prototype, - - decorate: function(viewport) { - tr.ui.tracks.Track.prototype.decorate.call(this, viewport); - this.classList.add('stacked-bars-track'); - this.objectInstance_ = null; - - this.heading_ = document.createElement('tr-ui-heading'); - this.appendChild(this.heading_); - }, - - set heading(heading) { - this.heading_.heading = heading; - }, - - get heading() { - return this.heading_.heading; - }, - - set tooltip(tooltip) { - this.heading_.tooltip = tooltip; - }, - - addEventsToTrackMap: function(eventToTrackMap) { - var objectSnapshots = this.objectInstance_.snapshots; - objectSnapshots.forEach(function(obj) { - eventToTrackMap.addEvent(obj, this); - }, this); - }, - - /** - * Used to hit-test clicks in the graph. - */ - addIntersectingEventsInRangeToSelectionInWorldSpace: function( - loWX, hiWX, viewPixWidthWorld, selection) { - function onSnapshot(snapshot) { - selection.push(snapshot); - } - - var snapshots = this.objectInstance_.snapshots; - var maxBounds = this.objectInstance_.parent.model.bounds.max; - - tr.b.iterateOverIntersectingIntervals( - snapshots, - function(x) { return x.ts; }, - function(x, i) { - if (i == snapshots.length - 1) { - if (snapshots.length == 1) - return maxBounds; - - return snapshots[i].ts - snapshots[i - 1].ts; - } - - return snapshots[i + 1].ts - snapshots[i].ts; - }, - loWX, hiWX, - onSnapshot); - }, - - /** - * Add the item to the left or right of the provided item, if any, to the - * selection. - * @param {slice} The current slice. - * @param {Number} offset Number of slices away from the object to look. - * @param {Selection} selection The selection to add an event to, - * if found. - * @return {boolean} Whether an event was found. - * @private - */ - addEventNearToProvidedEventToSelection: function(event, offset, selection) { - if (!(event instanceof tr.model.ObjectSnapshot)) - throw new Error('Unrecognized event'); - var objectSnapshots = this.objectInstance_.snapshots; - var index = objectSnapshots.indexOf(event); - var newIndex = index + offset; - if (newIndex >= 0 && newIndex < objectSnapshots.length) { - selection.push(objectSnapshots[newIndex]); - return true; - } - return false; - }, - - addAllEventsMatchingFilterToSelection: function(filter, selection) { - }, - - addClosestEventToSelection: function(worldX, worldMaxDist, loY, hiY, - selection) { - var snapshot = tr.b.findClosestElementInSortedArray( - this.objectInstance_.snapshots, - function(x) { return x.ts; }, - worldX, - worldMaxDist); - - if (!snapshot) - return; - - selection.push(snapshot); - } - }; - - return { - StackedBarsTrack: StackedBarsTrack - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/thread_track.css b/chromium/third_party/catapult/tracing/tracing/ui/tracks/thread_track.css deleted file mode 100644 index c42cee032d8..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/thread_track.css +++ /dev/null @@ -1,10 +0,0 @@ -/* Copyright (c) 2012 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -.thread-track { - -webkit-box-orient: vertical; - display: -webkit-box; - position: relative; -} diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/thread_track.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/thread_track.html deleted file mode 100644 index aca956546b3..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/thread_track.html +++ /dev/null @@ -1,163 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="stylesheet" href="/tracing/ui/tracks/thread_track.css"> - -<link rel="import" href="/tracing/base/iteration_helpers.html"> -<link rel="import" href="/tracing/core/filter.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/ui/base/ui.html"> -<link rel="import" href="/tracing/ui/tracks/async_slice_group_track.html"> -<link rel="import" href="/tracing/ui/tracks/container_track.html"> -<link rel="import" href="/tracing/ui/tracks/sample_track.html"> -<link rel="import" href="/tracing/ui/tracks/slice_group_track.html"> -<link rel="import" href="/tracing/ui/tracks/slice_track.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.tracks', function() { - /** - * Visualizes a Thread using a series of SliceTracks. - * @constructor - */ - var ThreadTrack = tr.ui.b.define('thread-track', - tr.ui.tracks.ContainerTrack); - ThreadTrack.prototype = { - __proto__: tr.ui.tracks.ContainerTrack.prototype, - - decorate: function(viewport) { - tr.ui.tracks.ContainerTrack.prototype.decorate.call(this, viewport); - this.classList.add('thread-track'); - }, - - get thread() { - return this.thread_; - }, - - set thread(thread) { - this.thread_ = thread; - this.updateContents_(); - }, - - get hasVisibleContent() { - return this.tracks_.length > 0; - }, - - get eventContainer() { - return this.thread; - }, - - addContainersToTrackMap: function(containerToTrackMap) { - tr.ui.tracks.ContainerTrack.prototype.addContainersToTrackMap.apply( - this, arguments); - containerToTrackMap.addContainer(this.thread, this); - }, - - updateContents_: function() { - this.detach(); - - if (!this.thread_) - return; - - this.heading = this.thread_.userFriendlyName + ': '; - this.tooltip = this.thread_.userFriendlyDetails; - - if (this.thread_.asyncSliceGroup.length) - this.appendAsyncSliceTracks_(); - - this.appendThreadSamplesTracks_(); - - if (this.thread_.timeSlices) { - var timeSlicesTrack = new tr.ui.tracks.SliceTrack(this.viewport); - timeSlicesTrack.heading = ''; - timeSlicesTrack.height = tr.ui.b.THIN_SLICE_HEIGHT + 'px'; - timeSlicesTrack.slices = this.thread_.timeSlices; - if (timeSlicesTrack.hasVisibleContent) - this.appendChild(timeSlicesTrack); - } - - if (this.thread_.sliceGroup.length) { - var track = new tr.ui.tracks.SliceGroupTrack(this.viewport); - track.heading = this.thread_.userFriendlyName; - track.tooltip = this.thread_.userFriendlyDetails; - track.group = this.thread_.sliceGroup; - if (track.hasVisibleContent) - this.appendChild(track); - } - }, - - appendAsyncSliceTracks_: function() { - var subGroups = this.thread_.asyncSliceGroup.viewSubGroups; - subGroups.forEach(function(subGroup) { - var asyncTrack = new tr.ui.tracks.AsyncSliceGroupTrack(this.viewport); - var title = subGroup.slices[0].viewSubGroupTitle; - asyncTrack.group = subGroup; - asyncTrack.heading = title; - if (asyncTrack.hasVisibleContent) - this.appendChild(asyncTrack); - }, this); - }, - - appendThreadSamplesTracks_: function() { - var threadSamples = this.thread_.samples; - if (threadSamples === undefined || threadSamples.length === 0) - return; - var samplesByTitle = {}; - threadSamples.forEach(function(sample) { - if (samplesByTitle[sample.title] === undefined) - samplesByTitle[sample.title] = []; - samplesByTitle[sample.title].push(sample); - }); - - var sampleTitles = tr.b.dictionaryKeys(samplesByTitle); - sampleTitles.sort(); - - sampleTitles.forEach(function(sampleTitle) { - var samples = samplesByTitle[sampleTitle]; - var samplesTrack = new tr.ui.tracks.SampleTrack(this.viewport); - samplesTrack.group = this.thread_; - samplesTrack.samples = samples; - samplesTrack.heading = this.thread_.userFriendlyName + ': ' + - sampleTitle; - samplesTrack.tooltip = this.thread_.userFriendlyDetails; - samplesTrack.selectionGenerator = function() { - var selection = new tr.model.EventSet(); - for (var i = 0; i < samplesTrack.samples.length; i++) { - selection.push(samplesTrack.samples[i]); - } - return selection; - }; - this.appendChild(samplesTrack); - }, this); - }, - - collapsedDidChange: function(collapsed) { - if (collapsed) { - var h = parseInt(this.tracks[0].height); - for (var i = 0; i < this.tracks.length; ++i) { - if (h > 2) { - this.tracks[i].height = Math.floor(h) + 'px'; - } else { - this.tracks[i].style.display = 'none'; - } - h = h * 0.5; - } - } else { - for (var i = 0; i < this.tracks.length; ++i) { - this.tracks[i].height = this.tracks[0].height; - this.tracks[i].style.display = ''; - } - } - } - }; - - return { - ThreadTrack: ThreadTrack - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/thread_track_test.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/thread_track_test.html deleted file mode 100644 index 068c4f01e02..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/thread_track_test.html +++ /dev/null @@ -1,145 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/model/instant_event.html"> -<link rel="import" href="/tracing/ui/base/dom_helpers.html"> -<link rel="import" href="/tracing/ui/timeline_track_view.html"> -<link rel="import" href="/tracing/ui/tracks/thread_track.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var HighlightInstantEvent = tr.model.ThreadHighlightInstantEvent; - var Process = tr.model.Process; - var EventSet = tr.model.EventSet; - var StackFrame = tr.model.StackFrame; - var Sample = tr.model.Sample; - var Thread = tr.model.Thread; - var ThreadSlice = tr.model.ThreadSlice; - var ThreadTrack = tr.ui.tracks.ThreadTrack; - var Viewport = tr.ui.TimelineViewport; - var newAsyncSlice = tr.c.TestUtils.newAsyncSlice; - var newAsyncSliceNamed = tr.c.TestUtils.newAsyncSliceNamed; - var newSliceEx = tr.c.TestUtils.newSliceEx; - - test('selectionHitTestingWithThreadTrack', function() { - var model = new tr.Model(); - var p1 = model.getOrCreateProcess(1); - var t1 = p1.getOrCreateThread(1); - t1.sliceGroup.pushSlice(new ThreadSlice('', 'a', 0, 1, {}, 4)); - t1.sliceGroup.pushSlice(new ThreadSlice('', 'b', 0, 5.1, {}, 4)); - - var testEl = document.createElement('div'); - testEl.appendChild(tr.ui.b.createScopedStyle('heading { width: 100px; }')); - testEl.style.width = '600px'; - - var viewport = new Viewport(testEl); - var drawingContainer = new tr.ui.tracks.DrawingContainer(viewport); - testEl.appendChild(drawingContainer); - - var track = new ThreadTrack(viewport); - drawingContainer.appendChild(track); - drawingContainer.updateCanvasSizeIfNeeded_(); - track.thread = t1; - - var y = track.getBoundingClientRect().top; - var h = track.getBoundingClientRect().height; - var wW = 10; - var vW = drawingContainer.canvas.getBoundingClientRect().width; - var dt = new tr.ui.TimelineDisplayTransform(); - dt.xSetWorldBounds(0, wW, vW); - track.viewport.setDisplayTransformImmediately(dt); - - var selection = new EventSet(); - var x = (1.5 / wW) * vW; - track.addIntersectingEventsInRangeToSelection( - x, x + 1, y, y + 1, selection); - assert.isTrue(selection.equals( - new EventSet([t1.sliceGroup.slices[0], t1.sliceGroup.slices[1]]))); - - var selection = new EventSet(); - track.addIntersectingEventsInRangeToSelection( - (1.5 / wW) * vW, (1.8 / wW) * vW, - y, y + h, selection); - assert.isTrue(selection.equals( - new EventSet([t1.sliceGroup.slices[0], t1.sliceGroup.slices[1]]))); - }); - - test('filterThreadSlices', function() { - var model = new tr.Model(); - var thread = new Thread(new Process(model, 7), 1); - thread.sliceGroup.pushSlice(newSliceEx( - {title: 'a', start: 0, duration: 0})); - thread.asyncSliceGroup.push(newAsyncSliceNamed('a', 0, 5, t, t)); - - var t = new ThreadTrack(new tr.ui.TimelineViewport()); - t.thread = thread; - - assert.equal(t.tracks_.length, 2); - assert.instanceOf(t.tracks_[0], tr.ui.tracks.AsyncSliceGroupTrack); - assert.instanceOf(t.tracks_[1], tr.ui.tracks.SliceGroupTrack); - }); - - test('sampleThreadSlices', function() { - var thread; - var cpu; - var model = tr.c.TestUtils.newModelWithEvents([], { - shiftWorldToZero: false, - pruneContainers: false, - customizeModelCallback: function(model) { - cpu = model.kernel.getOrCreateCpu(1); - thread = model.getOrCreateProcess(1).getOrCreateThread(2); - - var fA = model.addStackFrame(new StackFrame( - undefined, 1, 'cat', 'a', 7)); - var fAB = model.addStackFrame(new StackFrame( - fA, 2, 'cat', 'b', 7)); - var fABC = model.addStackFrame(new StackFrame( - fAB, 3, 'cat', 'c', 7)); - var fAD = model.addStackFrame(new StackFrame( - fA, 4, 'cat', 'd', 7)); - - model.samples.push(new Sample(undefined, thread, 'instructions_retired', - 10, fABC, 10)); - model.samples.push(new Sample(undefined, thread, 'instructions_retired', - 20, fAB, 10)); - model.samples.push(new Sample(undefined, thread, 'instructions_retired', - 30, fAB, 10)); - model.samples.push(new Sample(undefined, thread, 'instructions_retired', - 40, fAD, 10)); - - model.samples.push(new Sample(undefined, thread, 'page_fault', - 25, fAB, 10)); - model.samples.push(new Sample(undefined, thread, 'page_fault', - 35, fAD, 10)); - } - }); - - var t = new ThreadTrack(new tr.ui.TimelineViewport()); - t.thread = thread; - assert.equal(t.tracks_.length, 2); - - // Instructions retired - var t0 = t.tracks_[0]; - assert.notEqual(t0.heading.indexOf('instructions_retired'), -1); - assert.instanceOf(t0, tr.ui.tracks.SampleTrack); - assert.equal(t0.samples.length, 4); - t0.samples.forEach(function(s) { - assert.instanceOf(s, tr.model.Sample); - }); - - // page_fault - var t1 = t.tracks_[1]; - assert.notEqual(t1.heading.indexOf('page_fault'), -1); - assert.instanceOf(t1, tr.ui.tracks.SampleTrack); - assert.equal(t1.samples.length, 2); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/track.css b/chromium/third_party/catapult/tracing/tracing/ui/tracks/track.css deleted file mode 100644 index 3d56eef5b8d..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/track.css +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright (c) 2012 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -.track-button { - background-color: rgba(255, 255, 255, 0.5); - border: 1px solid rgba(0, 0, 0, 0.1); - color: rgba(0,0,0,0.2); - font-size: 10px; - height: 12px; - text-align: center; - width: 12px; -} - -.track-button:hover { - background-color: rgba(255, 255, 255, 1.0); - border: 1px solid rgba(0, 0, 0, 0.5); - box-shadow: 0 0 .05em rgba(0, 0, 0, 0.4); - color: rgba(0, 0, 0, 1); -} - -.track-close-button { - left: 2px; - position: absolute; - top: 2px; -} - -.track-collapse-button { - left: 3px; - position: absolute; - top: 2px; -} diff --git a/chromium/third_party/catapult/tracing/tracing/ui/tracks/track.html b/chromium/third_party/catapult/tracing/tracing/ui/tracks/track.html deleted file mode 100644 index 09a54c27223..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/tracks/track.html +++ /dev/null @@ -1,167 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> -<link rel="stylesheet" href="/tracing/ui/tracks/track.css"> - -<link rel="import" href="/tracing/ui/base/container_that_decorates_its_children.html"> -<link rel="import" href="/tracing/ui/base/ui.html"> - -<script> -'use strict'; - -tr.exportTo('tr.ui.tracks', function() { - /** - * The base class for all tracks, which render data into a provided div. - * @constructor - */ - var Track = tr.ui.b.define('track', - tr.ui.b.ContainerThatDecoratesItsChildren); - Track.prototype = { - __proto__: tr.ui.b.ContainerThatDecoratesItsChildren.prototype, - - decorate: function(viewport) { - tr.ui.b.ContainerThatDecoratesItsChildren.prototype.decorate.call(this); - if (viewport === undefined) - throw new Error('viewport is required when creating a Track.'); - - this.viewport_ = viewport; - this.classList.add('track'); - }, - - get viewport() { - return this.viewport_; - }, - - get drawingContainer() { - var cur = this; - while (cur) { - if (cur instanceof tr.ui.tracks.DrawingContainer) - return cur; - cur = cur.parentElement; - } - return undefined; - }, - - get eventContainer() { - }, - - invalidateDrawingContainer: function() { - var dc = this.drawingContainer; - if (dc) - dc.invalidate(); - }, - - context: function() { - // This is a little weird here, but we have to be able to walk up the - // parent tree to get the context. - if (!this.parentNode) - return undefined; - if (!this.parentNode.context) - throw new Error('Parent container does not support context() method.'); - return this.parentNode.context(); - }, - - decorateChild_: function(childTrack) { - }, - - undecorateChild_: function(childTrack) { - if (childTrack.detach) - childTrack.detach(); - }, - - updateContents_: function() { - }, - - /** - * Wrapper function around draw() that performs transformations on the - * context necessary for the track's contents to be drawn in the right place - * given the current pan and zoom. - */ - drawTrack: function(type) { - var ctx = this.context(); - - var pixelRatio = window.devicePixelRatio || 1; - var bounds = this.getBoundingClientRect(); - var canvasBounds = ctx.canvas.getBoundingClientRect(); - - ctx.save(); - ctx.translate(0, pixelRatio * (bounds.top - canvasBounds.top)); - - var dt = this.viewport.currentDisplayTransform; - var viewLWorld = dt.xViewToWorld(0); - var viewRWorld = dt.xViewToWorld(bounds.width * pixelRatio); - - this.draw(type, viewLWorld, viewRWorld); - ctx.restore(); - }, - - draw: function(type, viewLWorld, viewRWorld) { - }, - - addEventsToTrackMap: function(eventToTrackMap) { - }, - - addContainersToTrackMap: function(containerToTrackMap) { - }, - - addIntersectingEventsInRangeToSelection: function( - loVX, hiVX, loVY, hiVY, selection) { - - var pixelRatio = window.devicePixelRatio || 1; - var dt = this.viewport.currentDisplayTransform; - var viewPixWidthWorld = dt.xViewVectorToWorld(1); - var loWX = dt.xViewToWorld(loVX * pixelRatio); - var hiWX = dt.xViewToWorld(hiVX * pixelRatio); - - var clientRect = this.getBoundingClientRect(); - var a = Math.max(loVY, clientRect.top); - var b = Math.min(hiVY, clientRect.bottom); - if (a > b) - return; - - this.addIntersectingEventsInRangeToSelectionInWorldSpace( - loWX, hiWX, viewPixWidthWorld, selection); - }, - - addIntersectingEventsInRangeToSelectionInWorldSpace: function( - loWX, hiWX, viewPixWidthWorld, selection) { - }, - - /** - * Gets implemented by supporting track types. The method adds the event - * closest to worldX to the selection. - * - * @param {number} worldX The position that is looked for. - * @param {number} worldMaxDist The maximum distance allowed from worldX to - * the event. - * @param {number} loY Lower Y bound of the search interval in view space. - * @param {number} hiY Upper Y bound of the search interval in view space. - * @param {Selection} selection Selection to which to add hits. - */ - addClosestEventToSelection: function( - worldX, worldMaxDist, loY, hiY, selection) { - }, - - addClosestInstantEventToSelection: function(instantEvents, worldX, - worldMaxDist, selection) { - var instantEvent = tr.b.findClosestElementInSortedArray( - instantEvents, - function(x) { return x.start; }, - worldX, - worldMaxDist); - - if (!instantEvent) - return; - - selection.push(instantEvent); - } - }; - - return { - Track: Track - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/view_specific_brushing_state.html b/chromium/third_party/catapult/tracing/tracing/ui/view_specific_brushing_state.html deleted file mode 100644 index 0300e36d672..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/view_specific_brushing_state.html +++ /dev/null @@ -1,89 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/brushing_state_controller.html"> - -<!-- -This element handles storing and retrieving the brushing state of arbitrary -views (e.g. analysis sub-views). An element can use it by instantiating it and -appending it to itself: - - <div id="some-view-with-specific-brushing-state"> - <tr-ui-b-view-specific-brushing-state view-id="unique-view-identifier"> - </tr-ui-b-view-specific-brushing-state> - ... other child elements ... - </div> - -The state can then be retrieved from and pushed to the state element as -follows: - - newStateElement.set(state); - state = newStateElement.get(); - -Under the hood, the state element searches the DOM tree for an ancestor element -with a brushingStateController field to persist the state (see the -tr.c.BrushingStateController and tr.ui.b.BrushingState classes for more -details). ---> -<polymer-element name="tr-ui-b-view-specific-brushing-state"> - <script> - 'use strict'; - - Polymer({ - /** Compulsory unique identifier of the associated view. */ - get viewId() { - return this.getAttribute('view-id'); - }, - - set viewId(viewId) { - this.setAttribute('view-id', viewId); - }, - - /** - * Retrieve the persisted state of the associated view. The returned object - * (or any of its fields) must not be modified by the caller (unless the - * object/field is treated as a reference). - * - * If no state has been persisted yet or there is no ancestor element with - * a brushingStateController field, this method returns undefined. - */ - get: function() { - var viewId = this.viewId; - if (!viewId) - throw new Error('Element must have a view-id attribute!'); - - var brushingStateController = - tr.c.BrushingStateController.getControllerForElement(this); - if (!brushingStateController) - return undefined; - - return brushingStateController.getViewSpecificBrushingState(viewId); - }, - - /** - * Persist the provided state of the associated view. The provided object - * (or any of its fields) must not be modified afterwards (unless the - * object/field is treated as a reference). - * - * If there is no ancestor element with a brushingStateController field, - * this method does nothing. - */ - set: function(state) { - var viewId = this.viewId; - if (!viewId) - throw new Error('Element must have a view-id attribute!'); - - var brushingStateController = - tr.c.BrushingStateController.getControllerForElement(this); - if (!brushingStateController) - return; - - brushingStateController.changeViewSpecificBrushingState(viewId, state); - } - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/ui/view_specific_brushing_state_test.html b/chromium/third_party/catapult/tracing/tracing/ui/view_specific_brushing_state_test.html deleted file mode 100644 index e4e8ece0441..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/ui/view_specific_brushing_state_test.html +++ /dev/null @@ -1,67 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/ui/brushing_state_controller.html"> -<link rel="import" href="/tracing/ui/view_specific_brushing_state.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var BrushingStateController = tr.c.BrushingStateController; - - function setStateElement(containerEl, viewId) { - var stateElement = document.createElement( - 'tr-ui-b-view-specific-brushing-state'); - stateElement.viewId = viewId; - containerEl.appendChild(stateElement); - return stateElement; - } - - function addChildDiv(element) { - var child = element.ownerDocument.createElement('div'); - element.appendChild(child); - return child; - } - - function addShadowChildDiv(element) { - var shadowRoot = element.createShadowRoot(); - return addChildDiv(shadowRoot); - } - - test('instantiate_withoutBrushingStateController', function() { - var containerEl = document.createElement('div'); - - var stateElement1 = setStateElement(containerEl, 'test-view'); - assert.isUndefined(stateElement1.get()); - stateElement1.set({e: 2.71828}); - assert.isUndefined(stateElement1.get()); - }); - - test('instantiate_withBrushingStateController', function() { - var rootEl = document.createElement('div'); - var containerEl = addChildDiv(addShadowChildDiv(addChildDiv(rootEl))); - rootEl.brushingStateController = new BrushingStateController(undefined); - - var stateElement1 = setStateElement(containerEl, 'test-view'); - assert.isUndefined(stateElement1.get()); - stateElement1.set({e: 2.71828}); - assert.deepEqual(stateElement1.get(), {e: 2.71828}); - - var stateElement2 = setStateElement(containerEl, 'test-view-2'); - assert.isUndefined(stateElement2.get()); - stateElement2.set({pi: 3.14159}); - assert.deepEqual(stateElement2.get(), {pi: 3.14159}); - - var stateElement3 = setStateElement(containerEl, 'test-view'); - assert.deepEqual(stateElement3.get(), {e: 2.71828}); - - var stateElement4 = setStateElement(containerEl, 'test-view-2'); - assert.deepEqual(stateElement4.get(), {pi: 3.14159}); - }); -}); -</script> |