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

Side by Side Diff: chrome/browser/resources/md_history/app.crisper.js

Issue 2344803002: MD WebUI: Simplify usage of Templatizer in cr-lazy-render (Closed)
Patch Set: _render -> render_ Created 4 years, 3 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 | « no previous file | ui/webui/resources/cr_elements/cr_lazy_render/cr_lazy_render.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 function PromiseResolver() { 4 function PromiseResolver() {
5 this.resolve_; 5 this.resolve_;
6 this.reject_; 6 this.reject_;
7 this.promise_ = new Promise(function(resolve, reject) { 7 this.promise_ = new Promise(function(resolve, reject) {
8 this.resolve_ = resolve; 8 this.resolve_ = resolve;
9 this.reject_ = reject; 9 this.reject_ = reject;
10 }.bind(this)); 10 }.bind(this));
(...skipping 5370 matching lines...) Expand 10 before | Expand all | Expand 10 after
5381 }); 5381 });
5382 5382
5383 // Copyright 2016 The Chromium Authors. All rights reserved. 5383 // Copyright 2016 The Chromium Authors. All rights reserved.
5384 // Use of this source code is governed by a BSD-style license that can be 5384 // Use of this source code is governed by a BSD-style license that can be
5385 // found in the LICENSE file. 5385 // found in the LICENSE file.
5386 Polymer({ 5386 Polymer({
5387 is: 'cr-lazy-render', 5387 is: 'cr-lazy-render',
5388 "extends": 'template', 5388 "extends": 'template',
5389 behaviors: [ Polymer.Templatizer ], 5389 behaviors: [ Polymer.Templatizer ],
5390 _renderPromise: null, 5390 _renderPromise: null,
5391 _instance: null, 5391 _child: null,
5392 get: function() { 5392 get: function() {
5393 if (!this._renderPromise) { 5393 if (!this._renderPromise) {
5394 this._renderPromise = new Promise(function(resolve) { 5394 this._renderPromise = new Promise(function(resolve) {
5395 this._debounceTemplate(function() { 5395 this._debounceTemplate(function() {
5396 this._render(); 5396 this._render();
5397 this._renderPromise = null; 5397 this._renderPromise = null;
5398 resolve(this.getIfExists()); 5398 resolve(this.getIfExists());
5399 }.bind(this)); 5399 }.bind(this));
5400 }.bind(this)); 5400 }.bind(this));
5401 } 5401 }
5402 return this._renderPromise; 5402 return this._renderPromise;
5403 }, 5403 },
5404 getIfExists: function() { 5404 getIfExists: function() {
5405 if (this._instance) { 5405 return this._child;
5406 var children = this._instance._children;
5407 for (var i = 0; i < children.length; i++) {
5408 if (children[i].nodeType == Node.ELEMENT_NODE) return children[i];
5409 }
5410 }
5411 return null;
5412 }, 5406 },
5413 _render: function() { 5407 _render: function() {
5414 if (!this.ctor) this.templatize(this); 5408 if (!this.ctor) this.templatize(this);
5415 var parentNode = this.parentNode; 5409 var parentNode = this.parentNode;
5416 if (parentNode && !this._instance) { 5410 if (parentNode && !this._child) {
5417 this._instance = this.stamp({}); 5411 var instance = this.stamp({});
5418 var root = this._instance.root; 5412 this._child = instance.root.querySelector('*');
5419 parentNode.insertBefore(root, this); 5413 parentNode.insertBefore(instance.root, this);
5420 } 5414 }
5421 }, 5415 },
5422 _forwardParentProp: function(prop, value) { 5416 _forwardParentProp: function(prop, value) {
5423 if (this._instance) this._instance.__setProperty(prop, value, true); 5417 if (this._child) this._child._templateInstance[prop] = value;
5424 }, 5418 },
5425 _forwardParentPath: function(path, value) { 5419 _forwardParentPath: function(path, value) {
5426 if (this._instance) this._instance._notifyPath(path, value, true); 5420 if (this._child) this._child._templateInstance.notifyPath(path, value, true) ;
5427 } 5421 }
5428 }); 5422 });
5429 5423
5430 (function() { 5424 (function() {
5431 'use strict'; 5425 'use strict';
5432 Polymer.IronA11yAnnouncer = Polymer({ 5426 Polymer.IronA11yAnnouncer = Polymer({
5433 is: 'iron-a11y-announcer', 5427 is: 'iron-a11y-announcer',
5434 properties: { 5428 properties: {
5435 mode: { 5429 mode: {
5436 type: String, 5430 type: String,
(...skipping 3260 matching lines...) Expand 10 before | Expand all | Expand 10 after
8697 8691
8698 case HistoryRange.MONTH: 8692 case HistoryRange.MONTH:
8699 histogramValue = HistoryPageViewHistogram.GROUPED_MONTH; 8693 histogramValue = HistoryPageViewHistogram.GROUPED_MONTH;
8700 break; 8694 break;
8701 } 8695 }
8702 break; 8696 break;
8703 } 8697 }
8704 md_history.BrowserService.getInstance().recordHistogram('History.HistoryPage View', histogramValue, HistoryPageViewHistogram.END); 8698 md_history.BrowserService.getInstance().recordHistogram('History.HistoryPage View', histogramValue, HistoryPageViewHistogram.END);
8705 } 8699 }
8706 }); 8700 });
OLDNEW
« no previous file with comments | « no previous file | ui/webui/resources/cr_elements/cr_lazy_render/cr_lazy_render.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698