Bug 1258645 - Update all occurences of MarkerUtils to use the new module, r=jsantell
authorVictor Porof <vporof@mozilla.com>
Mon, 28 Mar 2016 13:50:02 +0200
changeset 290531 46fb0301d5ca4ca1f76087e7a182ff05811c4c88
parent 290530 ae98422622f7f75e608621c7291b27b94e2eddce
child 290532 a0f366bd78a48278208304775a1166396a3daad4
push id19656
push usergwagner@mozilla.com
push dateMon, 04 Apr 2016 13:43:23 +0000
treeherderb2g-inbound@e99061fde28a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjsantell
bugs1258645
milestone48.0a1
Bug 1258645 - Update all occurences of MarkerUtils to use the new module, r=jsantell
devtools/client/performance/modules/logic/waterfall-utils.js
devtools/client/performance/modules/widgets/marker-details.js
devtools/client/performance/modules/widgets/marker-view.js
devtools/client/performance/modules/widgets/markers-overview.js
devtools/client/performance/performance-controller.js
devtools/client/performance/test/browser_timeline-waterfall-sidebar.js
devtools/client/performance/test/unit/test_marker-utils.js
devtools/client/performance/views/toolbar.js
--- a/devtools/client/performance/modules/logic/waterfall-utils.js
+++ b/devtools/client/performance/modules/logic/waterfall-utils.js
@@ -3,17 +3,17 @@
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 "use strict";
 
 /**
  * Utility functions for collapsing markers into a waterfall.
  */
 
 const { extend } = require("sdk/util/object");
-const MarkerUtils = require("devtools/client/performance/modules/logic/marker-utils");
+const { MarkerBlueprintUtils } = require("devtools/client/performance/modules/marker-blueprint-utils");
 
 /**
  * Creates a parent marker, which functions like a regular marker,
  * but is able to hold additional child markers.
  *
  * The marker is seeded with values from `marker`.
  * @param object marker
  * @return object
@@ -35,22 +35,22 @@ function collapseMarkersIntoNode({ rootN
     pushNode,
     popParentNode
   } = createParentNodeFactory(rootNode);
 
   for (let i = 0, len = markersList.length; i < len; i++) {
     let curr = markersList[i];
 
     // If this marker type should not be displayed, just skip
-    if (!MarkerUtils.isMarkerValid(curr, filter)) {
+    if (!MarkerBlueprintUtils.shouldDisplayMarker(curr, filter)) {
       continue;
     }
 
     let parentNode = getCurrentParentNode();
-    let blueprint = MarkerUtils.getBlueprintFor(curr);
+    let blueprint = MarkerBlueprintUtils.getBlueprintFor(curr);
 
     let nestable = "nestable" in blueprint ? blueprint.nestable : true;
     let collapsible = "collapsible" in blueprint ? blueprint.collapsible : true;
 
     let finalized = false;
 
     // If this marker is collapsible, turn it into a parent marker.
     // If there are no children within it later, it will be turned
--- a/devtools/client/performance/modules/widgets/marker-details.js
+++ b/devtools/client/performance/modules/widgets/marker-details.js
@@ -5,17 +5,17 @@
 
 /**
  * This file contains the rendering code for the marker sidebar.
  */
 
 const { Cc, Ci, Cu, Cr } = require("chrome");
 
 const EventEmitter = require("devtools/shared/event-emitter");
