Moved parseSrcAttribute() into the SrcAttribute object as parse()
Imported from:
3bc15760f9
%5E%21/
This commit is contained in:
parent
cbafac774e
commit
9fcb6b2cd1
2 changed files with 22 additions and 20 deletions
|
@ -1,6 +1,7 @@
|
||||||
WebViewImpl = require './web-view'
|
WebViewImpl = require './web-view'
|
||||||
guestViewInternal = require './guest-view-internal'
|
guestViewInternal = require './guest-view-internal'
|
||||||
webViewConstants = require './web-view-constants'
|
webViewConstants = require './web-view-constants'
|
||||||
|
remote = require 'remote'
|
||||||
|
|
||||||
# Attribute objects.
|
# Attribute objects.
|
||||||
# Default implementation of a WebView attribute.
|
# Default implementation of a WebView attribute.
|
||||||
|
@ -54,7 +55,7 @@ class AllowTransparencyAttribute extends BooleanAttribute
|
||||||
|
|
||||||
handleMutation: (oldValue, newValue) ->
|
handleMutation: (oldValue, newValue) ->
|
||||||
return unless @webViewImpl.guestInstanceId
|
return unless @webViewImpl.guestInstanceId
|
||||||
guestViewInternal.setAllowTransparency @webViewImpl.guestInstanceId, @webViewImpl.attributes[webViewConstants.ATTRIBUTE_ALLOWTRANSPARENCY].getValue()
|
guestViewInternal.setAllowTransparency @webViewImpl.guestInstanceId, @getValue()
|
||||||
|
|
||||||
# Attribute used to define the demension limits of autosizing.
|
# Attribute used to define the demension limits of autosizing.
|
||||||
class AutosizeDimensionAttribute extends WebViewAttribute
|
class AutosizeDimensionAttribute extends WebViewAttribute
|
||||||
|
@ -116,7 +117,7 @@ class SrcAttribute extends WebViewAttribute
|
||||||
# on every guest-initiated navigation.
|
# on every guest-initiated navigation.
|
||||||
@setValueIgnoreMutation oldValue
|
@setValueIgnoreMutation oldValue
|
||||||
return
|
return
|
||||||
@webViewImpl.parseSrcAttribute()
|
@parse()
|
||||||
|
|
||||||
# The purpose of this mutation observer is to catch assignment to the src
|
# The purpose of this mutation observer is to catch assignment to the src
|
||||||
# attribute without any changes to its value. This is useful in the case
|
# attribute without any changes to its value. This is useful in the case
|
||||||
|
@ -135,13 +136,30 @@ class SrcAttribute extends WebViewAttribute
|
||||||
attributeFilter: [@name]
|
attributeFilter: [@name]
|
||||||
@observer.observe @webViewImpl.webviewNode, params
|
@observer.observe @webViewImpl.webviewNode, params
|
||||||
|
|
||||||
|
parse: ->
|
||||||
|
if not @webViewImpl.elementAttached or
|
||||||
|
not @webViewImpl.attributes[webViewConstants.ATTRIBUTE_PARTITION].validPartitionId or
|
||||||
|
not @.getValue()
|
||||||
|
return
|
||||||
|
|
||||||
|
unless @webViewImpl.guestInstanceId?
|
||||||
|
if @webViewImpl.beforeFirstNavigation
|
||||||
|
@webViewImpl.beforeFirstNavigation = false
|
||||||
|
@webViewImpl.createGuest()
|
||||||
|
return
|
||||||
|
|
||||||
|
# Navigate to |this.src|.
|
||||||
|
httpreferrer = @webViewImpl.attributes[webViewConstants.ATTRIBUTE_HTTPREFERRER].getValue()
|
||||||
|
urlOptions = if httpreferrer then {httpreferrer} else {}
|
||||||
|
remote.getGuestWebContents(@webViewImpl.guestInstanceId).loadUrl @getValue(), urlOptions
|
||||||
|
|
||||||
# Attribute specifies HTTP referrer.
|
# Attribute specifies HTTP referrer.
|
||||||
class HttpReferrerAttribute extends WebViewAttribute
|
class HttpReferrerAttribute extends WebViewAttribute
|
||||||
constructor: (webViewImpl) ->
|
constructor: (webViewImpl) ->
|
||||||
super webViewConstants.ATTRIBUTE_HTTPREFERRER, webViewImpl
|
super webViewConstants.ATTRIBUTE_HTTPREFERRER, webViewImpl
|
||||||
|
|
||||||
handleMutation: (oldValue, newValue) ->
|
handleMutation: (oldValue, newValue) ->
|
||||||
@webViewImpl.parseSrcAttribute()
|
SrcAttribute::parse.call this
|
||||||
|
|
||||||
# Sets up all of the webview attributes.
|
# Sets up all of the webview attributes.
|
||||||
WebViewImpl::setupWebViewAttributes = ->
|
WebViewImpl::setupWebViewAttributes = ->
|
||||||
|
|
|
@ -134,22 +134,6 @@ class WebViewImpl
|
||||||
# changed.
|
# changed.
|
||||||
@dispatchEvent webViewEvent
|
@dispatchEvent webViewEvent
|
||||||
|
|
||||||
parseSrcAttribute: ->
|
|
||||||
if not @attributes[webViewConstants.ATTRIBUTE_PARTITION].validPartitionId or
|
|
||||||
not @attributes[webViewConstants.ATTRIBUTE_SRC].getValue()
|
|
||||||
return
|
|
||||||
|
|
||||||
unless @guestInstanceId?
|
|
||||||
if @beforeFirstNavigation
|
|
||||||
@beforeFirstNavigation = false
|
|
||||||
@createGuest()
|
|
||||||
return
|
|
||||||
|
|
||||||
# Navigate to |this.src|.
|
|
||||||
httpreferrer = @attributes[webViewConstants.ATTRIBUTE_HTTPREFERRER].getValue()
|
|
||||||
urlOptions = if httpreferrer then {httpreferrer} else {}
|
|
||||||
remote.getGuestWebContents(@guestInstanceId).loadUrl @attributes[webViewConstants.ATTRIBUTE_SRC].getValue(), urlOptions
|
|
||||||
|
|
||||||
createGuest: ->
|
createGuest: ->
|
||||||
return if @pendingGuestCreation
|
return if @pendingGuestCreation
|
||||||
params =
|
params =
|
||||||
|
@ -272,7 +256,7 @@ registerWebViewElement = ->
|
||||||
return unless internal
|
return unless internal
|
||||||
unless internal.elementAttached
|
unless internal.elementAttached
|
||||||
internal.elementAttached = true
|
internal.elementAttached = true
|
||||||
internal.parseSrcAttribute()
|
internal.attributes[webViewConstants.ATTRIBUTE_SRC].parse()
|
||||||
|
|
||||||
# Public-facing API methods.
|
# Public-facing API methods.
|
||||||
methods = [
|
methods = [
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue