Commit c7b1e05c authored by Kevin McNee's avatar Kevin McNee Committed by Commit Bot

Remove unnecessary uses of privates in GuestView JS implementation

There are several uses of |privates| in the guest view js that are used
as if it were a means of making properties inaccessible from outside a
class (like what private does in C++). |privates| only hides
properties from outside the extension system implementation.

We remove uses of |privates| where the receiver is already inaccessible
from outside the extension system implementation.

Bug: 900940
Change-Id: Ib583aefe9daa22e095d387ffab430429870796fc
Reviewed-on: https://chromium-review.googlesource.com/c/1336052Reviewed-by: default avatarPaul Meyer <paulmeyer@chromium.org>
Commit-Queue: Kevin McNee <mcnee@chromium.org>
Cr-Commit-Position: refs/heads/master@{#611354}
parent 41b6d981
......@@ -149,9 +149,8 @@ GuestViewImpl.prototype.weakWrapper = function(func, viewInstanceId) {
return function() {
var view = GuestViewInternalNatives.GetViewFromID(viewInstanceId);
if (view && view.guest) {
return $Function.apply(func,
privates(view.guest).internal,
$Array.slice(arguments));
return $Function.apply(
func, view.guest.internal, $Array.slice(arguments));
}
};
};
......@@ -309,13 +308,15 @@ GuestViewImpl.prototype.setSizeImpl = function(sizeParams, callback) {
// attach(), create(), destroy(), and getId(). All other implementation details
// are hidden.
function GuestView(viewType, guestInstanceId) {
privates(this).internal = new GuestViewImpl(this, viewType, guestInstanceId);
this.internal = new GuestViewImpl(this, viewType, guestInstanceId);
}
GuestView.prototype.__proto__ = null;
// Attaches the guestview to the container with ID |internalInstanceId|.
GuestView.prototype.attach = function(
internalInstanceId, viewInstanceId, attachParams, callback) {
var internal = privates(this).internal;
var internal = this.internal;
$Array.push(internal.actionQueue, $Function.bind(internal.attachImpl$,
internal, internalInstanceId, viewInstanceId, attachParams, callback));
internal.performNextAction();
......@@ -323,7 +324,7 @@ GuestView.prototype.attach = function(
// Creates the guestview.
GuestView.prototype.create = function(createParams, callback) {
var internal = privates(this).internal;
var internal = this.internal;
$Array.push(internal.actionQueue, $Function.bind(internal.createImpl$,
internal, createParams, callback));
internal.performNextAction();
......@@ -332,7 +333,7 @@ GuestView.prototype.create = function(createParams, callback) {
// Destroys the guestview. Nothing can be done with the guestview after it has
// been destroyed.
GuestView.prototype.destroy = function(callback) {
var internal = privates(this).internal;
var internal = this.internal;
$Array.push(
internal.actionQueue,
$Function.bind(internal.destroyImpl$, internal, callback));
......@@ -342,7 +343,7 @@ GuestView.prototype.destroy = function(callback) {
// Detaches the guestview from its container.
// Note: This is not currently used.
GuestView.prototype.detach = function(callback) {
var internal = privates(this).internal;
var internal = this.internal;
$Array.push(internal.actionQueue,
$Function.bind(internal.detachImpl, internal, callback));
internal.performNextAction();
......@@ -350,7 +351,7 @@ GuestView.prototype.detach = function(callback) {
// Adjusts the guestview's sizing parameters.
GuestView.prototype.setSize = function(sizeParams, callback) {
var internal = privates(this).internal;
var internal = this.internal;
$Array.push(internal.actionQueue,
$Function.bind(internal.setSizeImpl, internal, sizeParams, callback));
internal.performNextAction();
......@@ -358,13 +359,13 @@ GuestView.prototype.setSize = function(sizeParams, callback) {
// Returns the contentWindow for this guestview.
GuestView.prototype.getContentWindow = function() {
var internal = privates(this).internal;
var internal = this.internal;
return internal.contentWindow;
};
// Returns the ID for this guestview.
GuestView.prototype.getId = function() {
var internal = privates(this).internal;
var internal = this.internal;
return internal.id;
};
......
......@@ -25,9 +25,9 @@ function GuestViewContainer(element, viewType) {
this.guest = new GuestView(viewType);
this.setupAttributes();
privates(this).internalElement = this.createInternalElement$();
this.internalElement = this.createInternalElement$();
var shadowRoot = this.element.attachShadow({mode: 'open'});
shadowRoot.appendChild(privates(this).internalElement);
shadowRoot.appendChild(this.internalElement);
GuestViewInternalNatives.RegisterView(this.viewInstanceId, this, viewType);
}
......@@ -43,14 +43,14 @@ GuestViewContainer.prototype.__proto__ = null;
GuestViewContainer.prototype.setupGuestProperty = function() {
$Object.defineProperty(this, 'guest', {
get: $Function.bind(function() {
return privates(this).guest;
return this.guest_;
}, this),
set: $Function.bind(function(value) {
privates(this).guest = value;
this.guest_ = value;
if (!value) {
return;
}
privates(this).guest.onresize = $Function.bind(function(e) {
this.guest_.onresize = $Function.bind(function(e) {
// Dispatch the 'contentresize' event.
var contentResizeEvent = new Event('contentresize', { bubbles: true });
contentResizeEvent.oldWidth = e.oldWidth;
......@@ -77,7 +77,7 @@ GuestViewContainer.prototype.prepareForReattach$ = function() {};
GuestViewContainer.prototype.focus = function() {
// Focus the internal element when focus() is called on the GuestView element.
privates(this).internalElement.focus();
this.internalElement.focus();
}
GuestViewContainer.prototype.attachWindow$ = function() {
......@@ -117,7 +117,7 @@ GuestViewContainer.prototype.onInternalInstanceId = function(
GuestViewContainer.prototype.handleInternalElementAttributeMutation =
function(name, oldValue, newValue) {
if (name == 'internalinstanceid' && !oldValue && !!newValue) {
privates(this).internalElement.removeAttribute('internalinstanceid');
this.internalElement.removeAttribute('internalinstanceid');
this.onInternalInstanceId(parseInt(newValue));
}
};
......
......@@ -13,7 +13,7 @@ var getIframeContentWindow = function(viewInstanceId) {
if (!view)
return null;
var internalIframeElement = privates(view).internalElement;
var internalIframeElement = view.internalElement;
if (internalIframeElement)
return internalIframeElement.contentWindow;
......
......@@ -12,7 +12,6 @@ GuestViewContainer.prototype.createInternalElement$ = function() {
iframeElement.style.width = '100%';
iframeElement.style.height = '100%';
iframeElement.style.border = '0';
privates(iframeElement).internal = this;
return iframeElement;
};
......@@ -20,8 +19,8 @@ GuestViewContainer.prototype.prepareForReattach$ = function() {
// Since attachment swaps a local frame for a remote frame, we need our
// internal iframe element to be local again before we can reattach.
var newFrame = this.createInternalElement$();
var oldFrame = privates(this).internalElement;
privates(this).internalElement = newFrame;
var oldFrame = this.internalElement;
this.internalElement = newFrame;
oldFrame.parentNode.replaceChild(newFrame, oldFrame);
};
......
......@@ -46,8 +46,7 @@ WebViewElement.prototype.print = function() {
};
WebViewElement.prototype.back = function(callback) {
return $Function.call(
privates(WebViewElement).originalGo, this, -1, callback);
return $Function.call(originalGo, this, -1, callback);
};
WebViewElement.prototype.canGoBack = function() {
......@@ -62,7 +61,7 @@ WebViewElement.prototype.canGoForward = function() {
};
WebViewElement.prototype.forward = function(callback) {
return $Function.call(privates(WebViewElement).originalGo, this, 1, callback);
return $Function.call(originalGo, this, 1, callback);
};
WebViewElement.prototype.getProcessId = function() {
......@@ -89,7 +88,7 @@ forwardApiMethods(
// Since |back| and |forward| are implemented in terms of |go|, we need to
// keep a reference to the real |go| function, since user code may override
// |WebViewElement.prototype.go|.
privates(WebViewElement).originalGo = WebViewElement.prototype.go;
var originalGo = WebViewElement.prototype.go;
// Exports.
exports.$set('WebViewElement', WebViewElement);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment