<commit_before>/* See license.txt for terms of usage */

"use strict";

module.metadata = {
  "stability": "unstable"
};

// Firebug SDK
const { Locale } = require("firebug.sdk/lib/core/locale.js");
const { Content } = require("firebug.sdk/lib/core/content.js");
const { Dom } = require("firebug.sdk/lib/core/dom.js");
const { Str } = require("firebug.sdk/lib/core/string.js");

const self = require("sdk/self");
const main = require("../main.js");

const { Cu } = require("chrome");
const { Panel } = require("dev/panel.js");
const { Class } = require("sdk/core/heritage");
const { Trace, TraceError } = require("firebug.sdk/lib/core/trace.js").get(module.id);
const { PanelToolbar, ToolbarButton } = require("./panel-toolbar.js");
const { Xul } = require("../core/xul.js");
const { when } = require("sdk/event/utils");
const { Theme } = require("./theme.js");
const { TabMenu } = require("./tab-menu.js");
const { createView } = require("dev/panel/view");
const { viewFor } = require("sdk/view/core");
const { once } = require("sdk/event/core");
const { TextSearch } = require("../chrome/text-search.js");
const { Css } = require("../core/css.js");
const { loadSheet } = require("sdk/stylesheet/utils");

// DevTools
const { devtools, EventEmitter, ToolSidebar } = require("firebug.sdk/lib/core/devtools.js");

// Shortcuts
const { BOX, VBOX, HBOX, SPLITTER, TABBOX, TABS, TABPANELS, IFRAME } = Xul;

/**
 * Base object for {@Toolbox} panels. Every Panel object should be derived
 * from this object. This object is also used for panel overlays - i.e. for
 * customization of built-in panels, see {@BaseOverlay}.
 */
