Simplify web-view.coffee
Imported from: https://chromium.googlesource.com/chromium/src/+/3ef1fc1b72af221a5cf8ebfd2db1ead5afda6a06%5E%21/
This commit is contained in:
		
					parent
					
						
							
								b6b8b936f2
							
						
					
				
			
			
				commit
				
					
						4348143fd9
					
				
			
		
					 1 changed files with 11 additions and 22 deletions
				
			
		| 
						 | 
					@ -27,11 +27,6 @@ class WebView
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @beforeFirstNavigation = true
 | 
					    @beforeFirstNavigation = true
 | 
				
			||||||
    @contentWindow = null
 | 
					    @contentWindow = null
 | 
				
			||||||
    # Used to save some state upon deferred attachment.
 | 
					 | 
				
			||||||
    # If <object> bindings is not available, we defer attachment.
 | 
					 | 
				
			||||||
    # This state contains whether or not the attachment request was for
 | 
					 | 
				
			||||||
    # newwindow.
 | 
					 | 
				
			||||||
    @deferredAttachState = null
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # on* Event handlers.
 | 
					    # on* Event handlers.
 | 
				
			||||||
    @on = {}
 | 
					    @on = {}
 | 
				
			||||||
| 
						 | 
					@ -206,9 +201,8 @@ class WebView
 | 
				
			||||||
      @browserPluginNode.removeAttribute webViewConstants.ATTRIBUTE_INTERNALINSTANCEID
 | 
					      @browserPluginNode.removeAttribute webViewConstants.ATTRIBUTE_INTERNALINSTANCEID
 | 
				
			||||||
      @internalInstanceId = parseInt newValue
 | 
					      @internalInstanceId = parseInt newValue
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      if !!@guestInstanceId and @guestInstanceId != 0
 | 
					      return unless @guestInstanceId
 | 
				
			||||||
        isNewWindow = if @deferredAttachState then @deferredAttachState.isNewWindow else false
 | 
					
 | 
				
			||||||
        params = @buildAttachParams isNewWindow
 | 
					 | 
				
			||||||
      guestViewInternal.attachGuest @internalInstanceId, @guestInstanceId, params, (w) => @contentWindow = w
 | 
					      guestViewInternal.attachGuest @internalInstanceId, @guestInstanceId, params, (w) => @contentWindow = w
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  onSizeChanged: (webViewEvent) ->
 | 
					  onSizeChanged: (webViewEvent) ->
 | 
				
			||||||
| 
						 | 
					@ -309,7 +303,7 @@ class WebView
 | 
				
			||||||
      unless @elementAttached
 | 
					      unless @elementAttached
 | 
				
			||||||
        guestViewInternal.destroyGuest guestInstanceId
 | 
					        guestViewInternal.destroyGuest guestInstanceId
 | 
				
			||||||
        return
 | 
					        return
 | 
				
			||||||
      @attachWindow guestInstanceId, false
 | 
					      @attachWindow guestInstanceId
 | 
				
			||||||
    @pendingGuestCreation = true
 | 
					    @pendingGuestCreation = true
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  dispatchEvent: (webViewEvent) ->
 | 
					  dispatchEvent: (webViewEvent) ->
 | 
				
			||||||
