Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(177)

Side by Side Diff: extensions/renderer/resources/guest_view/web_view_attributes.js

Issue 928623002: <webview> + <extensionview>: Generalize setValueIgnoreMutation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « extensions/renderer/resources/guest_view/extension_view_attributes.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <webview> tag. 5 // This module implements the attributes of the <webview> 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 WebViewImpl = require('webView').WebViewImpl; 9 var WebViewImpl = require('webView').WebViewImpl;
10 var WebViewConstants = require('webViewConstants').WebViewConstants; 10 var WebViewConstants = require('webViewConstants').WebViewConstants;
(...skipping 17 matching lines...) Expand all
28 }; 28 };
29 29
30 // Sets the attribute's value. 30 // Sets the attribute's value.
31 WebViewAttribute.prototype.setValue = function(value) { 31 WebViewAttribute.prototype.setValue = function(value) {
32 this.webViewImpl.element.setAttribute(this.name, value || ''); 32 this.webViewImpl.element.setAttribute(this.name, value || '');
33 }; 33 };
34 34
35 // Changes the attribute's value without triggering its mutation handler. 35 // Changes the attribute's value without triggering its mutation handler.
36 WebViewAttribute.prototype.setValueIgnoreMutation = function(value) { 36 WebViewAttribute.prototype.setValueIgnoreMutation = function(value) {
37 this.ignoreMutation = true; 37 this.ignoreMutation = true;
38 this.webViewImpl.element.setAttribute(this.name, value || ''); 38 this.setValue(value);
39 this.ignoreMutation = false; 39 this.ignoreMutation = false;
40 } 40 }
41 41
42 // Defines this attribute as a property on the webview node. 42 // Defines this attribute as a property on the webview node.
43 WebViewAttribute.prototype.defineProperty = function() { 43 WebViewAttribute.prototype.defineProperty = function() {
44 Object.defineProperty(this.webViewImpl.element, this.name, { 44 Object.defineProperty(this.webViewImpl.element, this.name, {
45 get: function() { 45 get: function() {
46 return this.getValue(); 46 return this.getValue();
47 }.bind(this), 47 }.bind(this),
48 set: function(value) { 48 set: function(value) {
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 } 204 }
205 205
206 SrcAttribute.prototype.__proto__ = WebViewAttribute.prototype; 206 SrcAttribute.prototype.__proto__ = WebViewAttribute.prototype;
207 207
208 SrcAttribute.prototype.setValueIgnoreMutation = function(value) { 208 SrcAttribute.prototype.setValueIgnoreMutation = function(value) {
209 // takeRecords() is needed to clear queued up src mutations. Without it, it is 209 // takeRecords() is needed to clear queued up src mutations. Without it, it is
210 // possible for this change to get picked up asyncronously by src's mutation 210 // possible for this change to get picked up asyncronously by src's mutation
211 // observer |observer|, and then get handled even though we do not want to 211 // observer |observer|, and then get handled even though we do not want to
212 // handle this mutation. 212 // handle this mutation.
213 this.observer.takeRecords(); 213 this.observer.takeRecords();
214 this.ignoreMutation = true; 214 WebViewAttribute.prototype.setValueIgnoreMutation.call(this, value);
215 this.webViewImpl.element.setAttribute(this.name, value || '');
216 this.ignoreMutation = false;
217 } 215 }
218 216
219 SrcAttribute.prototype.handleMutation = function(oldValue, newValue) { 217 SrcAttribute.prototype.handleMutation = function(oldValue, newValue) {
220 // Once we have navigated, we don't allow clearing the src attribute. 218 // Once we have navigated, we don't allow clearing the src attribute.
221 // Once <webview> enters a navigated state, it cannot return to a 219 // Once <webview> enters a navigated state, it cannot return to a
222 // placeholder state. 220 // placeholder state.
223 if (!newValue && oldValue) { 221 if (!newValue && oldValue) {
224 // src attribute changes normally initiate a navigation. We suppress 222 // src attribute changes normally initiate a navigation. We suppress
225 // the next src attribute handler call to avoid reloading the page 223 // the next src attribute handler call to avoid reloading the page
226 // on every guest-initiated navigation. 224 // on every guest-initiated navigation.
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 295
298 var autosizeAttributes = [WebViewConstants.ATTRIBUTE_MAXHEIGHT, 296 var autosizeAttributes = [WebViewConstants.ATTRIBUTE_MAXHEIGHT,
299 WebViewConstants.ATTRIBUTE_MAXWIDTH, 297 WebViewConstants.ATTRIBUTE_MAXWIDTH,
300 WebViewConstants.ATTRIBUTE_MINHEIGHT, 298 WebViewConstants.ATTRIBUTE_MINHEIGHT,
301 WebViewConstants.ATTRIBUTE_MINWIDTH]; 299 WebViewConstants.ATTRIBUTE_MINWIDTH];
302 for (var i = 0; autosizeAttributes[i]; ++i) { 300 for (var i = 0; autosizeAttributes[i]; ++i) {
303 this.attributes[autosizeAttributes[i]] = 301 this.attributes[autosizeAttributes[i]] =
304 new AutosizeDimensionAttribute(autosizeAttributes[i], this); 302 new AutosizeDimensionAttribute(autosizeAttributes[i], this);
305 } 303 }
306 }; 304 };
OLDNEW
« no previous file with comments | « extensions/renderer/resources/guest_view/extension_view_attributes.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698