Bug 1325464 - Enable object-shorthand rule and run 'mach eslint --fix' with the rule enabled. r=MattN

MozReview-Commit-ID: 7E7LPorrEje
This commit is contained in:
Jared Wein
2016-12-29 18:34:54 -05:00
parent 2de0319338
commit e3149c378f
824 changed files with 7775 additions and 7789 deletions

View File

@@ -8,19 +8,19 @@ var PointerlockFsWarning = {
_element: null,
_origin: null,
init: function() {
init() {
this.Timeout.prototype = {
start: function() {
start() {
this.cancel();
this._id = setTimeout(() => this._handle(), this._delay);
},
cancel: function() {
cancel() {
if (this._id) {
clearTimeout(this._id);
this._id = 0;
}
},
_handle: function() {
_handle() {
this._id = 0;
this._func();
},
@@ -30,6 +30,13 @@ var PointerlockFsWarning = {
};
},
/* eslint-disable object-shorthand */
/* The object-shorthand rule must be disabled for this constructor
* because the ES6 method syntax causes "this.Timeout is not a
* constructor" exception. Further, using the {ignoreConstructors: true}
* option causes "TypeError: Cannot read property 'charAt' of undefined"
* in eslint.
*/
/**
* Timeout object for managing timeout request. If it is started when
* the previous call hasn't finished, it would automatically cancelled
@@ -40,15 +47,16 @@ var PointerlockFsWarning = {
this._func = func;
this._delay = delay;
},
/* eslint-enable object-shorthand */
showPointerLock: function(aOrigin) {
showPointerLock(aOrigin) {
if (!document.fullscreen) {
let timeout = gPrefService.getIntPref("pointer-lock-api.warning.timeout");
this.show(aOrigin, "pointerlock-warning", timeout, 0);
}
},
showFullScreen: function(aOrigin) {
showFullScreen(aOrigin) {
let timeout = gPrefService.getIntPref("full-screen-api.warning.timeout");
let delay = gPrefService.getIntPref("full-screen-api.warning.delay");
this.show(aOrigin, "fullscreen-warning", timeout, delay);
@@ -56,7 +64,7 @@ var PointerlockFsWarning = {
// Shows a warning that the site has entered fullscreen or
// pointer lock for a short duration.
show: function(aOrigin, elementId, timeout, delay) {
show(aOrigin, elementId, timeout, delay) {
if (!this._element) {
this._element = document.getElementById(elementId);
@@ -111,7 +119,7 @@ var PointerlockFsWarning = {
this._timeoutHide.start();
},
close: function() {
close() {
if (!this._element) {
return;
}
@@ -180,7 +188,7 @@ var PointerlockFsWarning = {
}
},
handleEvent: function(event) {
handleEvent(event) {
switch (event.type) {
case "mousemove": {
let state = this._state;
@@ -226,12 +234,12 @@ var PointerlockFsWarning = {
var PointerLock = {
init: function() {
init() {
window.messageManager.addMessageListener("PointerLock:Entered", this);
window.messageManager.addMessageListener("PointerLock:Exited", this);
},
receiveMessage: function(aMessage) {
receiveMessage(aMessage) {
switch (aMessage.name) {
case "PointerLock:Entered": {
PointerlockFsWarning.showPointerLock(aMessage.data.originNoSuffix);
@@ -253,7 +261,7 @@ var FullScreen = {
"DOMFullscreen:Painted",
],
init: function() {
init() {
// called when we go into full screen, even if initiated by a web page script
window.addEventListener("fullscreen", this, true);
window.addEventListener("MozDOMFullscreen:Entered", this,
@@ -270,14 +278,14 @@ var FullScreen = {
this.toggle();
},
uninit: function() {
uninit() {
for (let type of this._MESSAGES) {
window.messageManager.removeMessageListener(type, this);
}
this.cleanup();
},
toggle: function() {
toggle() {
var enterFS = window.fullScreen;
// Toggle the View:FullScreen command, which controls elements like the
@@ -342,11 +350,11 @@ var FullScreen = {
}
},
exitDomFullScreen : function() {
exitDomFullScreen() {
document.exitFullscreen();
},
handleEvent: function(event) {
handleEvent(event) {
switch (event.type) {
case "fullscreen":
this.toggle();
@@ -377,7 +385,7 @@ var FullScreen = {
}
},
receiveMessage: function(aMessage) {
receiveMessage(aMessage) {
let browser = aMessage.target;
switch (aMessage.name) {
case "DOMFullscreen:Request": {
@@ -403,7 +411,7 @@ var FullScreen = {
}
},
enterDomFullscreen : function(aBrowser) {
enterDomFullscreen(aBrowser) {
if (!document.fullscreenElement) {
return;
@@ -456,7 +464,7 @@ var FullScreen = {
window.addEventListener("activate", this);
},
cleanup: function() {
cleanup() {
if (!window.fullScreen) {
MousePosTracker.removeListener(this);
document.removeEventListener("keypress", this._keyToggleCallback, false);
@@ -465,7 +473,7 @@ var FullScreen = {
}
},
cleanupDomFullscreen: function() {
cleanupDomFullscreen() {
window.messageManager
.broadcastAsyncMessage("DOMFullscreen:CleanUp");
@@ -478,7 +486,7 @@ var FullScreen = {
document.documentElement.removeAttribute("inDOMFullscreen");
},
_isRemoteBrowser: function(aBrowser) {
_isRemoteBrowser(aBrowser) {
return gMultiProcessBrowser && aBrowser.getAttribute("remote") == "true";
},
@@ -487,21 +495,21 @@ var FullScreen = {
.getInterface(Ci.nsIDOMWindowUtils);
},
getMouseTargetRect: function()
getMouseTargetRect()
{
return this._mouseTargetRect;
},
// Event callbacks
_expandCallback: function()
_expandCallback()
{
FullScreen.showNavToolbox();
},
onMouseEnter: function()
onMouseEnter()
{
FullScreen.hideNavToolbox();
},
_keyToggleCallback: function(aEvent)
_keyToggleCallback(aEvent)
{
// if we can use the keyboard (eg Ctrl+L or Ctrl+E) to open the toolbars, we
// should provide a way to collapse them too.
@@ -516,7 +524,7 @@ var FullScreen = {
// Checks whether we are allowed to collapse the chrome
_isPopupOpen: false,
_isChromeCollapsed: false,
_safeToCollapse: function() {
_safeToCollapse() {
if (!gPrefService.getBoolPref("browser.fullscreen.autohide"))
return false;
@@ -538,7 +546,7 @@ var FullScreen = {
return true;
},
_setPopupOpen: function(aEvent)
_setPopupOpen(aEvent)
{
// Popups should only veto chrome collapsing if they were opened when the chrome was not collapsed.
// Otherwise, they would not affect chrome and the user would expect the chrome to go away.
@@ -556,18 +564,18 @@ var FullScreen = {
},
// Autohide helpers for the context menu item
getAutohide: function(aItem)
getAutohide(aItem)
{
aItem.setAttribute("checked", gPrefService.getBoolPref("browser.fullscreen.autohide"));
},
setAutohide: function()
setAutohide()
{
gPrefService.setBoolPref("browser.fullscreen.autohide", !gPrefService.getBoolPref("browser.fullscreen.autohide"));
// Try again to hide toolbar when we change the pref.
FullScreen.hideNavToolbox(true);
},
showNavToolbox: function(trackMouse = true) {
showNavToolbox(trackMouse = true) {
this._fullScrToggler.hidden = true;
gNavToolbox.removeAttribute("fullscreenShouldAnimate");
gNavToolbox.style.marginTop = "";
@@ -591,7 +599,7 @@ var FullScreen = {
this._isChromeCollapsed = false;
},
hideNavToolbox: function(aAnimate = false) {
hideNavToolbox(aAnimate = false) {
if (this._isChromeCollapsed || !this._safeToCollapse())
return;
@@ -615,7 +623,7 @@ var FullScreen = {
MousePosTracker.removeListener(this);
},
_updateToolbars: function(aEnterFS) {
_updateToolbars(aEnterFS) {
for (let el of document.querySelectorAll("toolbar[fullscreentoolbar=true]")) {
if (aEnterFS) {
// Give the main nav bar and the tab bar the fullscreen context menu,