Bug 1505299 - Remove unused SimpleListWidget r=gl
authorui.manish <1991manish.kumar@gmail.com>
Sat, 23 Feb 2019 20:39:57 +0000
changeset 518646 1549e3c7bc5161ad2d447f19b96c6d233c838698
parent 518645 94e616a3a7a0bed27cdf035b910895e9e658648b
child 518647 5ddf9d49a6b3c843ad1c353a8ba9d3195f63e44e
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgl
bugs1505299
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1505299 - Remove unused SimpleListWidget r=gl Differential Revision: https://phabricator.services.mozilla.com/D20928
devtools/client/shared/widgets/SimpleListWidget.jsm
devtools/client/shared/widgets/moz.build
devtools/client/shared/widgets/view-helpers.js
devtools/client/shared/widgets/widgets.css
devtools/client/themes/widgets.css
deleted file mode 100644
--- a/devtools/client/shared/widgets/SimpleListWidget.jsm
+++ /dev/null
@@ -1,251 +0,0 @@
-/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
-/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-"use strict";
-
-const { require } = ChromeUtils.import("resource://devtools/shared/Loader.jsm");
-const { ViewHelpers } = require("devtools/client/shared/widgets/view-helpers");
-
-this.EXPORTED_SYMBOLS = ["SimpleListWidget"];
-
-/**
- * A very simple vertical list view.
- *
- * Note: this widget should be used in tandem with the WidgetMethods in
- * view-helpers.js.
- *
- * @param Node aNode
- *        The element associated with the widget.
- */
-function SimpleListWidget(aNode) {
-  this.document = aNode.ownerDocument;
-  this.window = this.document.defaultView;
-  this._parent = aNode;
-
-  // Create an internal list container.
-  this._list = this.document.createElement("scrollbox");
-  this._list.className = "simple-list-widget-container theme-body";
-  this._list.setAttribute("flex", "1");
-  this._list.setAttribute("orient", "vertical");
-  this._parent.appendChild(this._list);
-
-  // Delegate some of the associated node's methods to satisfy the interface
-  // required by WidgetMethods instances.
-  ViewHelpers.delegateWidgetAttributeMethods(this, aNode);
-  ViewHelpers.delegateWidgetEventMethods(this, aNode);
-}
-this.SimpleListWidget = SimpleListWidget;
-
-SimpleListWidget.prototype = {
-  /**
-   * Inserts an item in this container at the specified index.
-   *
-   * @param number aIndex
-   *        The position in the container intended for this item.
-   * @param Node aContents
-   *        The node displayed in the container.
-   * @return Node
-   *         The element associated with the displayed item.
-   */
-  insertItemAt: function(aIndex, aContents) {
-    aContents.classList.add("simple-list-widget-item");
-
-    const list = this._list;
-    return list.insertBefore(aContents, list.childNodes[aIndex]);
-  },
-
-  /**
-   * Returns the child node in this container situated at the specified index.
-   *
-   * @param number aIndex
-   *        The position in the container intended for this item.
-   * @return Node
-   *         The element associated with the displayed item.
-   */
-  getItemAtIndex: function(aIndex) {
-    return this._list.childNodes[aIndex];
-  },
-
-  /**
-   * Immediately removes the specified child node from this container.
-   *
-   * @param Node aChild
-   *        The element associated with the displayed item.
-   */
-  removeChild: function(aChild) {
-    this._list.removeChild(aChild);
-
-    if (this._selectedItem == aChild) {
-      this._selectedItem = null;
-    }
-  },
-
-  /**
-   * Removes all of the child nodes from this container.
-   */
-  removeAllItems: function() {
-    const list = this._list;
-    const parent = this._parent;
-
-    while (list.hasChildNodes()) {
-      list.firstChild.remove();
-    }
-
-    parent.scrollTop = 0;
-    parent.scrollLeft = 0;
-    this._selectedItem = null;
-  },
-
-  /**
-   * Gets the currently selected child node in this container.
-   * @return Node
-   */
-  get selectedItem() {
-    return this._selectedItem;
-  },
-
-  /**
-   * Sets the currently selected child node in this container.
-   * @param Node aChild
-   */
-  set selectedItem(aChild) {
-    const childNodes = this._list.childNodes;
-
-    if (!aChild) {
-      this._selectedItem = null;
-    }
-    for (const node of childNodes) {
-      if (node == aChild) {
-        node.classList.add("selected");
-        this._selectedItem = node;
-      } else {
-        node.classList.remove("selected");
-      }
-    }
-  },
-
-  /**
-   * Adds a new attribute or changes an existing attribute on this container.
-   *
-   * @param string aName
-   *        The name of the attribute.
-   * @param string aValue
-   *        The desired attribute value.
-   */
-  setAttribute: function(aName, aValue) {
-    this._parent.setAttribute(aName, aValue);
-
-    if (aName == "emptyText") {
-      this._textWhenEmpty = aValue;
-    } else if (aName == "headerText") {
-      this._textAsHeader = aValue;
-    }
-  },
-
-  /**
-   * Removes an attribute on this container.
-   *
-   * @param string aName
-   *        The name of the attribute.
-   */
-  removeAttribute: function(aName) {
-    this._parent.removeAttribute(aName);
-
-    if (aName == "emptyText") {
-      this._removeEmptyText();
-    }
-  },
-
-  /**
-   * Ensures the specified element is visible.
-   *
-   * @param Node aElement
-   *        The element to make visible.
-   */
-  ensureElementIsVisible: function(aElement) {
-    if (!aElement) {
-      return;
-    }
-
-    // Ensure the element is visible but not scrolled horizontally.
-    aElement.scrollIntoView({ block: "nearest" });
-    this._list.scrollBy(-this._list.clientWidth, 0);
-  },
-
-  /**
-   * Sets the text displayed permanently in this container as a header.
-   * @param string aValue
-   */
-  set _textAsHeader(aValue) {
-    if (this._headerTextNode) {
-      this._headerTextNode.setAttribute("value", aValue);
-    }
-    this._headerTextValue = aValue;
-    this._showHeaderText();
-  },
-
-  /**
-   * Sets the text displayed in this container when empty.
-   * @param string aValue
-   */
-  set _textWhenEmpty(aValue) {
-    if (this._emptyTextNode) {
-      this._emptyTextNode.setAttribute("value", aValue);
-    }
-    this._emptyTextValue = aValue;
-    this._showEmptyText();
-  },
-
-  /**
-   * Creates and appends a label displayed as this container's header.
-   */
-  _showHeaderText: function() {
-    if (this._headerTextNode || !this._headerTextValue) {
-      return;
-    }
-    const label = this.document.createElement("label");
-    label.className = "plain simple-list-widget-perma-text";
-    label.setAttribute("value", this._headerTextValue);
-
-    this._parent.insertBefore(label, this._list);
-    this._headerTextNode = label;
-  },
-
-  /**
-   * Creates and appends a label signaling that this container is empty.
-   */
-  _showEmptyText: function() {
-    if (this._emptyTextNode || !this._emptyTextValue) {
-      return;
-    }
-    const label = this.document.createElement("label");
-    label.className = "plain simple-list-widget-empty-text";
-    label.setAttribute("value", this._emptyTextValue);
-
-    this._parent.appendChild(label);
-    this._emptyTextNode = label;
-  },
-
-  /**
-   * Removes the label signaling that this container is empty.
-   */
-  _removeEmptyText: function() {
-    if (!this._emptyTextNode) {
-      return;
-    }
-    this._parent.removeChild(this._emptyTextNode);
-    this._emptyTextNode = null;
-  },
-
-  window: null,
-  document: null,
-  _parent: null,
-  _list: null,
-  _selectedItem: null,
-  _headerTextNode: null,
-  _headerTextValue: "",
-  _emptyTextNode: null,
-  _emptyTextValue: "",
-};
--- a/devtools/client/shared/widgets/moz.build
+++ b/devtools/client/shared/widgets/moz.build
@@ -19,16 +19,15 @@ DevToolsModules(
     'FilterWidget.js',
     'FlameGraph.js',
     'Graphs.js',
     'GraphsWorker.js',
     'LineGraphWidget.js',
     'MountainGraphWidget.js',
     'ShapesInContextEditor.js',
     'SideMenuWidget.jsm',
-    'SimpleListWidget.jsm',
     'Spectrum.js',
     'TableWidget.js',
     'TreeWidget.js',
     'VariablesView.jsm',
     'VariablesViewController.jsm',
     'view-helpers.js',
 )
