OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 the attributes of the <extensionview> tag. | 5 // This module implements the attributes of the <extensionview> tag. |
6 | 6 |
7 var GuestViewInternal = | 7 var GuestViewInternal = |
8 require('binding').Binding.create('guestViewInternal').generate(); | 8 require('binding').Binding.create('guestViewInternal').generate(); |
9 var ExtensionViewImpl = require('extensionView').ExtensionViewImpl; | 9 var ExtensionViewImpl = require('extensionView').ExtensionViewImpl; |
10 var ExtensionViewConstants = | 10 var ExtensionViewConstants = |
(...skipping 19 matching lines...) Expand all Loading... |
30 }; | 30 }; |
31 | 31 |
32 // Sets the attribute's value. | 32 // Sets the attribute's value. |
33 ExtensionViewAttribute.prototype.setValue = function(value) { | 33 ExtensionViewAttribute.prototype.setValue = function(value) { |
34 this.extensionViewImpl.element.setAttribute(this.name, value || ''); | 34 this.extensionViewImpl.element.setAttribute(this.name, value || ''); |
35 }; | 35 }; |
36 | 36 |
37 // Changes the attribute's value without triggering its mutation handler. | 37 // Changes the attribute's value without triggering its mutation handler. |
38 ExtensionViewAttribute.prototype.setValueIgnoreMutation = function(value) { | 38 ExtensionViewAttribute.prototype.setValueIgnoreMutation = function(value) { |
39 this.ignoreMutation = true; | 39 this.ignoreMutation = true; |
40 this.extensionViewImpl.element.setAttribute(this.name, value || ''); | 40 this.setValue(value); |
41 this.ignoreMutation = false; | 41 this.ignoreMutation = false; |
42 } | 42 } |
43 | 43 |
44 // Defines this attribute as a property on the extensionview node. | 44 // Defines this attribute as a property on the extensionview node. |
45 ExtensionViewAttribute.prototype.defineProperty = function() { | 45 ExtensionViewAttribute.prototype.defineProperty = function() { |
46 Object.defineProperty(this.extensionViewImpl.element, this.name, { | 46 Object.defineProperty(this.extensionViewImpl.element, this.name, { |
47 get: function() { | 47 get: function() { |
48 return this.getValue(); | 48 return this.getValue(); |
49 }.bind(this), | 49 }.bind(this), |
50 set: function(value) { | 50 set: function(value) { |
(...skipping 22 matching lines...) Expand all Loading... |
73 ExtensionViewAttribute.call(this, ExtensionViewConstants.ATTRIBUTE_SRC, | 73 ExtensionViewAttribute.call(this, ExtensionViewConstants.ATTRIBUTE_SRC, |
74 extensionViewImpl); | 74 extensionViewImpl); |
75 this.setupMutationObserver(); | 75 this.setupMutationObserver(); |
76 this.beforeFirstNavigation = true; | 76 this.beforeFirstNavigation = true; |
77 } | 77 } |
78 | 78 |
79 SrcAttribute.prototype.__proto__ = ExtensionViewAttribute.prototype; | 79 SrcAttribute.prototype.__proto__ = ExtensionViewAttribute.prototype; |
80 | 80 |
81 SrcAttribute.prototype.setValueIgnoreMutation = function(value) { | 81 SrcAttribute.prototype.setValueIgnoreMutation = function(value) { |
82 this.observer.takeRecords(); | 82 this.observer.takeRecords(); |
83 this.ignoreMutation = true; | 83 ExtensionViewAttribute.prototype.setValueIgnoreMutation.call(this, value); |
84 this.extensionViewImpl.element.setAttribute(this.name, value || ''); | |
85 this.ignoreMutation = false; | |
86 } | 84 } |
87 | 85 |
88 SrcAttribute.prototype.handleMutation = function(oldValue, newValue) { | 86 SrcAttribute.prototype.handleMutation = function(oldValue, newValue) { |
89 if (!newValue && oldValue) { | 87 if (!newValue && oldValue) { |
90 this.setValueIgnoreMutation(oldValue); | 88 this.setValueIgnoreMutation(oldValue); |
91 return; | 89 return; |
92 } | 90 } |
93 this.parse(); | 91 this.parse(); |
94 }; | 92 }; |
95 | 93 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 }; | 132 }; |
135 | 133 |
136 // ----------------------------------------------------------------------------- | 134 // ----------------------------------------------------------------------------- |
137 | 135 |
138 // Sets up all of the extensionview attributes. | 136 // Sets up all of the extensionview attributes. |
139 ExtensionViewImpl.prototype.setupExtensionViewAttributes = function() { | 137 ExtensionViewImpl.prototype.setupExtensionViewAttributes = function() { |
140 this.attributes = {}; | 138 this.attributes = {}; |
141 this.attributes[ExtensionViewConstants.ATTRIBUTE_SRC] = | 139 this.attributes[ExtensionViewConstants.ATTRIBUTE_SRC] = |
142 new SrcAttribute(this); | 140 new SrcAttribute(this); |
143 }; | 141 }; |
OLD | NEW |