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

Side by Side Diff: Source/devtools/front_end/elements/MetricsSidebarPane.js

Issue 1285183006: DevTools: WI.Throttler goes promisified. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@cc
Patch Set: remove dependent patchset Created 5 years, 4 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2007 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 20 matching lines...) Expand all
31 * @extends {WebInspector.ElementsSidebarPane} 31 * @extends {WebInspector.ElementsSidebarPane}
32 */ 32 */
33 WebInspector.MetricsSidebarPane = function() 33 WebInspector.MetricsSidebarPane = function()
34 { 34 {
35 WebInspector.ElementsSidebarPane.call(this, WebInspector.UIString("Metrics") ); 35 WebInspector.ElementsSidebarPane.call(this, WebInspector.UIString("Metrics") );
36 } 36 }
37 37
38 WebInspector.MetricsSidebarPane.prototype = { 38 WebInspector.MetricsSidebarPane.prototype = {
39 /** 39 /**
40 * @override 40 * @override
41 * @param {!WebInspector.Throttler.FinishCallback} finishedCallback
42 * @protected 41 * @protected
42 * @return {!Promise.<?>}
43 */ 43 */
44 doUpdate: function(finishedCallback) 44 doUpdate: function()
45 { 45 {
46 // "style" attribute might have changed. Update metrics unless they are being edited 46 // "style" attribute might have changed. Update metrics unless they are being edited
47 // (if a CSS property is added, a StyleSheetChanged event is dispatched) . 47 // (if a CSS property is added, a StyleSheetChanged event is dispatched) .
48 if (this._isEditingMetrics) { 48 if (this._isEditingMetrics)
49 finishedCallback(); 49 return Promise.resolve();
50 return;
51 }
52 50
53 // FIXME: avoid updates of a collapsed pane. 51 // FIXME: avoid updates of a collapsed pane.
54 var node = this.node(); 52 var node = this.node();
55 var cssModel = this.cssModel(); 53 var cssModel = this.cssModel();
56 if (!node || node.nodeType() !== Node.ELEMENT_NODE || !cssModel) { 54 if (!node || node.nodeType() !== Node.ELEMENT_NODE || !cssModel) {
57 this.element.removeChildren(); 55 this.element.removeChildren();
58 finishedCallback(); 56 return Promise.resolve();
59 return;
60 } 57 }
61 58
62 /** 59 /**
63 * @param {?WebInspector.CSSStyleDeclaration} style 60 * @param {?WebInspector.CSSStyleDeclaration} style
64 * @this {WebInspector.MetricsSidebarPane} 61 * @this {WebInspector.MetricsSidebarPane}
65 */ 62 */
66 function callback(style) 63 function callback(style)
67 { 64 {
68 if (!style || this.node() !== node) 65 if (!style || this.node() !== node)
69 return; 66 return;
70 this._updateMetrics(style); 67 this._updateMetrics(style);
71 } 68 }
72 /** 69 /**
73 * @param {?WebInspector.CSSStyleModel.InlineStyleResult} inlineStyleRes ult 70 * @param {?WebInspector.CSSStyleModel.InlineStyleResult} inlineStyleRes ult
74 * @this {WebInspector.MetricsSidebarPane} 71 * @this {WebInspector.MetricsSidebarPane}
75 */ 72 */
76 function inlineStyleCallback(inlineStyleResult) 73 function inlineStyleCallback(inlineStyleResult)
77 { 74 {
78 if (inlineStyleResult && this.node() === node) 75 if (inlineStyleResult && this.node() === node)
79 this.inlineStyle = inlineStyleResult.inlineStyle; 76 this.inlineStyle = inlineStyleResult.inlineStyle;
80 } 77 }
81 78
82 var promises = [ 79 var promises = [
83 cssModel.computedStylePromise(node.id).then(callback.bind(this)), 80 cssModel.computedStylePromise(node.id).then(callback.bind(this)),
84 cssModel.inlineStylesPromise(node.id).then(inlineStyleCallback.bind( this)) 81 cssModel.inlineStylesPromise(node.id).then(inlineStyleCallback.bind( this))
85 ]; 82 ];
86 Promise.all(promises) 83 return Promise.all(promises);
87 .then(finishedCallback.bind(null, undefined))
88 .catch(/** @type {function()} */(finishedCallback));
89 }, 84 },
90 85
91 /** 86 /**
92 * @override 87 * @override
93 */ 88 */
94 onDOMModelChanged: function() 89 onDOMModelChanged: function()
95 { 90 {
96 this.update(); 91 this.update();
97 }, 92 },
98 93
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 }, 455 },
461 456
462 editingCommitted: function(element, userInput, previousContent, context) 457 editingCommitted: function(element, userInput, previousContent, context)
463 { 458 {
464 this.editingEnded(element, context); 459 this.editingEnded(element, context);
465 this._applyUserInput(element, userInput, previousContent, context, true) ; 460 this._applyUserInput(element, userInput, previousContent, context, true) ;
466 }, 461 },
467 462
468 __proto__: WebInspector.ElementsSidebarPane.prototype 463 __proto__: WebInspector.ElementsSidebarPane.prototype
469 } 464 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/elements/EventListenersWidget.js ('k') | Source/devtools/front_end/elements/PlatformFontsWidget.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698