--- a/devtools/client/shared/widgets/view-helpers.js
+++ b/devtools/client/shared/widgets/view-helpers.js
@@ -469,18 +469,16 @@ Item.prototype = {
  *   }
  *
  *   MyView.prototype = extend(WidgetMethods, {
  *     myMethod: function() {},
  *     ...
  *   });
  *
  * See https://gist.github.com/victorporof/5749386 for more details.
- * The devtools/shared/widgets/SimpleListWidget.jsm is an implementation
- * example.
  *
  * Language:
  *   - An "item" is an instance of an Item.
  *   - An "element" or "node" is a Node.
  *
  * The supplied widget can be any object implementing the following
  * methods:
  *   - function:Node insertItemAt(aIndex:number, aNode:Node,
--- a/devtools/client/shared/widgets/widgets.css
+++ b/devtools/client/shared/widgets/widgets.css
@@ -8,23 +8,16 @@
 .breadcrumbs-widget-item {
   direction: ltr;
 }
 
 .breadcrumbs-widget-item {
   -moz-user-focus: normal;
 }
 
-/* SimpleListWidget */
-
-.simple-list-widget-container {
-  overflow-x: hidden;
-  overflow-y: auto;
-}
-
 /* FastListWidget */
 
 .fast-list-widget-container {
   overflow: auto;
 }
 
 /* SideMenuWidget */
 
--- a/devtools/client/themes/widgets.css
+++ b/devtools/client/themes/widgets.css
@@ -96,46 +96,16 @@
     /* To hide generic-toggled-pane, negative margins are applied dynamically.
      * If a vertical layout, the pane is on the bottom and should be hidden
      * using negative bottom margin only.
      */
     margin-inline-end: 0 !important;
   }
 }
 
-/* SimpleListWidget */
-
-.simple-list-widget-container {
-  /* Hack: force hardware acceleration */
-  transform: translateZ(1px);
-}
-
-.simple-list-widget-item.selected {
-  background-color: var(--theme-selection-background);
-  color: var(--theme-selection-color);
-}
-
-.theme-dark .simple-list-widget-item:not(.selected):hover {
-  background-color: rgba(255,255,255,.05);
-}
-
-.theme-light .simple-list-widget-item:not(.selected):hover {
-  background-color: rgba(0,0,0,.05);
-}
-
-.simple-list-widget-empty-text,
-.simple-list-widget-perma-text {
-  padding: 4px 8px;
-}
-
-.simple-list-widget-empty-text,
-.simple-list-widget-perma-text {
-  color: var(--theme-body-color-alt);
-}
-
 /* FastListWidget */
 
 .fast-list-widget-container {
   /* Hack: force hardware acceleration */
   transform: translateZ(1px);
 }
 
 .fast-list-widget-empty-text {