OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // This module implements the shared functionality for different guestview | 5 // This module implements the shared functionality for different guestview |
6 // containers, such as web_view, app_view, etc. | 6 // containers, such as web_view, app_view, etc. |
7 | 7 |
8 var DocumentNatives = requireNative('document_natives'); | 8 var DocumentNatives = requireNative('document_natives'); |
9 var GuestView = require('guestView').GuestView; | 9 var GuestView = require('guestView').GuestView; |
10 var GuestViewInternalNatives = requireNative('guest_view_internal'); | 10 var GuestViewInternalNatives = requireNative('guest_view_internal'); |
(...skipping 97 matching lines...) Loading... |
108 } | 108 } |
109 this.guest.attach(this.internalInstanceId, | 109 this.guest.attach(this.internalInstanceId, |
110 this.viewInstanceId, | 110 this.viewInstanceId, |
111 this.buildParams()); | 111 this.buildParams()); |
112 } | 112 } |
113 }; | 113 }; |
114 | 114 |
115 GuestViewContainer.prototype.buildParams = function() { | 115 GuestViewContainer.prototype.buildParams = function() { |
116 var params = this.buildContainerParams(); | 116 var params = this.buildContainerParams(); |
117 params['instanceId'] = this.viewInstanceId; | 117 params['instanceId'] = this.viewInstanceId; |
118 params['elementWidth'] = parseInt(this.element.offsetWidth); | 118 var elementRect = this.element.getBoundingClientRect(); |
119 params['elementHeight'] = parseInt(this.element.offsetHeight); | 119 params['elementWidth'] = parseInt(elementRect.width); |
| 120 params['elementHeight'] = parseInt(elementRect.height); |
120 return params; | 121 return params; |
121 }; | 122 }; |
122 | 123 |
123 // Implemented by the specific view type, if needed. | 124 // Implemented by the specific view type, if needed. |
124 GuestViewContainer.prototype.buildContainerParams = function() { return {}; }; | 125 GuestViewContainer.prototype.buildContainerParams = function() { return {}; }; |
125 GuestViewContainer.prototype.handleAttributeMutation = function() {}; | 126 GuestViewContainer.prototype.handleAttributeMutation = function() {}; |
126 GuestViewContainer.prototype.onElementAttached = function() {}; | 127 GuestViewContainer.prototype.onElementAttached = function() {}; |
127 GuestViewContainer.prototype.onElementDetached = function() { | 128 GuestViewContainer.prototype.onElementDetached = function() { |
128 this.guest.destroy(); | 129 this.guest.destroy(); |
129 }; | 130 }; |
(...skipping 86 matching lines...) Loading... |
216 // Delete the callbacks so developers cannot call them and produce unexpected | 217 // Delete the callbacks so developers cannot call them and produce unexpected |
217 // behavior. | 218 // behavior. |
218 delete proto.createdCallback; | 219 delete proto.createdCallback; |
219 delete proto.attachedCallback; | 220 delete proto.attachedCallback; |
220 delete proto.detachedCallback; | 221 delete proto.detachedCallback; |
221 delete proto.attributeChangedCallback; | 222 delete proto.attributeChangedCallback; |
222 } | 223 } |
223 | 224 |
224 // Exports. | 225 // Exports. |
225 exports.GuestViewContainer = GuestViewContainer; | 226 exports.GuestViewContainer = GuestViewContainer; |
OLD | NEW |