const BasePanel = Class(
/** @lends BasePanel */
{
  extends: Panel,

  searchable: false,

  initialize: function(options) {
    Trace.sysout("basePanel.initialize;", options);

    EventEmitter.decorate(this);

    this.sidePanels = new Map();

    // Register theme listener to receive notifications
    // when Firebug theme is activated or deactivated.
    let applyTheme = this.applyTheme.bind(this);
    let unapplyTheme = this.unapplyTheme.bind(this);
    Theme.addThemeListeners(applyTheme, unapplyTheme);
  },

  /**
   * Executed by the framework when an overlaid panel is destroyed.
   */
  destroy: function() {
    this.destroyTabMenu();

    if (this.toggleSideBar) {
      this.toggleSideBar.destroy();
    }
  },

  /**
   * Executed by SDK framework for custom panels (not for overlays).
   */
  dispose: function() {
    Trace.sysout("basePanel.dispose;");

    this.destroy();

    delete this.debuggee;
  },

  /**
   * Executed by the framework when panel frame needs to be created.
   *
   * @return An instance of <iframe> element.
   */
  createView: function(document, panelFrame) {
    Trace.sysout("basePanel.createView; " + this.id);

    // Get the panel container element.
    let parentNode = document.getElementById("toolbox-panel-" + this.id);

    // Definition of the new panel content layout.
    let content =
      HBOX({"class": "panelContent", "flex": "1"},
        VBOX({"id": "panelMainBox", "flex": "1"}),
        SPLITTER({"id": "panelSplitter", "class": "devtools-side-splitter",
          "valign": "top"},
            BOX({"class": "panelSplitterBox"})
        ),
        TABBOX({"id": "panelSideBox",
          "class": "devtools-sidebar-tabs",
          "width": "300px",
          "handleCtrlTab": "false"},
            TABS(),
            TABPANELS({"flex": "1"})
        )
      );

    this.panelContent = content.build(parentNode);
    let mainBox = this.panelContent.querySelector("#panelMainBox");

    // Create a toolbar for the main panel.
    let mainToolbar = new PanelToolbar({
      parentNode: mainBox,
    });

    // Populate the toolbar with buttons defined by this panel.
    let items = this.getPanelToolbarButtons();
    if (items) {
      mainToolbar.createItems(items);
    }

    // Build panel frame if default one isn't provided. Otherwise
    // just make sure the frame is inserted at the right location
    // in the DOM.
    if (!panelFrame) {
      panelFrame = IFRAME({
        "sandbox": "allow-scripts",
        "type": "content",
        "flex": "1",
        "id": "toolbox-panel-iframe-" + this.id,
        "transparent": true,
        "seamless": "seamless"}).build(mainBox);
    } else {
      // Insert the frame at the right location.
      mainBox.appendChild(panelFrame);
    }

    // Create side box and populate it by side-panels defined
    // by this panel instance.
    let sideBox = this.panelContent.querySelector("#panelSideBox");
    this.sidebar = new ToolSidebar(sideBox, this, this.id + "-sidebar");
    this.sidebar.on("select", (event, toolId) => {
      // TODO: remember the last selected side panel.
    });

    this.setupSidePanels();

    // Return the panel frame.
    return panelFrame;
  },

 /**
  * This method is called to setup new panels. It isn't executed
  * for Panel overlays. Built in panel are already setup.
  */
  setup: function(options) {
    Trace.sysout("basePanel.setup;", options);

    let frame = options.frame || viewFor(this);
    let parentWin = frame.ownerDocument.defaultView;

    if (!frame) {
      TraceError.sysout("basePanel.setup; ERRO no panel frame!", options);
    }

    this.panelFrame = frame;
    this.debuggee = options.debuggee;<commit_msg>Fix typo<commit_after>/* See license.txt for terms of usage */

"use strict";

module.metadata = {
  "stability": "unstable"
};

// Firebug SDK
const { Locale } = require("firebug.sdk/lib/core/locale.js");
const { Content } = require("firebug.sdk/lib/core/content.js");
const { Dom } = require("firebug.sdk/lib/core/dom.js");
const { Str } = require("firebug.sdk/lib/core/string.js");

const self = require("sdk/self");
const main = require("../main.js");

const { Cu } = require("chrome");
const { Panel } = require("dev/panel.js");
const { Class } = require("sdk/core/heritage");
const { Trace, TraceError } = require("firebug.sdk/lib/core/trace.js").get(module.id);
const { PanelToolbar, ToolbarButton } = require("./panel-toolbar.js");
const { Xul } = require("../core/xul.js");
const { when } = require("sdk/event/utils");
const { Theme } = require("./theme.js");
const { TabMenu } = require("./tab-menu.js");
const { createView } = require("dev/panel/view");
const { viewFor } = require("sdk/view/core");
const { once } = require("sdk/event/core");
const { TextSearch } = require("../chrome/text-search.js");
const { Css } = require("../core/css.js");
const { loadSheet } = require("sdk/stylesheet/utils");

// DevTools
const { devtools, EventEmitter, ToolSidebar } = require("firebug.sdk/lib/core/devtools.js");

// Shortcuts
const { BOX, VBOX, HBOX, SPLITTER, TABBOX, TABS, TABPANELS, IFRAME } = Xul;

/**
 * Base object for {@Toolbox} panels. Every Panel object should be derived
 * from this object. This object is also used for panel overlays - i.e. for
 * customization of built-in panels, see {@BaseOverlay}.
 */
const BasePanel = Class(
/** @lends BasePanel */
{
  extends: Panel,

  searchable: false,

  initialize: function(options) {
    Trace.sysout("basePanel.initialize;", options);

    EventEmitter.decorate(this);

    this.sidePanels = new Map();

    // Register theme listener to receive notifications
    // when Firebug theme is activated or deactivated.
    let applyTheme = this.applyTheme.bind(this);
    let unapplyTheme = this.unapplyTheme.bind(this);
    Theme.addThemeListeners(applyTheme, unapplyTheme);
  },

  /**
   * Executed by the framework when an overlaid panel is destroyed.
   */
  destroy: function() {
    this.destroyTabMenu();

    if (this.toggleSideBar) {
      this.toggleSideBar.destroy();
    }
  },

  /**
   * Executed by SDK framework for custom panels (not for overlays).
   */
  dispose: function() {
    Trace.sysout("basePanel.dispose;");

    this.destroy();

    delete this.debuggee;
  },

  /**
   * Executed by the framework when panel frame needs to be created.
   *
   * @return An instance of <iframe> element.
   */
  createView: function(document, panelFrame) {
    Trace.sysout("basePanel.createView; " + this.id);

    // Get the panel container element.
    let parentNode = document.getElementById("toolbox-panel-" + this.id);

    // Definition of the new panel content layout.
    let content =
      HBOX({"class": "panelContent", "flex": "1"},
        VBOX({"id": "panelMainBox", "flex": "1"}),
        SPLITTER({"id": "panelSplitter", "class": "devtools-side-splitter",
          "valign": "top"},
            BOX({"class": "panelSplitterBox"})
        ),
        TABBOX({"id": "panelSideBox",
          "class": "devtools-sidebar-tabs",
          "width": "300px",
          "handleCtrlTab": "false"},
            TABS(),
            TABPANELS({"flex": "1"})
        )
      );

    this.panelContent = content.build(parentNode);
    let mainBox = this.panelContent.querySelector("#panelMainBox");

    // Create a toolbar for the main panel.
    let mainToolbar = new PanelToolbar({
      parentNode: mainBox,
    });

    // Populate the toolbar with buttons defined by this panel.
    let items = this.getPanelToolbarButtons();
    if (items) {
      mainToolbar.createItems(items);
    }

    // Build panel frame if default one isn't provided. Otherwise
    // just make sure the frame is inserted at the right location
    // in the DOM.
    if (!panelFrame) {
      panelFrame = IFRAME({
        "sandbox": "allow-scripts",
        "type": "content",
        "flex": "1",
        "id": "toolbox-panel-iframe-" + this.id,
        "transparent": true,
        "seamless": "seamless"}).build(mainBox);
    } else {
      // Insert the frame at the right location.
      mainBox.appendChild(panelFrame);
    }

    // Create side box and populate it by side-panels defined
    // by this panel instance.
    let sideBox = this.panelContent.querySelector("#panelSideBox");
    this.sidebar = new ToolSidebar(sideBox, this, this.id + "-sidebar");
    this.sidebar.on("select", (event, toolId) => {
      // TODO: remember the last selected side panel.
    });

    this.setupSidePanels();

    // Return the panel frame.
    return panelFrame;
  },

 /**
  * This method is called to setup new panels. It isn't executed
  * for Panel overlays. Built in panel are already setup.
  */
  setup: function(options) {
    Trace.sysout("basePanel.setup;", options);

    let frame = options.frame || viewFor(this);
    let parentWin = frame.ownerDocument.defaultView;

    if (!frame) {
      TraceError.sysout("basePanel.setup; ERROR no panel frame!", options);
    }

    this.panelFrame = frame;
    this.debuggee = options.debuggee;
{'fraction_non_alphanumeric': 0.15277516462841015, 'fraction_numerical': 0.001317027281279398, 'mean_word_length': 3.0268939393939394, 'pattern_counts': {'":': 40, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5252504', 'n_tokens_mistral': 3320, 'n_tokens_neox': 3234, 'n_words': 854}