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

@ -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;