OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // This module implements Webview (<webview>) as a custom element that wraps a | 5 // This module implements Webview (<webview>) as a custom element that wraps a |
6 // BrowserPlugin object element. The object element is hidden within | 6 // BrowserPlugin object element. The object element is hidden within |
7 // the shadow DOM of the Webview element. | 7 // the shadow DOM of the Webview element. |
8 | 8 |
9 var DocumentNatives = requireNative('document_natives'); | 9 var DocumentNatives = requireNative('document_natives'); |
10 var GuestViewInternal = | 10 var GuestViewInternal = |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
439 // attribute without any changes to its value. This is useful in the case | 439 // attribute without any changes to its value. This is useful in the case |
440 // where the webview guest has crashed and navigating to the same address | 440 // where the webview guest has crashed and navigating to the same address |
441 // spawns off a new process. | 441 // spawns off a new process. |
442 this.srcAndPartitionObserver = new MutationObserver(function(mutations) { | 442 this.srcAndPartitionObserver = new MutationObserver(function(mutations) { |
443 $Array.forEach(mutations, function(mutation) { | 443 $Array.forEach(mutations, function(mutation) { |
444 var oldValue = mutation.oldValue; | 444 var oldValue = mutation.oldValue; |
445 var newValue = this.webviewNode.getAttribute(mutation.attributeName); | 445 var newValue = this.webviewNode.getAttribute(mutation.attributeName); |
446 if (oldValue != newValue) { | 446 if (oldValue != newValue) { |
447 return; | 447 return; |
448 } | 448 } |
449 this.handleWebviewAttributeMutation( | 449 this.handleWebviewAttributeMutation( |
lazyboy
2014/09/02 22:57:27
^^^
| |
450 mutation.attributeName, oldValue, newValue); | 450 mutation.attributeName, oldValue, newValue); |
451 }.bind(this)); | 451 }.bind(this)); |
452 }); | 452 }.bind(this)); |
lazyboy
2014/09/02 17:45:34
This isn't necessary, are you doing this for consi
Fady Samuel
2014/09/02 22:53:59
Are you sure about that? If I don't bind this here
lazyboy
2014/09/02 22:57:27
I was confused by the whole diff being messed up i
| |
453 var params = { | 453 var params = { |
454 attributes: true, | 454 attributes: true, |
455 attributeOldValue: true, | 455 attributeOldValue: true, |
456 attributeFilter: ['src', 'partition'] | 456 attributeFilter: ['src', 'partition'] |
457 }; | 457 }; |
458 this.srcAndPartitionObserver.observe(this.webviewNode, params); | 458 this.srcAndPartitionObserver.observe(this.webviewNode, params); |
459 }; | 459 }; |
460 | 460 |
461 /** | 461 /** |
462 * @private | 462 * @private |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
740 WebViewInternal.prototype.dispatchEvent = function(webViewEvent) { | 740 WebViewInternal.prototype.dispatchEvent = function(webViewEvent) { |
741 return this.webviewNode.dispatchEvent(webViewEvent); | 741 return this.webviewNode.dispatchEvent(webViewEvent); |
742 }; | 742 }; |
743 | 743 |
744 /** | 744 /** |
745 * Adds an 'on<event>' property on the webview, which can be used to set/unset | 745 * Adds an 'on<event>' property on the webview, which can be used to set/unset |
746 * an event handler. | 746 * an event handler. |
747 */ | 747 */ |
748 WebViewInternal.prototype.setupEventProperty = function(eventName) { | 748 WebViewInternal.prototype.setupEventProperty = function(eventName) { |
749 var propertyName = 'on' + eventName.toLowerCase(); | 749 var propertyName = 'on' + eventName.toLowerCase(); |
750 Object.defineProperty(webviewNode, propertyName, { | 750 Object.defineProperty(this.webviewNode, propertyName, { |
751 get: function() { | 751 get: function() { |
752 return this.on[propertyName]; | 752 return this.on[propertyName]; |
753 }.bind(this), | 753 }.bind(this), |
754 set: function(value) { | 754 set: function(value) { |
755 if (this.on[propertyName]) | 755 if (this.on[propertyName]) |
756 this.webviewNode.removeEventListener(eventName, this.on[propertyName]); | 756 this.webviewNode.removeEventListener(eventName, this.on[propertyName]); |
757 this.on[propertyName] = value; | 757 this.on[propertyName] = value; |
758 if (value) | 758 if (value) |
759 this.webviewNode.addEventListener(eventName, value); | 759 this.webviewNode.addEventListener(eventName, value); |
760 }.bind(this), | 760 }.bind(this), |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1031 }; | 1031 }; |
1032 | 1032 |
1033 /** | 1033 /** |
1034 * Implemented when the experimental API is available. | 1034 * Implemented when the experimental API is available. |
1035 * @private | 1035 * @private |
1036 */ | 1036 */ |
1037 WebViewInternal.prototype.setupExperimentalContextMenus = function() {}; | 1037 WebViewInternal.prototype.setupExperimentalContextMenus = function() {}; |
1038 | 1038 |
1039 exports.WebView = WebView; | 1039 exports.WebView = WebView; |
1040 exports.WebViewInternal = WebViewInternal; | 1040 exports.WebViewInternal = WebViewInternal; |
OLD | NEW |