Use // for single line comments

This commit is contained in:
Kevin Sawicki 2016-01-14 10:35:29 -08:00
parent 26350f4ccb
commit f4af744519
43 changed files with 311 additions and 310 deletions

View file

@ -19,12 +19,12 @@ Module = require('module');
process.argv.splice(1, 1);
/* Clear search paths. */
// Clear search paths.
require(path.resolve(__dirname, '..', '..', 'common', 'lib', 'reset-search-paths'));
/* Import common settings. */
// Import common settings.
require(path.resolve(__dirname, '..', '..', 'common', 'lib', 'init'));
@ -35,12 +35,12 @@ if (!process.env.ELECTRON_HIDE_INTERNAL_MODULES) {
}
/* Expose public APIs. */
// Expose public APIs.
globalPaths.push(path.resolve(__dirname, '..', 'api', 'lib', 'exports'));
/* The global variable will be used by ipc for event dispatching */
// The global variable will be used by ipc for event dispatching
v8Util = process.atomBinding('v8_util');
@ -54,7 +54,7 @@ electron.ipcRenderer.on('ELECTRON_INTERNAL_RENDERER_WEB_FRAME_METHOD', (event, m
electron.webFrame[method].apply(electron.webFrame, args);
});
/* Process command line arguments. */
// Process command line arguments.
nodeIntegration = 'false';
@ -63,11 +63,11 @@ for (i = 0, len = ref.length; i < len; i++) {
arg = ref[i];
if (arg.indexOf('--guest-instance-id=') === 0) {
/* This is a guest web view. */
// This is a guest web view.
process.guestInstanceId = parseInt(arg.substr(arg.indexOf('=') + 1));
} else if (arg.indexOf('--opener-id=') === 0) {
/* This is a guest BrowserWindow. */
// This is a guest BrowserWindow.
process.openerId = parseInt(arg.substr(arg.indexOf('=') + 1));
} else if (arg.indexOf('--node-integration=') === 0) {
nodeIntegration = arg.substr(arg.indexOf('=') + 1);
@ -78,20 +78,20 @@ for (i = 0, len = ref.length; i < len; i++) {
if (location.protocol === 'chrome-devtools:') {
/* Override some inspector APIs. */
// Override some inspector APIs.
require('./inspector');
nodeIntegration = 'true';
} else if (location.protocol === 'chrome-extension:') {
/* Add implementations of chrome API. */
// Add implementations of chrome API.
require('./chrome-api');
nodeIntegration = 'true';
} else {
/* Override default web functions. */
// Override default web functions.
require('./override');
/* Load webview tag implementation. */
// Load webview tag implementation.
if (process.guestInstanceId == null) {
require('./web-view/web-view');
require('./web-view/web-view-attributes');
@ -100,27 +100,27 @@ if (location.protocol === 'chrome-devtools:') {
if (nodeIntegration === 'true' || nodeIntegration === 'all' || nodeIntegration === 'except-iframe' || nodeIntegration === 'manual-enable-iframe') {
/* Export node bindings to global. */
// Export node bindings to global.
global.require = require;
global.module = module;
/* Set the __filename to the path of html file if it is file: protocol. */
// Set the __filename to the path of html file if it is file: protocol.
if (window.location.protocol === 'file:') {
pathname = process.platform === 'win32' && window.location.pathname[0] === '/' ? window.location.pathname.substr(1) : window.location.pathname;
global.__filename = path.normalize(decodeURIComponent(pathname));
global.__dirname = path.dirname(global.__filename);
/* Set module's filename so relative require can work as expected. */
// Set module's filename so relative require can work as expected.
module.filename = global.__filename;
/* Also search for module under the html file. */
// Also search for module under the html file.
module.paths = module.paths.concat(Module._nodeModulePaths(global.__dirname));
} else {
global.__filename = __filename;
global.__dirname = __dirname;
}
/* Redirect window.onerror to uncaughtException. */
// Redirect window.onerror to uncaughtException.
window.onerror = function(message, filename, lineno, colno, error) {
if (global.process.listeners('uncaughtException').length > 0) {
global.process.emit('uncaughtException', error);
@ -130,13 +130,13 @@ if (nodeIntegration === 'true' || nodeIntegration === 'all' || nodeIntegration =
}
};
/* Emit the 'exit' event when page is unloading. */
// Emit the 'exit' event when page is unloading.
window.addEventListener('unload', function() {
return process.emit('exit');
});
} else {
/* Delete Node's symbols after the Environment has been loaded. */
// Delete Node's symbols after the Environment has been loaded.
process.once('loaded', function() {
delete global.process;
delete global.setImmediate;
@ -146,7 +146,7 @@ if (nodeIntegration === 'true' || nodeIntegration === 'all' || nodeIntegration =
}
/* Load the script specfied by the "preload" attribute. */
// Load the script specfied by the "preload" attribute.
if (preloadScript) {
try {

View file

@ -2,10 +2,10 @@ var convertToMenuTemplate, createFileSelectorElement, createMenu, pathToHtml5Fil
window.onload = function() {
/* Use menu API to show context menu. */
// Use menu API to show context menu.
InspectorFrontendHost.showContextMenuAtPoint = createMenu;
/* Use dialog API to override file chooser dialog. */
// Use dialog API to override file chooser dialog.
return WebInspector.createFileSelectorElement = createFileSelectorElement;
};
@ -52,7 +52,7 @@ createMenu = function(x, y, items, document) {
Menu = remote.Menu;
menu = Menu.buildFromTemplate(convertToMenuTemplate(items));
/* The menu is expected to show asynchronously. */
// The menu is expected to show asynchronously.
return setTimeout(function() {
return menu.popup(remote.getCurrentWindow());
});

View file

@ -4,7 +4,7 @@ var BrowserWindowProxy, a, getHistoryOperation, ipcRenderer, ref, remote, resolv
ref = require('electron'), ipcRenderer = ref.ipcRenderer, remote = ref.remote;
/* Helper function to resolve relative url. */
// Helper function to resolve relative url.
a = window.top.document.createElement('a');
@ -14,7 +14,7 @@ resolveURL = function(url) {
};
/* Window object returned by "window.open". */
// Window object returned by "window.open".
BrowserWindowProxy = (function() {
BrowserWindowProxy.proxies = {};
@ -70,14 +70,14 @@ BrowserWindowProxy = (function() {
if (process.guestInstanceId == null) {
/* Override default window.close. */
// Override default window.close.
window.close = function() {
return remote.getCurrentWindow().close();
};
}
/* Make the browser window or guest view emit "new-window" event. */
// Make the browser window or guest view emit "new-window" event.
window.open = function(url, frameName, features) {
var feature, guestId, i, ints, j, len, len1, name, options, ref1, ref2, value;
@ -90,7 +90,7 @@ window.open = function(url, frameName, features) {
options = {};
ints = ['x', 'y', 'width', 'height', 'min-width', 'max-width', 'min-height', 'max-height', 'zoom-factor'];
/* Make sure to get rid of excessive whitespace in the property name */
// Make sure to get rid of excessive whitespace in the property name
ref1 = features.split(/,\s*/);
for (i = 0, len = ref1.length; i < len; i++) {
feature = ref1[i];
@ -117,7 +117,7 @@ window.open = function(url, frameName, features) {
options.height = 600;
}
/* Resolve relative urls. */
// Resolve relative urls.
url = resolveURL(url);
for (j = 0, len1 = ints.length; j < len1; j++) {
name = ints[j];
@ -134,7 +134,7 @@ window.open = function(url, frameName, features) {
};
/* Use the dialog API to implement alert(). */
// Use the dialog API to implement alert().
window.alert = function(message, title) {
var buttons;
@ -149,11 +149,11 @@ window.alert = function(message, title) {
buttons: buttons
});
/* Alert should always return undefined. */
// Alert should always return undefined.
};
/* And the confirm(). */
// And the confirm().
window.confirm = function(message, title) {
var buttons, cancelId;
@ -171,7 +171,7 @@ window.confirm = function(message, title) {
};
/* But we do not support prompt(). */
// But we do not support prompt().
window.prompt = function() {
throw new Error('prompt() is and will not be supported.');
@ -183,9 +183,9 @@ if (process.openerId != null) {
ipcRenderer.on('ATOM_SHELL_GUEST_WINDOW_POSTMESSAGE', function(event, sourceId, message, sourceOrigin) {
/* Manually dispatch event instead of using postMessage because we also need to */
// Manually dispatch event instead of using postMessage because we also need to
/* set event.source. */
// set event.source.
event = document.createEvent('Event');
event.initEvent('message', false, false);
event.data = message;
@ -195,7 +195,7 @@ ipcRenderer.on('ATOM_SHELL_GUEST_WINDOW_POSTMESSAGE', function(event, sourceId,
});
/* Forward history operations to browser. */
// Forward history operations to browser.
sendHistoryOperation = function() {
var args;
@ -228,7 +228,7 @@ Object.defineProperty(window.history, 'length', {
});
/* Make document.hidden and document.visibilityState return the correct value. */
// Make document.hidden and document.visibilityState return the correct value.
Object.defineProperty(document, 'hidden', {
get: function() {

View file

@ -11,7 +11,7 @@ webViewConstants = require('./web-view-constants');
remote = require('electron').remote;
/* Helper function to resolve url set in attribute. */
// Helper function to resolve url set in attribute.
a = document.createElement('a');
@ -36,21 +36,21 @@ WebViewAttribute = (function() {
}
/* Retrieves and returns the attribute's value. */
// Retrieves and returns the attribute's value.
WebViewAttribute.prototype.getValue = function() {
return this.webViewImpl.webviewNode.getAttribute(this.name) || this.value;
};
/* Sets the attribute's value. */
// Sets the attribute's value.
WebViewAttribute.prototype.setValue = function(value) {
return this.webViewImpl.webviewNode.setAttribute(this.name, value || '');
};
/* Changes the attribute's value without triggering its mutation handler. */
// Changes the attribute's value without triggering its mutation handler.
WebViewAttribute.prototype.setValueIgnoreMutation = function(value) {
this.ignoreMutation = true;
@ -59,7 +59,7 @@ WebViewAttribute = (function() {
};
/* Defines this attribute as a property on the webview node. */
// Defines this attribute as a property on the webview node.
WebViewAttribute.prototype.defineProperty = function() {
return Object.defineProperty(this.webViewImpl.webviewNode, this.name, {
@ -78,7 +78,7 @@ WebViewAttribute = (function() {
};
/* Called when the attribute's value changes. */
// Called when the attribute's value changes.
WebViewAttribute.prototype.handleMutation = function() {};
@ -87,7 +87,7 @@ WebViewAttribute = (function() {
})();
/* An attribute that is treated as a Boolean. */
// An attribute that is treated as a Boolean.
BooleanAttribute = (function(superClass) {
extend(BooleanAttribute, superClass);
@ -113,7 +113,7 @@ BooleanAttribute = (function(superClass) {
})(WebViewAttribute);
/* Attribute that specifies whether transparency is allowed in the webview. */
// Attribute that specifies whether transparency is allowed in the webview.
AllowTransparencyAttribute = (function(superClass) {
extend(AllowTransparencyAttribute, superClass);
@ -134,7 +134,7 @@ AllowTransparencyAttribute = (function(superClass) {
})(BooleanAttribute);
/* Attribute used to define the demension limits of autosizing. */
// Attribute used to define the demension limits of autosizing.
AutosizeDimensionAttribute = (function(superClass) {
extend(AutosizeDimensionAttribute, superClass);
@ -169,7 +169,7 @@ AutosizeDimensionAttribute = (function(superClass) {
})(WebViewAttribute);
/* Attribute that specifies whether the webview should be autosized. */
// Attribute that specifies whether the webview should be autosized.
AutosizeAttribute = (function(superClass) {
extend(AutosizeAttribute, superClass);
@ -185,7 +185,7 @@ AutosizeAttribute = (function(superClass) {
})(BooleanAttribute);
/* Attribute representing the state of the storage partition. */
// Attribute representing the state of the storage partition.
PartitionAttribute = (function(superClass) {
extend(PartitionAttribute, superClass);
@ -198,7 +198,7 @@ PartitionAttribute = (function(superClass) {
PartitionAttribute.prototype.handleMutation = function(oldValue, newValue) {
newValue = newValue || '';
/* The partition cannot change if the webview has already navigated. */
// The partition cannot change if the webview has already navigated.
if (!this.webViewImpl.beforeFirstNavigation) {
window.console.error(webViewConstants.ERROR_MSG_ALREADY_NAVIGATED);
this.setValueIgnoreMutation(oldValue);
@ -215,7 +215,7 @@ PartitionAttribute = (function(superClass) {
})(WebViewAttribute);
/* Attribute that handles the location and navigation of the webview. */
// Attribute that handles the location and navigation of the webview.
SrcAttribute = (function(superClass) {
extend(SrcAttribute, superClass);
@ -310,7 +310,7 @@ SrcAttribute = (function(superClass) {
return;
}
/* Navigate to |this.src|. */
// Navigate to |this.src|.
opts = {};
httpreferrer = this.webViewImpl.attributes[webViewConstants.ATTRIBUTE_HTTPREFERRER].getValue();
if (httpreferrer) {
@ -329,7 +329,7 @@ SrcAttribute = (function(superClass) {
})(WebViewAttribute);
/* Attribute specifies HTTP referrer. */
// Attribute specifies HTTP referrer.
HttpReferrerAttribute = (function(superClass) {
extend(HttpReferrerAttribute, superClass);
@ -343,7 +343,7 @@ HttpReferrerAttribute = (function(superClass) {
})(WebViewAttribute);
/* Attribute specifies user agent */
// Attribute specifies user agent
UserAgentAttribute = (function(superClass) {
extend(UserAgentAttribute, superClass);
@ -357,7 +357,7 @@ UserAgentAttribute = (function(superClass) {
})(WebViewAttribute);
/* Attribute that set preload script. */
// Attribute that set preload script.
PreloadAttribute = (function(superClass) {
extend(PreloadAttribute, superClass);
@ -385,7 +385,7 @@ PreloadAttribute = (function(superClass) {
})(WebViewAttribute);
/* Sets up all of the webview attributes. */
// Sets up all of the webview attributes.
WebViewImpl.prototype.setupWebViewAttributes = function() {
var attribute, autosizeAttributes, i, len, results;

View file

@ -1,6 +1,6 @@
module.exports = {
/* Attributes. */
// Attributes.
ATTRIBUTE_ALLOWTRANSPARENCY: 'allowtransparency',
ATTRIBUTE_AUTOSIZE: 'autosize',
ATTRIBUTE_MAXHEIGHT: 'maxheight',
@ -18,10 +18,10 @@ module.exports = {
ATTRIBUTE_PRELOAD: 'preload',
ATTRIBUTE_USERAGENT: 'useragent',
/* Internal attribute. */
// Internal attribute.
ATTRIBUTE_INTERNALINSTANCEID: 'internalinstanceid',
/* Error messages. */
// Error messages.
ERROR_MSG_ALREADY_NAVIGATED: 'The object has already navigated, so its partition cannot be changed.',
ERROR_MSG_CANNOT_INJECT_SCRIPT: '<webview>: ' + 'Script cannot be injected into content until the page has loaded.',
ERROR_MSG_INVALID_PARTITION_ATTRIBUTE: 'Invalid partition attribute.',

View file

@ -13,7 +13,7 @@ guestViewInternal = require('./guest-view-internal');
webViewConstants = require('./web-view-constants');
/* ID generator. */
// ID generator.
nextId = 0;
@ -22,7 +22,7 @@ getNextId = function() {
};
/* Represents the internal state of the WebView node. */
// Represents the internal state of the WebView node.
WebViewImpl = (function() {
function WebViewImpl(webviewNode) {
@ -33,7 +33,7 @@ WebViewImpl = (function() {
this.elementAttached = false;
this.beforeFirstNavigation = true;
/* on* Event handlers. */
// on* Event handlers.
this.on = {};
this.browserPluginNode = this.createBrowserPluginNode();
shadowRoot = this.webviewNode.createShadowRoot();
@ -62,7 +62,7 @@ WebViewImpl = (function() {
};
/* Resets some state upon reattaching <webview> element to the DOM. */
// Resets some state upon reattaching <webview> element to the DOM.
WebViewImpl.prototype.reset = function() {
// Unlisten the zoom-level-changed event.
@ -87,7 +87,7 @@ WebViewImpl = (function() {
};
/* Sets the <webview>.request property. */
// Sets the <webview>.request property.
WebViewImpl.prototype.setRequestPropertyOnWebViewNode = function(request) {
return Object.defineProperty(this.webviewNode, 'request', {
@ -110,14 +110,14 @@ WebViewImpl = (function() {
this.webviewNode.addEventListener('focus', (function(_this) {
return function(e) {
/* Focus the BrowserPlugin when the <webview> takes focus. */
// Focus the BrowserPlugin when the <webview> takes focus.
return _this.browserPluginNode.focus();
};
})(this));
return this.webviewNode.addEventListener('blur', (function(_this) {
return function(e) {
/* Blur the BrowserPlugin when the <webview> loses focus. */
// Blur the BrowserPlugin when the <webview> loses focus.
return _this.browserPluginNode.blur();
};
})(this));
@ -137,7 +137,7 @@ WebViewImpl = (function() {
return;
}
/* Let the changed attribute handle its own mutation; */
// Let the changed attribute handle its own mutation;
return this.attributes[attributeName].handleMutation(oldValue, newValue);
};
@ -146,7 +146,7 @@ WebViewImpl = (function() {
this.browserPluginNode.removeAttribute(webViewConstants.ATTRIBUTE_INTERNALINSTANCEID);
this.internalInstanceId = parseInt(newValue);
/* Track when the element resizes using the element resize callback. */
// Track when the element resizes using the element resize callback.
webFrame.registerElementResizeCallback(this.internalInstanceId, this.onElementResize.bind(this));
if (!this.guestInstanceId) {
return;
@ -163,9 +163,9 @@ WebViewImpl = (function() {
width = node.offsetWidth;
height = node.offsetHeight;
/* Check the current bounds to make sure we do not resize <webview> */
// Check the current bounds to make sure we do not resize <webview>
/* outside of current constraints. */
// outside of current constraints.
maxWidth = this.attributes[webViewConstants.ATTRIBUTE_MAXWIDTH].getValue() | width;
maxHeight = this.attributes[webViewConstants.ATTRIBUTE_MAXHEIGHT].getValue() | width;
minWidth = this.attributes[webViewConstants.ATTRIBUTE_MINWIDTH].getValue() | width;
@ -186,7 +186,7 @@ WebViewImpl = (function() {
WebViewImpl.prototype.onElementResize = function(newSize) {
/* Dispatch the 'resize' event. */
// Dispatch the 'resize' event.
var resizeEvent;
resizeEvent = new Event('resize', {
bubbles: true
@ -214,10 +214,10 @@ WebViewImpl = (function() {
};
/* Adds an 'on<event>' property on the webview, which can be used to set/unset */
// Adds an 'on<event>' property on the webview, which can be used to set/unset
/* an event handler. */
// an event handler.
WebViewImpl.prototype.setupEventProperty = function(eventName) {
var propertyName;
@ -244,7 +244,7 @@ WebViewImpl = (function() {
};
/* Updates state upon loadcommit. */
// Updates state upon loadcommit.
WebViewImpl.prototype.onLoadCommit = function(webViewEvent) {
var newValue, oldValue;
@ -306,7 +306,7 @@ WebViewImpl = (function() {
})();
/* Registers browser plugin <object> custom element. */
// Registers browser plugin <object> custom element.
registerBrowserPluginElement = function() {
var proto;
@ -315,7 +315,7 @@ registerBrowserPluginElement = function() {
this.setAttribute('type', 'application/browser-plugin');
this.setAttribute('id', 'browser-plugin-' + getNextId());
/* The <object> node fills in the <webview> container. */
// The <object> node fills in the <webview> container.
this.style.display = 'block';
this.style.width = '100%';
return this.style.height = '100%';
@ -330,7 +330,7 @@ registerBrowserPluginElement = function() {
};
proto.attachedCallback = function() {
/* Load the plugin immediately. */
// Load the plugin immediately.
var unused;
return unused = this.nonExistentAttribute;
};
@ -345,7 +345,7 @@ registerBrowserPluginElement = function() {
};
/* Registers <webview> custom element. */
// Registers <webview> custom element.
registerWebViewElement = function() {
var createBlockHandler, createNonBlockHandler, i, j, len, len1, m, methods, nonblockMethods, proto;
@ -384,7 +384,7 @@ registerWebViewElement = function() {
}
};
/* Public-facing API methods. */
// Public-facing API methods.
methods = ['getURL', 'getTitle', 'isLoading', 'isWaitingForResponse', 'stop', 'reload', 'reloadIgnoringCache', 'canGoBack', 'canGoForward', 'canGoToOffset', 'clearHistory', 'goBack', 'goForward', 'goToIndex', 'goToOffset', 'isCrashed', 'setUserAgent', 'getUserAgent', 'openDevTools', 'closeDevTools', 'isDevToolsOpened', 'isDevToolsFocused', 'inspectElement', 'setAudioMuted', 'isAudioMuted', 'undo', 'redo', 'cut', 'copy', 'paste', 'pasteAndMatchStyle', 'delete', 'selectAll', 'unselect', 'replace', 'replaceMisspelling', 'findInPage', 'stopFindInPage', 'getId', 'downloadURL', 'inspectServiceWorker', 'print', 'printToPDF'];
nonblockMethods = [
'executeJavaScript',
@ -397,7 +397,7 @@ registerWebViewElement = function() {
'setZoomLevelLimits',
];
/* Forward proto.foo* method calls to WebViewImpl.foo*. */
// Forward proto.foo* method calls to WebViewImpl.foo*.
createBlockHandler = function(m) {
return function() {
var args, internal, ref1;
@ -423,15 +423,16 @@ registerWebViewElement = function() {
proto[m] = createNonBlockHandler(m);
}
/* Deprecated. */
// Deprecated.
deprecate.rename(proto, 'getUrl', 'getURL');
window.WebView = webFrame.registerEmbedderCustomElement('webview', {
prototype: proto
});
/* Delete the callbacks so developers cannot call them and produce unexpected */
/* behavior. */
/*
Delete the callbacks so developers cannot call them and produce unexpected
behavior.
*/
delete proto.createdCallback;
delete proto.attachedCallback;
delete proto.detachedCallback;