parent
7f5fb4e6f9
commit
cbafac774e
1 changed files with 6 additions and 47 deletions
|
@ -41,9 +41,6 @@ class WebViewImpl
|
||||||
v8Util.setHiddenValue browserPluginNode, 'internal', this
|
v8Util.setHiddenValue browserPluginNode, 'internal', this
|
||||||
browserPluginNode
|
browserPluginNode
|
||||||
|
|
||||||
getGuestInstanceId: ->
|
|
||||||
@guestInstanceId
|
|
||||||
|
|
||||||
# Resets some state upon reattaching <webview> element to the DOM.
|
# Resets some state upon reattaching <webview> element to the DOM.
|
||||||
reset: ->
|
reset: ->
|
||||||
# If guestInstanceId is defined then the <webview> has navigated and has
|
# If guestInstanceId is defined then the <webview> has navigated and has
|
||||||
|
@ -79,10 +76,6 @@ class WebViewImpl
|
||||||
# Blur the BrowserPlugin when the <webview> loses focus.
|
# Blur the BrowserPlugin when the <webview> loses focus.
|
||||||
@browserPluginNode.blur()
|
@browserPluginNode.blur()
|
||||||
|
|
||||||
# Validation helper function for executeScript() and insertCSS().
|
|
||||||
validateExecuteCodeCall: ->
|
|
||||||
throw new Error(webViewConstants.ERROR_MSG_CANNOT_INJECT_SCRIPT) unless @guestInstanceId
|
|
||||||
|
|
||||||
setupWebviewNodeProperties: ->
|
setupWebviewNodeProperties: ->
|
||||||
# We cannot use {writable: true} property descriptor because we want a
|
# We cannot use {writable: true} property descriptor because we want a
|
||||||
# dynamic getter value.
|
# dynamic getter value.
|
||||||
|
@ -125,31 +118,10 @@ class WebViewImpl
|
||||||
|
|
||||||
# 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.
|
||||||
if node.hasAttribute(webViewConstants.ATTRIBUTE_MAXWIDTH) and
|
maxWidth = @attributes[webViewConstants.ATTRIBUTE_MAXWIDTH].getValue() | width
|
||||||
node[webViewConstants.ATTRIBUTE_MAXWIDTH]
|
maxHeight = @attributes[webViewConstants.ATTRIBUTE_MAXHEIGHT].getValue() | width
|
||||||
maxWidth = node[webViewConstants.ATTRIBUTE_MAXWIDTH]
|
minWidth = @attributes[webViewConstants.ATTRIBUTE_MINWIDTH].getValue() | width
|
||||||
else
|
minHeight = @attributes[webViewConstants.ATTRIBUTE_MINHEIGHT].getValue() | width
|
||||||
maxWidth = width
|
|
||||||
|
|
||||||
if node.hasAttribute(webViewConstants.ATTRIBUTE_MINWIDTH) and
|
|
||||||
node[webViewConstants.ATTRIBUTE_MINWIDTH]
|
|
||||||
minWidth = node[webViewConstants.ATTRIBUTE_MINWIDTH]
|
|
||||||
else
|
|
||||||
minWidth = width
|
|
||||||
minWidth = maxWidth if minWidth > maxWidth
|
|
||||||
|
|
||||||
if node.hasAttribute(webViewConstants.ATTRIBUTE_MAXHEIGHT) and
|
|
||||||
node[webViewConstants.ATTRIBUTE_MAXHEIGHT]
|
|
||||||
maxHeight = node[webViewConstants.ATTRIBUTE_MAXHEIGHT]
|
|
||||||
else
|
|
||||||
maxHeight = height
|
|
||||||
|
|
||||||
if node.hasAttribute(webViewConstants.ATTRIBUTE_MINHEIGHT) and
|
|
||||||
node[webViewConstants.ATTRIBUTE_MINHEIGHT]
|
|
||||||
minHeight = node[webViewConstants.ATTRIBUTE_MINHEIGHT]
|
|
||||||
else
|
|
||||||
minHeight = height
|
|
||||||
minHeight = maxHeight if minHeight > maxHeight
|
|
||||||
|
|
||||||
if not @attributes[webViewConstants.ATTRIBUTE_AUTOSIZE].getValue() or
|
if not @attributes[webViewConstants.ATTRIBUTE_AUTOSIZE].getValue() or
|
||||||
(newWidth >= minWidth and
|
(newWidth >= minWidth and
|
||||||
|
@ -162,13 +134,6 @@ class WebViewImpl
|
||||||
# changed.
|
# changed.
|
||||||
@dispatchEvent webViewEvent
|
@dispatchEvent webViewEvent
|
||||||
|
|
||||||
# Returns if <object> is in the render tree.
|
|
||||||
isPluginInRenderTree: ->
|
|
||||||
!!@internalInstanceId && @internalInstanceId != 0
|
|
||||||
|
|
||||||
hasNavigated: ->
|
|
||||||
not @beforeFirstNavigation
|
|
||||||
|
|
||||||
parseSrcAttribute: ->
|
parseSrcAttribute: ->
|
||||||
if not @attributes[webViewConstants.ATTRIBUTE_PARTITION].validPartitionId or
|
if not @attributes[webViewConstants.ATTRIBUTE_PARTITION].validPartitionId or
|
||||||
not @attributes[webViewConstants.ATTRIBUTE_SRC].getValue()
|
not @attributes[webViewConstants.ATTRIBUTE_SRC].getValue()
|
||||||
|
@ -185,11 +150,6 @@ class WebViewImpl
|
||||||
urlOptions = if httpreferrer then {httpreferrer} else {}
|
urlOptions = if httpreferrer then {httpreferrer} else {}
|
||||||
remote.getGuestWebContents(@guestInstanceId).loadUrl @attributes[webViewConstants.ATTRIBUTE_SRC].getValue(), urlOptions
|
remote.getGuestWebContents(@guestInstanceId).loadUrl @attributes[webViewConstants.ATTRIBUTE_SRC].getValue(), urlOptions
|
||||||
|
|
||||||
parseAttributes: ->
|
|
||||||
return unless @elementAttached
|
|
||||||
hasNavigated = @hasNavigated()
|
|
||||||
@parseSrcAttribute()
|
|
||||||
|
|
||||||
createGuest: ->
|
createGuest: ->
|
||||||
return if @pendingGuestCreation
|
return if @pendingGuestCreation
|
||||||
params =
|
params =
|
||||||
|
@ -257,8 +217,7 @@ class WebViewImpl
|
||||||
@guestInstanceId = guestInstanceId
|
@guestInstanceId = guestInstanceId
|
||||||
params = @buildAttachParams()
|
params = @buildAttachParams()
|
||||||
|
|
||||||
unless @isPluginInRenderTree()
|
return true unless @internalInstanceId
|
||||||
return true
|
|
||||||
|
|
||||||
guestViewInternal.attachGuest @internalInstanceId, @guestInstanceId, params, (w) => @contentWindow = w
|
guestViewInternal.attachGuest @internalInstanceId, @guestInstanceId, params, (w) => @contentWindow = w
|
||||||
|
|
||||||
|
@ -313,7 +272,7 @@ registerWebViewElement = ->
|
||||||
return unless internal
|
return unless internal
|
||||||
unless internal.elementAttached
|
unless internal.elementAttached
|
||||||
internal.elementAttached = true
|
internal.elementAttached = true
|
||||||
internal.parseAttributes()
|
internal.parseSrcAttribute()
|
||||||
|
|
||||||
# Public-facing API methods.
|
# Public-facing API methods.
|
||||||
methods = [
|
methods = [
|
||||||
|
|
Loading…
Reference in a new issue