Commit 07737959 authored by Victor Porof's avatar Victor Porof
Browse files

Bug 1561435 - Format toolkit/content/, a=automatic-formatting

# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D36053

--HG--
extra : source : 651d8f947a29f5d80b7e833f7e6b99e2afe8bf9d
parent 4a06c925
Loading
Loading
Loading
Loading
+13 −7
Original line number Diff line number Diff line
@@ -29,18 +29,24 @@
  setFocusToVideoElement();

  // Opt out of moving focus away if the DOM tree changes (from add-on or web content)
  let observer = new MutationObserver(
    () => {
  let observer = new MutationObserver(() => {
    observer.disconnect();
    document.removeEventListener("focus", setFocusToVideoElement, true);
  });
  observer.observe(document.documentElement, { childList: true, subtree: true });
  observer.observe(document.documentElement, {
    childList: true,
    subtree: true,
  });

  // Handle fullscreen mode
  document.addEventListener("keypress", ev => {
    // Maximize the standalone video when pressing F11,
    // but ignore audio elements
    if (ev.key == "F11" && videoElement.videoWidth != 0 && videoElement.videoHeight != 0) {
    if (
      ev.key == "F11" &&
      videoElement.videoWidth != 0 &&
      videoElement.videoHeight != 0
    ) {
      // If we're in browser fullscreen mode, it means the user pressed F11
      // while browser chrome or another tab had focus.
      // Don't break leaving that mode, so do nothing here.
+4 −2
Original line number Diff line number Diff line
@@ -5,7 +5,9 @@
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");

// get release notes and vendor URL from prefs
var releaseNotesURL = Services.urlFormatter.formatURLPref("app.releaseNotesURL");
var releaseNotesURL = Services.urlFormatter.formatURLPref(
  "app.releaseNotesURL"
);
if (releaseNotesURL != "about:blank") {
  var relnotes = document.getElementById("releaseNotesURL");
  relnotes.setAttribute("href", releaseNotesURL);
+3 −1
Original line number Diff line number Diff line
@@ -2,7 +2,9 @@
 * 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/. */

const {AboutPagesUtils} = ChromeUtils.import("resource://gre/modules/AboutPagesUtils.jsm");
const { AboutPagesUtils } = ChromeUtils.import(
  "resource://gre/modules/AboutPagesUtils.jsm"
);

var gContainer;
window.onload = function() {
+61 −49
Original line number Diff line number Diff line
@@ -5,31 +5,36 @@
"use strict";

const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
const FileUtils = ChromeUtils.import("resource://gre/modules/FileUtils.jsm").FileUtils;
const gEnv = Cc["@mozilla.org/process/environment;1"]
               .getService(Ci.nsIEnvironment);
const gDashboard = Cc["@mozilla.org/network/dashboard;1"]
                     .getService(Ci.nsIDashboard);
const gDirServ = Cc["@mozilla.org/file/directory_service;1"]
                   .getService(Ci.nsIDirectoryServiceProvider);
const gNetLinkSvc = Cc["@mozilla.org/network/network-link-service;1"]
                      .getService(Ci.nsINetworkLinkService);
const FileUtils = ChromeUtils.import("resource://gre/modules/FileUtils.jsm")
  .FileUtils;
const gEnv = Cc["@mozilla.org/process/environment;1"].getService(
  Ci.nsIEnvironment
);
const gDashboard = Cc["@mozilla.org/network/dashboard;1"].getService(
  Ci.nsIDashboard
);
const gDirServ = Cc["@mozilla.org/file/directory_service;1"].getService(
  Ci.nsIDirectoryServiceProvider
);
const gNetLinkSvc = Cc[
  "@mozilla.org/network/network-link-service;1"
].getService(Ci.nsINetworkLinkService);

const gRequestNetworkingData = {
  "http": gDashboard.requestHttpConnections,
  "sockets": gDashboard.requestSockets,
  "dns": gDashboard.requestDNSInfo,
  "websockets": gDashboard.requestWebsocketConnections,
  "dnslookuptool": () => {},
  "logging": () => {},
  "rcwn": gDashboard.requestRcwnStats,
  http: gDashboard.requestHttpConnections,
  sockets: gDashboard.requestSockets,
  dns: gDashboard.requestDNSInfo,
  websockets: gDashboard.requestWebsocketConnections,
  dnslookuptool: () => {},
  logging: () => {},
  rcwn: gDashboard.requestRcwnStats,
};
const gDashboardCallbacks = {
  "http": displayHttp,
  "sockets": displaySockets,
  "dns": displayDns,
  "websockets": displayWebsockets,
  "rcwn": displayRcwnStats,
  http: displayHttp,
  sockets: displaySockets,
  dns: displayDns,
  websockets: displayWebsockets,
  rcwn: displayRcwnStats,
};

const REFRESH_INTERVAL_MS = 3000;
@@ -130,10 +135,14 @@ function displayWebsockets(data) {
function displayRcwnStats(data) {
  let status = Services.prefs.getBoolPref("network.http.rcwn.enabled");
  let linkType = gNetLinkSvc.linkType;
  if (!(linkType == Ci.nsINetworkLinkService.LINK_TYPE_UNKNOWN ||
  if (
    !(
      linkType == Ci.nsINetworkLinkService.LINK_TYPE_UNKNOWN ||
      linkType == Ci.nsINetworkLinkService.LINK_TYPE_ETHERNET ||
      linkType == Ci.nsINetworkLinkService.LINK_TYPE_USB ||
        linkType == Ci.nsINetworkLinkService.LINK_TYPE_WIFI)) {
      linkType == Ci.nsINetworkLinkService.LINK_TYPE_WIFI
    )
  ) {
    status = false;
  }

@@ -151,32 +160,28 @@ function displayRcwnStats(data) {
  document.getElementById("rcwn_cache_not_slow").innerText = cacheNotSlow;

  // Keep in sync with CachePerfStats::EDataType in CacheFileUtils.h
  const perfStatTypes = [
    "open",
    "read",
    "write",
    "entryopen",
  ];

  const perfStatFieldNames = [
    "avgShort",
    "avgLong",
    "stddevLong",
  ];
  const perfStatTypes = ["open", "read", "write", "entryopen"];

  const perfStatFieldNames = ["avgShort", "avgLong", "stddevLong"];

  for (let typeIndex in perfStatTypes) {
    for (let statFieldIndex in perfStatFieldNames) {
      document.getElementById("rcwn_perfstats_" + perfStatTypes[typeIndex] + "_"
                              + perfStatFieldNames[statFieldIndex]).innerText =
      document.getElementById(
        "rcwn_perfstats_" +
          perfStatTypes[typeIndex] +
          "_" +
          perfStatFieldNames[statFieldIndex]
      ).innerText =
        data.perfStats[typeIndex][perfStatFieldNames[statFieldIndex]];
    }
  }
}

function requestAllNetworkingData() {
  for (let id in gRequestNetworkingData)
  for (let id in gRequestNetworkingData) {
    requestNetworkingDataForTab(id);
  }
}

function requestNetworkingDataForTab(id) {
  gRequestNetworkingData[id](gDashboardCallbacks[id]);
@@ -199,8 +204,9 @@ function init() {
  requestAllNetworkingData();

  let autoRefresh = document.getElementById("autorefcheck");
  if (autoRefresh.checked)
  if (autoRefresh.checked) {
    setAutoRefreshInterval(autoRefresh);
  }

  autoRefresh.addEventListener("click", function() {
    let refrButton = document.getElementById("refreshButton");
@@ -215,14 +221,16 @@ function init() {

  let refr = document.getElementById("refreshButton");
  refr.addEventListener("click", requestAllNetworkingData);
  if (document.getElementById("autorefcheck").checked)
  if (document.getElementById("autorefcheck").checked) {
    refr.disabled = "disabled";
  }

  // Event delegation on #categories element
  let menu = document.getElementById("categories");
  menu.addEventListener("click", function click(e) {
    if (e.target && e.target.parentNode == menu)
    if (e.target && e.target.parentNode == menu) {
      show(e.target);
    }
  });

  let dnsLookupButton = document.getElementById("dnsLookupButton");
@@ -264,7 +272,9 @@ function init() {
  }

  if (location.hash) {
    let sectionButton = document.getElementById("category-" + location.hash.substring(1));
    let sectionButton = document.getElementById(
      "category-" + location.hash.substring(1)
    );
    if (sectionButton) {
      sectionButton.click();
    }
@@ -292,7 +302,8 @@ function updateLogFile() {

function updateLogModules() {
  // Try to get the environment variable for the log file
  let logModules = gEnv.get("MOZ_LOG") ||
  let logModules =
    gEnv.get("MOZ_LOG") ||
    gEnv.get("MOZ_LOG_MODULES") ||
    gEnv.get("NSPR_LOG_MODULES");
  let currentLogModules = document.getElementById("current-log-modules");
@@ -415,8 +426,9 @@ function show(button) {
  let current_tab = document.querySelector(".active");
  let category = button.getAttribute("id").substring("category-".length);
  let content = document.getElementById(category);
  if (current_tab == content)
  if (current_tab == content) {
    return;
  }
  current_tab.classList.remove("active");
  current_tab.hidden = true;
  content.classList.add("active");
+113 −60
Original line number Diff line number Diff line
@@ -5,7 +5,9 @@
"use strict";

const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
const { XPCOMUtils } = ChromeUtils.import(
  "resource://gre/modules/XPCOMUtils.jsm"
);

XPCOMUtils.defineLazyServiceGetter(
  this,
@@ -21,17 +23,28 @@ async function flush() {
  } catch (e) {
    let [title, msg, button] = await document.l10n.formatValues([
      { id: "profiles-flush-fail-title" },
      { id: e.result == Cr.NS_ERROR_DATABASE_CHANGED ?
                        "profiles-flush-conflict" :
                        "profiles-flush-failed" },
      {
        id:
          e.result == Cr.NS_ERROR_DATABASE_CHANGED
            ? "profiles-flush-conflict"
            : "profiles-flush-failed",
      },
      { id: "profiles-flush-restart-button" },
    ]);

    const PS = Ci.nsIPromptService;
    let result = Services.prompt.confirmEx(window, title, msg,
                                          (PS.BUTTON_POS_0 * PS.BUTTON_TITLE_CANCEL) +
                                          (PS.BUTTON_POS_1 * PS.BUTTON_TITLE_IS_STRING),
                                          null, button, null, null, {});
    let result = Services.prompt.confirmEx(
      window,
      title,
      msg,
      PS.BUTTON_POS_0 * PS.BUTTON_TITLE_CANCEL +
        PS.BUTTON_POS_1 * PS.BUTTON_TITLE_IS_STRING,
      null,
      button,
      null,
      null,
      {}
    );
    if (result == 1) {
      restart(false);
    }
@@ -59,9 +72,11 @@ function rebuildProfileList() {
        let lock = profile.lock({});
        lock.unlock();
      } catch (e) {
        if (e.result != Cr.NS_ERROR_FILE_TARGET_DOES_NOT_EXIST &&
        if (
          e.result != Cr.NS_ERROR_FILE_TARGET_DOES_NOT_EXIST &&
          e.result != Cr.NS_ERROR_FILE_NOT_DIRECTORY &&
            e.result != Cr.NS_ERROR_FILE_NOT_FOUND) {
          e.result != Cr.NS_ERROR_FILE_NOT_FOUND
        ) {
          isInUse = true;
        }
      }
@@ -84,8 +99,9 @@ function display(profileData) {
  let name = document.createElement("h2");

  div.appendChild(name);
  document.l10n.setAttributes(name, "profiles-name", { name: profileData.profile.name });

  document.l10n.setAttributes(name, "profiles-name", {
    name: profileData.profile.name,
  });

  if (profileData.isCurrentProfile) {
    let currentProfile = document.createElement("h3");
@@ -134,8 +150,10 @@ function display(profileData) {
    }
  }

  createItem("profiles-is-default",
    profileData.isDefault ? "profiles-yes" : "profiles-no");
  createItem(
    "profiles-is-default",
    profileData.isDefault ? "profiles-yes" : "profiles-no"
  );

  createItem("profiles-rootdir", profileData.profile.rootDir, true);

@@ -190,9 +208,12 @@ function CreateProfile(profile) {

function createProfileWizard() {
  // This should be rewritten in HTML eventually.
  window.openDialog("chrome://mozapps/content/profile/createProfileWizard.xul",
                    "", "centerscreen,chrome,modal,titlebar",
                    ProfileService);
  window.openDialog(
    "chrome://mozapps/content/profile/createProfileWizard.xul",
    "",
    "centerscreen,chrome,modal,titlebar",
    ProfileService
  );
}

async function renameProfile(profile) {
@@ -202,8 +223,7 @@ async function renameProfile(profile) {
    { id: "profiles-rename-profile", args: { name: profile.name } },
  ]);

  if (Services.prompt.prompt(window, title, msg, newName, null,
                             { value: 0 })) {
  if (Services.prompt.prompt(window, title, msg, newName, null, { value: 0 })) {
    newName = newName.value;

    if (newName == profile.name) {
@@ -230,20 +250,33 @@ async function removeProfile(profile) {
  let deleteFiles = false;

  if (profile.rootDir.exists()) {
    let [title, msg, dontDeleteStr, deleteStr] = await document.l10n.formatValues([
    let [
      title,
      msg,
      dontDeleteStr,
      deleteStr,
    ] = await document.l10n.formatValues([
      { id: "profiles-delete-profile-title" },
      { id: "profiles-delete-profile-confirm", args: { dir: profile.rootDir.path } },
      {
        id: "profiles-delete-profile-confirm",
        args: { dir: profile.rootDir.path },
      },
      { id: "profiles-dont-delete-files" },
      { id: "profiles-delete-files" },
    ]);
    let buttonPressed = Services.prompt.confirmEx(window, title, msg,
                          (Services.prompt.BUTTON_TITLE_IS_STRING * Services.prompt.BUTTON_POS_0) +
                          (Services.prompt.BUTTON_TITLE_CANCEL * Services.prompt.BUTTON_POS_1) +
                          (Services.prompt.BUTTON_TITLE_IS_STRING * Services.prompt.BUTTON_POS_2),
    let buttonPressed = Services.prompt.confirmEx(
      window,
      title,
      msg,
      Services.prompt.BUTTON_TITLE_IS_STRING * Services.prompt.BUTTON_POS_0 +
        Services.prompt.BUTTON_TITLE_CANCEL * Services.prompt.BUTTON_POS_1 +
        Services.prompt.BUTTON_TITLE_IS_STRING * Services.prompt.BUTTON_POS_2,
      dontDeleteStr,
      null,
      deleteStr,
                          null, {value: 0});
      null,
      { value: 0 }
    );
    if (buttonPressed == 1) {
      return;
    }
@@ -310,9 +343,14 @@ async function defaultProfile(profile) {
}

function openProfile(profile) {
  let cancelQuit = Cc["@mozilla.org/supports-PRBool;1"]
                     .createInstance(Ci.nsISupportsPRBool);
  Services.obs.notifyObservers(cancelQuit, "quit-application-requested", "restart");
  let cancelQuit = Cc["@mozilla.org/supports-PRBool;1"].createInstance(
    Ci.nsISupportsPRBool
  );
  Services.obs.notifyObservers(
    cancelQuit,
    "quit-application-requested",
    "restart"
  );

  if (cancelQuit.data) {
    return;
@@ -322,9 +360,14 @@ function openProfile(profile) {
}

function restart(safeMode) {
  let cancelQuit = Cc["@mozilla.org/supports-PRBool;1"]
                     .createInstance(Ci.nsISupportsPRBool);
  Services.obs.notifyObservers(cancelQuit, "quit-application-requested", "restart");
  let cancelQuit = Cc["@mozilla.org/supports-PRBool;1"].createInstance(
    Ci.nsISupportsPRBool
  );
  Services.obs.notifyObservers(
    cancelQuit,
    "quit-application-requested",
    "restart"
  );

  if (cancelQuit.data) {
    return;
@@ -339,19 +382,27 @@ function restart(safeMode) {
  }
}

window.addEventListener("DOMContentLoaded", function() {
window.addEventListener(
  "DOMContentLoaded",
  function() {
    let createButton = document.getElementById("create-button");
    createButton.addEventListener("click", createProfileWizard);

  let restartSafeModeButton = document.getElementById("restart-in-safe-mode-button");
    let restartSafeModeButton = document.getElementById(
      "restart-in-safe-mode-button"
    );
    if (!Services.policies || Services.policies.isAllowed("safeMode")) {
    restartSafeModeButton.addEventListener("click", () => { restart(true); });
      restartSafeModeButton.addEventListener("click", () => {
        restart(true);
      });
    } else {
      restartSafeModeButton.setAttribute("disabled", "true");
    }

    let restartNormalModeButton = document.getElementById("restart-button");
  restartNormalModeButton.addEventListener("click", () => { restart(false); });
    restartNormalModeButton.addEventListener("click", () => {
      restart(false);
    });

    if (ProfileService.isListOutdated) {
      document.getElementById("owned").hidden = true;
@@ -359,4 +410,6 @@ window.addEventListener("DOMContentLoaded", function() {
      document.getElementById("conflict").hidden = true;
      rebuildProfileList();
    }
}, {once: true});
  },
  { once: true }
);
Loading