-const MarkerUtils = require("devtools/client/performance/modules/logic/marker-utils");
+const { MarkerDOMUtils } = require("devtools/client/performance/modules/marker-dom-utils");
 
 /**
  * A detailed view for one single marker.
  *
  * @param nsIDOMNode parent
  *        The parent node holding the view.
  * @param nsIDOMNode splitter
  *        The splitter node that the resize event is bound to.
@@ -88,32 +88,32 @@ MarkerDetails.prototype = {
    *          - frames: Array of stack frame information; see stack.js.
    *          - allocations: Whether or not allocations were enabled for this recording. [optional]
    */
   render: function (options) {
     let { marker, frames } = options;
     this.empty();
 
     let elements = [];
-    elements.push(MarkerUtils.DOM.buildTitle(this._document, marker));
-    elements.push(MarkerUtils.DOM.buildDuration(this._document, marker));
-    MarkerUtils.DOM.buildFields(this._document, marker).forEach(f => elements.push(f));
-    MarkerUtils.DOM.buildCustom(this._document, marker, options).forEach(f => elements.push(f));
+    elements.push(MarkerDOMUtils.buildTitle(this._document, marker));
+    elements.push(MarkerDOMUtils.buildDuration(this._document, marker));
+    MarkerDOMUtils.buildFields(this._document, marker).forEach(f => elements.push(f));
+    MarkerDOMUtils.buildCustom(this._document, marker, options).forEach(f => elements.push(f));
 
     // Build a stack element -- and use the "startStack" label if
     // we have both a startStack and endStack.
     if (marker.stack) {
       let type = marker.endStack ? "startStack" : "stack";
-      elements.push(MarkerUtils.DOM.buildStackTrace(this._document, {
+      elements.push(MarkerDOMUtils.buildStackTrace(this._document, {
         frameIndex: marker.stack, frames, type
       }));
     }
     if (marker.endStack) {
       let type = "endStack";
-      elements.push(MarkerUtils.DOM.buildStackTrace(this._document, {
+      elements.push(MarkerDOMUtils.buildStackTrace(this._document, {
         frameIndex: marker.endStack, frames, type
       }));
     }
 
     elements.forEach(el => this._parent.appendChild(el));
   },
 
   /**
--- a/devtools/client/performance/modules/widgets/marker-view.js
+++ b/devtools/client/performance/modules/widgets/marker-view.js
@@ -6,18 +6,17 @@
 /**
  * This file contains the "marker" view, essentially a detailed list
  * of all the markers in the timeline data.
  */
 
 const { Cc, Ci, Cu, Cr } = require("chrome");
 const { Heritage } = require("resource://devtools/client/shared/widgets/ViewHelpers.jsm");
 const { AbstractTreeItem } = require("resource://devtools/client/shared/widgets/AbstractTreeItem.jsm");
-
-const MarkerUtils = require("devtools/client/performance/modules/logic/marker-utils");
+const { MarkerBlueprintUtils } = require("devtools/client/performance/modules/marker-blueprint-utils");
 
 const HTML_NS = "http://www.w3.org/1999/xhtml";
 
 const LEVEL_INDENT = 10; // px
 const ARROW_NODE_OFFSET = -15; // px
 const WATERFALL_MARKER_SIDEBAR_SAFE_BOUNDS = 20; // px
 const WATERFALL_MARKER_SIDEBAR_WIDTH = 175; // px
 const WATERFALL_MARKER_TIMEBAR_WIDTH_MIN = 5; // px
@@ -143,17 +142,17 @@ MarkerView.prototype = Heritage.extend(A
     let startTime = this.root._interval.startTime;
     let endTime = this.root._interval.endTime;
     let newLevel = this.level + 1;
 
     for (let i = 0, len = submarkers.length; i < len; i++) {
       let marker = submarkers[i];
 
       // Skip filtered markers
-      if (!MarkerUtils.isMarkerValid(marker, this.filter)) {
+      if (!MarkerBlueprintUtils.shouldDisplayMarker(marker, this.filter)) {
         continue;
       }
 
       if (!isMarkerInRange(marker, startTime|0, endTime|0)) {
         continue;
       }
 
       children.push(new MarkerView({
@@ -168,17 +167,17 @@ MarkerView.prototype = Heritage.extend(A
   /**
    * Builds all the nodes representing a marker in the waterfall.
    * @param nsIDOMNode document
    * @param nsIDOMNode targetNode
    * @param nsIDOMNode arrowNode
    */
   _buildMarkerCells: function(doc, targetNode, arrowNode) {
     let marker = this.marker;
-    let blueprint = MarkerUtils.getBlueprintFor(marker);
+    let blueprint = MarkerBlueprintUtils.getBlueprintFor(marker);
     let startTime = this.root._interval.startTime;
     let endTime = this.root._interval.endTime;
 
     let sidebarCell = this._buildMarkerSidebar(doc, blueprint, marker);
     let timebarCell = this._buildMarkerTimebar(doc, blueprint, marker, startTime, endTime, arrowNode);
 
     targetNode.appendChild(sidebarCell);
     targetNode.appendChild(timebarCell);
@@ -207,17 +206,17 @@ MarkerView.prototype = Heritage.extend(A
 
     let bullet = doc.createElement("hbox");
     bullet.className = `waterfall-marker-bullet marker-color-${style.colorName}`;
     bullet.style.transform = `translateX(${this.level * LEVEL_INDENT}px)`;
     bullet.setAttribute("type", marker.name);
     cell.appendChild(bullet);
 
     let name = doc.createElement("description");
-    let label = MarkerUtils.getMarkerLabel(marker);
+    let label = MarkerBlueprintUtils.getMarkerLabel(marker);
     name.className = "plain waterfall-marker-name";
     name.style.transform = `translateX(${this.level * LEVEL_INDENT}px)`;
     name.setAttribute("crop", "end");
     name.setAttribute("flex", "1");
     name.setAttribute("value", label);
     name.setAttribute("tooltiptext", label);
     cell.appendChild(name);
 
--- a/devtools/client/performance/modules/widgets/markers-overview.js
+++ b/devtools/client/performance/modules/widgets/markers-overview.js
@@ -11,17 +11,17 @@
 
 const { Cc, Ci, Cu, Cr } = require("chrome");
 const { Heritage } = require("resource://devtools/client/shared/widgets/ViewHelpers.jsm");
 const { AbstractCanvasGraph } = require("devtools/client/shared/widgets/Graphs");
 
 const { colorUtils } = require("devtools/shared/css-color");
 const { getColor } = require("devtools/client/shared/theme");
 const ProfilerGlobal = require("devtools/client/performance/modules/global");
-const MarkerUtils = require("devtools/client/performance/modules/logic/marker-utils");
+const { MarkerBlueprintUtils } = require("devtools/client/performance/modules/marker-blueprint-utils");
 const { TickUtils } = require("devtools/client/performance/modules/widgets/waterfall-ticks");
 const { TIMELINE_BLUEPRINT } = require("devtools/client/performance/modules/markers");
 
 const OVERVIEW_HEADER_HEIGHT = 14; // px
 const OVERVIEW_ROW_HEIGHT = 11; // px
 
 const OVERVIEW_SELECTION_LINE_COLOR = "#666";
 const OVERVIEW_CLIPHEAD_LINE_COLOR = "#555";
@@ -112,17 +112,17 @@ MarkersOverview.prototype = Heritage.ext
     let canvasWidth = this._width;
     let canvasHeight = this._height;
 
     // Group markers into separate paint batches. This is necessary to
     // draw all markers sharing the same style at once.
     for (let marker of markers) {
       // Again skip over markers that we're filtering -- we don't want them
       // to be labeled as "Unknown"
-      if (!MarkerUtils.isMarkerValid(marker, this._filter)) {
+      if (!MarkerBlueprintUtils.shouldDisplayMarker(marker, this._filter)) {
         continue;
       }
 
       let markerType = this._paintBatches.get(marker.name) || this._paintBatches.get("UNKNOWN");
       markerType.batch.push(marker);
     }
 
     // Calculate each row's height, and the time-based scaling.
--- a/devtools/client/performance/performance-controller.js
+++ b/devtools/client/performance/performance-controller.js
@@ -36,17 +36,17 @@ var system = require("devtools/shared/sy
 var { L10N } = require("devtools/client/performance/modules/global");
 var { PerformanceTelemetry } = require("devtools/client/performance/modules/logic/telemetry");
 var { TIMELINE_BLUEPRINT } = require("devtools/client/performance/modules/markers");
 var RecordingUtils = require("devtools/shared/performance/recording-utils");
 var { OptimizationsGraph, GraphsController } = require("devtools/client/performance/modules/widgets/graphs");
 var { WaterfallHeader } = require("devtools/client/performance/modules/widgets/waterfall-ticks");
 var { MarkerView } = require("devtools/client/performance/modules/widgets/marker-view");
 var { MarkerDetails } = require("devtools/client/performance/modules/widgets/marker-details");
-var MarkerUtils = require("devtools/client/performance/modules/logic/marker-utils");
+var { MarkerBlueprintUtils } = require("devtools/client/performance/modules/marker-blueprint-utils");
 var WaterfallUtils = require("devtools/client/performance/modules/logic/waterfall-utils");
 var FrameUtils = require("devtools/client/performance/modules/logic/frame-utils");
 var { CallView } = require("devtools/client/performance/modules/widgets/tree-view");
 var { ThreadNode } = require("devtools/client/performance/modules/logic/tree-model");
 var { FrameNode } = require("devtools/client/performance/modules/logic/tree-model");
 
 // Widgets modules
 
--- a/devtools/client/performance/test/browser_timeline-waterfall-sidebar.js
+++ b/devtools/client/performance/test/browser_timeline-waterfall-sidebar.js
@@ -4,17 +4,17 @@
 /**
  * Tests if the sidebar is properly updated when a marker is selected.
  */
 
 function* spawnTest() {
   let { target, panel } = yield initPerformance(SIMPLE_URL);
   let { $, $$, PerformanceController, WaterfallView } = panel.panelWin;
   let { L10N } = require("devtools/client/performance/modules/global");
-  let { getMarkerLabel } = require("devtools/client/performance/modules/logic/marker-utils");
+  let { MarkerBlueprintUtils } = require("devtools/client/performance/modules/marker-blueprint-utils");
 
   // Hijack the markers massaging part of creating the waterfall view,
   // to prevent collapsing markers and allowing this test to verify
   // everything individually. A better solution would be to just expand
   // all markers first and then skip the meta nodes, but I'm lazy.
   WaterfallView._prepareWaterfallTree = markers => {
     return { submarkers: markers };
   };
@@ -55,17 +55,17 @@ function* spawnTest() {
 
     let type = $(".marker-details-type").getAttribute("value");
     let tooltip = $(".marker-details-duration").getAttribute("tooltiptext");
     let duration = $(".marker-details-duration .marker-details-labelvalue").getAttribute("value");
 
     info("Current marker data: " + mkr.toSource());
     info("Current marker output: " + $("#waterfall-details").innerHTML);
 
-    is(type, getMarkerLabel(mkr), "Sidebar title matches markers name.");
+    is(type, MarkerBlueprintUtils.getMarkerLabel(mkr), "Sidebar title matches markers name.");
 
     // Values are rounded. We don't use a strict equality.
     is(toMs(mkr.end - mkr.start), duration, "Sidebar duration is valid.");
 
     // For some reason, anything that creates "→" here turns it into a "â" for some reason.
     // So just check that start and end time are in there somewhere.
     ok(tooltip.indexOf(toMs(mkr.start)) !== -1, "Tooltip has start time.");
     ok(tooltip.indexOf(toMs(mkr.end)) !== -1, "Tooltip has end time.");
--- a/devtools/client/performance/test/unit/test_marker-utils.js
+++ b/devtools/client/performance/test/unit/test_marker-utils.js
@@ -7,95 +7,95 @@
 
 function run_test() {
   run_next_test();
 }
 
 add_task(function () {
   let { TIMELINE_BLUEPRINT } = require("devtools/client/performance/modules/markers");
   let { PREFS } = require("devtools/client/performance/modules/global");
-  let Utils = require("devtools/client/performance/modules/logic/marker-utils");
+  let { MarkerBlueprintUtils } = require("devtools/client/performance/modules/marker-blueprint-utils");
 
   PREFS.registerObserver();
 
   Services.prefs.setBoolPref(PLATFORM_DATA_PREF, false);
 
-  equal(Utils.getMarkerLabel({ name: "DOMEvent" }), "DOM Event",
+  equal(MarkerBlueprintUtils.getMarkerLabel({ name: "DOMEvent" }), "DOM Event",
     "getMarkerLabel() returns a simple label");
-  equal(Utils.getMarkerLabel({ name: "Javascript", causeName: "setTimeout handler" }), "setTimeout",
+  equal(MarkerBlueprintUtils.getMarkerLabel({ name: "Javascript", causeName: "setTimeout handler" }), "setTimeout",
     "getMarkerLabel() returns a label defined via function");
-  equal(Utils.getMarkerLabel({ name: "GarbageCollection", causeName: "ALLOC_TRIGGER" }), "Incremental GC",
+  equal(MarkerBlueprintUtils.getMarkerLabel({ name: "GarbageCollection", causeName: "ALLOC_TRIGGER" }), "Incremental GC",
     "getMarkerLabel() returns a label for a function that is generalizable");
 
-  ok(Utils.getMarkerFields({ name: "Paint" }).length === 0,
+  ok(MarkerBlueprintUtils.getMarkerFields({ name: "Paint" }).length === 0,
     "getMarkerFields() returns an empty array when no fields defined");
 
-  let fields = Utils.getMarkerFields({ name: "ConsoleTime", causeName: "snowstorm" });
+  let fields = MarkerBlueprintUtils.getMarkerFields({ name: "ConsoleTime", causeName: "snowstorm" });
   equal(fields[0].label, "Timer Name:", "getMarkerFields() returns an array with proper label");
   equal(fields[0].value, "snowstorm", "getMarkerFields() returns an array with proper value");
 
-  fields = Utils.getMarkerFields({ name: "DOMEvent", type: "mouseclick" });
+  fields = MarkerBlueprintUtils.getMarkerFields({ name: "DOMEvent", type: "mouseclick" });
   equal(fields.length, 1, "getMarkerFields() ignores fields that are not found on marker");
   equal(fields[0].label, "Event Type:", "getMarkerFields() returns an array with proper label");
   equal(fields[0].value, "mouseclick", "getMarkerFields() returns an array with proper value");
 
-  fields = Utils.getMarkerFields({ name: "DOMEvent", eventPhase: Ci.nsIDOMEvent.AT_TARGET, type: "mouseclick" });
+  fields = MarkerBlueprintUtils.getMarkerFields({ name: "DOMEvent", eventPhase: Ci.nsIDOMEvent.AT_TARGET, type: "mouseclick" });
   equal(fields.length, 2, "getMarkerFields() returns multiple fields when using a fields function");
   equal(fields[0].label, "Event Type:", "getMarkerFields() correctly returns fields via function (1)");
   equal(fields[0].value, "mouseclick", "getMarkerFields() correctly returns fields via function (2)");
   equal(fields[1].label, "Phase:", "getMarkerFields() correctly returns fields via function (3)");
   equal(fields[1].value, "Target", "getMarkerFields() correctly returns fields via function (4)");
 
-  fields = Utils.getMarkerFields({ name: "GarbageCollection", causeName: "ALLOC_TRIGGER" });
+  fields = MarkerBlueprintUtils.getMarkerFields({ name: "GarbageCollection", causeName: "ALLOC_TRIGGER" });
   equal(fields[0].value, "Too Many Allocations", "Uses L10N for GC reasons");
 
-  fields = Utils.getMarkerFields({ name: "GarbageCollection", causeName: "NOT_A_GC_REASON" });
+  fields = MarkerBlueprintUtils.getMarkerFields({ name: "GarbageCollection", causeName: "NOT_A_GC_REASON" });
   equal(fields[0].value, "NOT_A_GC_REASON", "Defaults to enum for GC reasons when not L10N'd");
 
-  equal(Utils.getMarkerFields({ name: "Javascript", causeName: "Some Platform Field" })[0].value, "(Gecko)",
+  equal(MarkerBlueprintUtils.getMarkerFields({ name: "Javascript", causeName: "Some Platform Field" })[0].value, "(Gecko)",
     "Correctly obfuscates JS markers when platform data is off.");
   Services.prefs.setBoolPref(PLATFORM_DATA_PREF, true);
-  equal(Utils.getMarkerFields({ name: "Javascript", causeName: "Some Platform Field" })[0].value, "Some Platform Field",
+  equal(MarkerBlueprintUtils.getMarkerFields({ name: "Javascript", causeName: "Some Platform Field" })[0].value, "Some Platform Field",
     "Correctly deobfuscates JS markers when platform data is on.");
 
-  equal(Utils.getMarkerClassName("Javascript"), "Function Call",
-    "getMarkerClassName() returns correct string when defined via function");
-  equal(Utils.getMarkerClassName("GarbageCollection"), "Garbage Collection",
-    "getMarkerClassName() returns correct string when defined via function");
-  equal(Utils.getMarkerClassName("Reflow"), "Layout",
-    "getMarkerClassName() returns correct string when defined via string");
+  equal(MarkerBlueprintUtils.getMarkerGenericName("Javascript"), "Function Call",
+    "getMarkerGenericName() returns correct string when defined via function");
+  equal(MarkerBlueprintUtils.getMarkerGenericName("GarbageCollection"), "Garbage Collection",
+    "getMarkerGenericName() returns correct string when defined via function");
+  equal(MarkerBlueprintUtils.getMarkerGenericName("Reflow"), "Layout",
+    "getMarkerGenericName() returns correct string when defined via string");
 
   TIMELINE_BLUEPRINT["fakemarker"] = { group: 0 };
   try {
-    Utils.getMarkerClassName("fakemarker");
-    ok(false, "getMarkerClassName() should throw when no label on blueprint.");
+    MarkerBlueprintUtils.getMarkerGenericName("fakemarker");
+    ok(false, "getMarkerGenericName() should throw when no label on blueprint.");
   } catch (e) {
-    ok(true, "getMarkerClassName() should throw when no label on blueprint.");
+    ok(true, "getMarkerGenericName() should throw when no label on blueprint.");
   }
 
   TIMELINE_BLUEPRINT["fakemarker"] = { group: 0, label: () => void 0 };
   try {
-    Utils.getMarkerClassName("fakemarker");
-    ok(false, "getMarkerClassName() should throw when label function returnd undefined.");
+    MarkerBlueprintUtils.getMarkerGenericName("fakemarker");
+    ok(false, "getMarkerGenericName() should throw when label function returnd undefined.");
   } catch (e) {
-    ok(true, "getMarkerClassName() should throw when label function returnd undefined.");
+    ok(true, "getMarkerGenericName() should throw when label function returnd undefined.");
   }
 
   delete TIMELINE_BLUEPRINT["fakemarker"];
 
   let customBlueprint = {
     UNKNOWN: {
       group: 1,
       label: "MyDefault"
     },
     custom: {
       group: 0,
       label: "MyCustom"
     }
   };
 
-  equal(Utils.getBlueprintFor({ name: "Reflow" }).label, "Layout",
-    "Utils.getBlueprintFor() should return marker def for passed in marker.");
-  equal(Utils.getBlueprintFor({ name: "Not sure!" }).label(), "Unknown",
-    "Utils.getBlueprintFor() should return a default marker def if the marker is undefined.");
+  equal(MarkerBlueprintUtils.getBlueprintFor({ name: "Reflow" }).label, "Layout",
+    "getBlueprintFor() should return marker def for passed in marker.");
+  equal(MarkerBlueprintUtils.getBlueprintFor({ name: "Not sure!" }).label(), "Unknown",
+    "getBlueprintFor() should return a default marker def if the marker is undefined.");
 
   PREFS.unregisterObserver();
 });
--- a/devtools/client/performance/views/toolbar.js
+++ b/devtools/client/performance/views/toolbar.js
@@ -56,17 +56,17 @@ var ToolbarView = {
    */
   _buildMarkersFilterPopup: function() {
     for (let [markerName, markerDetails] of Iterator(TIMELINE_BLUEPRINT)) {
       let menuitem = document.createElement("menuitem");
       menuitem.setAttribute("closemenu", "none");
       menuitem.setAttribute("type", "checkbox");
       menuitem.setAttribute("align", "center");
       menuitem.setAttribute("flex", "1");
-      menuitem.setAttribute("label", MarkerUtils.getMarkerClassName(markerName));
+      menuitem.setAttribute("label", MarkerBlueprintUtils.getMarkerGenericName(markerName));
       menuitem.setAttribute("marker-type", markerName);
       menuitem.className = `marker-color-${markerDetails.colorName}`;
 
       menuitem.addEventListener("command", this._onHiddenMarkersChanged);
 
       $("#performance-filter-menupopup").appendChild(menuitem);
     }
   },