out->min_size.reset(new gfx::Size(size));
if (params.Get("max", &size))
out->max_size.reset(new gfx::Size(size));
+ if (params.Get("elementSize", &size))
+ out->normal_size.reset(new gfx::Size(size));
return true;
}
};
bool is_full_page_plugin) {
embedder_web_contents_ = embedder_web_contents;
element_instance_id_ = element_instance_id;
+ is_full_page_plugin_ = is_full_page_plugin;
}
void WebContents::Destroy() {
guest = webContents.create
isGuest: true
guestInstanceId: id
- storagePartitionId: params.storagePartitionId
guestInstances[id] = {guest, embedder}
# Destroy guest when the embedder is gone or navigated.
delete @attachParams
@viewInstanceId = params.instanceId
- min = width: params.minwidth, height: params.minheight
- max = width: params.maxwidth, height: params.maxheight
- @setSize params.autosize, min, max
+ @setSize
+ enableAutoSize: params.autosize
+ min:
+ width: params.minwidth, height: params.minheight
+ max:
+ width: params.maxwidth, height: params.maxheight
if params.src
opts = {}
delete reverseEmbedderElementsMap[id]
delete embedderElementsMap[key]
-ipc.on 'ATOM_SHELL_GUEST_VIEW_MANAGER_CREATE_GUEST', (event, type, params, requestId) ->
+ipc.on 'ATOM_SHELL_GUEST_VIEW_MANAGER_CREATE_GUEST', (event, params, requestId) ->
event.sender.send "ATOM_SHELL_RESPONSE_#{requestId}", createGuest(event.sender, params)
ipc.on 'ATOM_SHELL_GUEST_VIEW_MANAGER_ATTACH_GUEST', (event, elementInstanceId, guestInstanceId, params) ->
ipc.removeAllListeners "ATOM_SHELL_GUEST_VIEW_INTERNAL_IPC_MESSAGE-#{viewInstanceId}"
ipc.removeAllListeners "ATOM_SHELL_GUEST_VIEW_INTERNAL_SIZE_CHANGED-#{viewInstanceId}"
- createGuest: (type, params, callback) ->
+ createGuest: (params, callback) ->
requestId++
- ipc.send 'ATOM_SHELL_GUEST_VIEW_MANAGER_CREATE_GUEST', type, params, requestId
+ ipc.send 'ATOM_SHELL_GUEST_VIEW_MANAGER_CREATE_GUEST', params, requestId
ipc.once "ATOM_SHELL_RESPONSE_#{requestId}", callback
attachGuest: (elementInstanceId, guestInstanceId, params) ->
return unless @guestInstanceId
- guestViewInternal.attachGuest @internalInstanceId, @guestInstanceId, @buildAttachParams()
+ guestViewInternal.attachGuest @internalInstanceId, @guestInstanceId, @buildParams()
onSizeChanged: (webViewEvent) ->
newWidth = webViewEvent.newWidth
@dispatchEvent webViewEvent
createGuest: ->
- params =
- storagePartitionId: @attributes[webViewConstants.ATTRIBUTE_PARTITION].getValue()
- guestViewInternal.createGuest 'webview', params, (guestInstanceId) =>
+ guestViewInternal.createGuest @buildParams(), (guestInstanceId) =>
@attachWindow guestInstanceId
dispatchEvent: (webViewEvent) ->
onAttach: (storagePartitionId) ->
@attributes[webViewConstants.ATTRIBUTE_PARTITION].setValue storagePartitionId
- buildAttachParams: ->
+ buildParams: ->
params =
instanceId: @viewInstanceId
userAgentOverride: @userAgentOverride
for attributeName, attribute of @attributes
params[attributeName] = attribute.getValue()
+ # When the WebView is not participating in layout (display:none)
+ # then getBoundingClientRect() would report a width and height of 0.
+ # However, in the case where the WebView has a fixed size we can
+ # use that value to initially size the guest so as to avoid a relayout of
+ # the on display:block.
+ css = window.getComputedStyle @webviewNode, null
+ elementRect = @webviewNode.getBoundingClientRect()
+ params.elementSize =
+ width: parseInt(elementRect.width) || parseInt(css.getPropertyValue('width'))
+ height: parseInt(elementRect.height) || parseInt(css.getPropertyValue('height'))
params
attachWindow: (guestInstanceId) ->
@guestInstanceId = guestInstanceId
- params = @buildAttachParams()
-
return true unless @internalInstanceId
- guestViewInternal.attachGuest @internalInstanceId, @guestInstanceId, params
+ guestViewInternal.attachGuest @internalInstanceId, @guestInstanceId, @buildParams()
# Registers browser plugin <object> custom element.
registerBrowserPluginElement = ->