| 
						 | 
					@ -343,31 +337,26 @@ class WebView
 | 
				
			||||||
  onAttach: (storagePartitionId) ->
 | 
					  onAttach: (storagePartitionId) ->
 | 
				
			||||||
    @attributes[webViewConstants.ATTRIBUTE_PARTITION].setValue storagePartitionId
 | 
					    @attributes[webViewConstants.ATTRIBUTE_PARTITION].setValue storagePartitionId
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  buildAttachParams: (isNewWindow) ->
 | 
					  buildAttachParams: ->
 | 
				
			||||||
 | 
					    instanceId: @viewInstanceId
 | 
				
			||||||
 | 
					    userAgentOverride: @userAgentOverride
 | 
				
			||||||
 | 
					    # Attributes:
 | 
				
			||||||
    allowtransparency: @attributes[webViewConstants.ATTRIBUTE_ALLOWTRANSPARENCY].getValue()
 | 
					    allowtransparency: @attributes[webViewConstants.ATTRIBUTE_ALLOWTRANSPARENCY].getValue()
 | 
				
			||||||
    autosize: @attributes[webViewConstants.ATTRIBUTE_AUTOSIZE].getValue()
 | 
					    autosize: @attributes[webViewConstants.ATTRIBUTE_AUTOSIZE].getValue()
 | 
				
			||||||
    instanceId: @viewInstanceId
 | 
					 | 
				
			||||||
    maxheight: parseInt @attributes[webViewConstants.ATTRIBUTE_MAXHEIGHT].getValue() || 0
 | 
					    maxheight: parseInt @attributes[webViewConstants.ATTRIBUTE_MAXHEIGHT].getValue() || 0
 | 
				
			||||||
    maxwidth: parseInt @attributes[webViewConstants.ATTRIBUTE_MAXWIDTH].getValue() || 0
 | 
					    maxwidth: parseInt @attributes[webViewConstants.ATTRIBUTE_MAXWIDTH].getValue() || 0
 | 
				
			||||||
    minheight: parseInt @attributes[webViewConstants.ATTRIBUTE_MINHEIGHT].getValue() || 0
 | 
					    minheight: parseInt @attributes[webViewConstants.ATTRIBUTE_MINHEIGHT].getValue() || 0
 | 
				
			||||||
    minwidth: parseInt @attributes[webViewConstants.ATTRIBUTE_MINWIDTH].getValue() || 0
 | 
					    minwidth: parseInt @attributes[webViewConstants.ATTRIBUTE_MINWIDTH].getValue() || 0
 | 
				
			||||||
    # We don't need to navigate new window from here.
 | 
					    src: @attributes[webViewConstants.ATTRIBUTE_SRC].getValue()
 | 
				
			||||||
    src: if isNewWindow then undefined else @attributes[webViewConstants.ATTRIBUTE_SRC].getValue()
 | 
					 | 
				
			||||||
    # If we have a partition from the opener, that will also be already
 | 
					 | 
				
			||||||
    # set via this.onAttach().
 | 
					 | 
				
			||||||
    storagePartitionId: @attributes[webViewConstants.ATTRIBUTE_PARTITION].getValue()
 | 
					 | 
				
			||||||
    userAgentOverride: @userAgentOverride
 | 
					 | 
				
			||||||
    httpreferrer: @attributes[webViewConstants.ATTRIBUTE_HTTPREFERRER].getValue()
 | 
					    httpreferrer: @attributes[webViewConstants.ATTRIBUTE_HTTPREFERRER].getValue()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  attachWindow: (guestInstanceId, isNewWindow) ->
 | 
					  attachWindow: (guestInstanceId) ->
 | 
				
			||||||
    @guestInstanceId = guestInstanceId
 | 
					    @guestInstanceId = guestInstanceId
 | 
				
			||||||
    params = @buildAttachParams isNewWindow
 | 
					    params = @buildAttachParams()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    unless @isPluginInRenderTree()
 | 
					    unless @isPluginInRenderTree()
 | 
				
			||||||
      @deferredAttachState = isNewWindow: isNewWindow
 | 
					 | 
				
			||||||
      return true
 | 
					      return true
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @deferredAttachState = null
 | 
					 | 
				
			||||||
    guestViewInternal.attachGuest @internalInstanceId, @guestInstanceId, params, (w) => @contentWindow = w
 | 
					    guestViewInternal.attachGuest @internalInstanceId, @guestInstanceId, params, (w) => @contentWindow = w
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Registers browser plugin <object> custom element.
 | 
					# Registers browser plugin <object> custom element.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue