webview: adding load-commit event
This commit is contained in:
parent
6b8d4a43a3
commit
0a7a4c0d0a
7 changed files with 27 additions and 4 deletions
|
@ -4,6 +4,7 @@ webFrame = require 'web-frame'
|
|||
requestId = 0
|
||||
|
||||
WEB_VIEW_EVENTS =
|
||||
'load-commit': ['url', 'isMainFrame']
|
||||
'did-finish-load': []
|
||||
'did-fail-load': ['errorCode', 'errorDescription']
|
||||
'did-frame-finish-load': ['isMainFrame']
|
||||
|
@ -32,6 +33,7 @@ dispatchEvent = (webView, event, args...) ->
|
|||
for f, i in WEB_VIEW_EVENTS[event]
|
||||
domEvent[f] = args[i]
|
||||
webView.dispatchEvent domEvent
|
||||
webView.onLoadCommit domEvent if event == 'load-commit'
|
||||
|
||||
module.exports =
|
||||
registerEvents: (webView, viewInstanceId) ->
|
||||
|
|
|
@ -120,7 +120,7 @@ class SrcAttribute extends WebViewAttribute
|
|||
''
|
||||
|
||||
setValueIgnoreMutation: (value) ->
|
||||
WebViewAttribute::setValueIgnoreMutation value
|
||||
WebViewAttribute::setValueIgnoreMutation.call(this, value)
|
||||
# takeRecords() is needed to clear queued up src mutations. Without it, it
|
||||
# is possible for this change to get picked up asyncronously by src's
|
||||
# mutation observer |observer|, and then get handled even though we do not
|
||||
|
|
|
@ -157,10 +157,10 @@ class WebViewImpl
|
|||
enumerable: true
|
||||
|
||||
# Updates state upon loadcommit.
|
||||
onLoadCommit: (@baseUrlForDataUrl, @currentEntryIndex, @entryCount, @processId, url, isTopLevel) ->
|
||||
onLoadCommit: (webViewEvent) ->
|
||||
oldValue = @webviewNode.getAttribute webViewConstants.ATTRIBUTE_SRC
|
||||
newValue = url
|
||||
if isTopLevel and (oldValue != newValue)
|
||||
newValue = webViewEvent.url
|
||||
if webViewEvent.isMainFrame and (oldValue != newValue)
|
||||
# Touching the src attribute triggers a navigation. To avoid
|
||||
# triggering a page reload on every guest-initiated navigation,
|
||||
# we do not handle this mutation
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue