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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/sources/RevisionHistoryView.js

Issue 1609973002: DevTools: promisify ContentProvider.requestContent and all its clients. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit Created 4 years, 11 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) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 { 202 {
203 TreeElement.call(this, revision.timestamp.toLocaleTimeString(), true); 203 TreeElement.call(this, revision.timestamp.toLocaleTimeString(), true);
204 this.selectable = false; 204 this.selectable = false;
205 205
206 this._revision = revision; 206 this._revision = revision;
207 this._baseRevision = baseRevision; 207 this._baseRevision = baseRevision;
208 208
209 this._revertElement = createElement("span"); 209 this._revertElement = createElement("span");
210 this._revertElement.className = "revision-history-link"; 210 this._revertElement.className = "revision-history-link";
211 this._revertElement.textContent = WebInspector.UIString("apply revision cont ent"); 211 this._revertElement.textContent = WebInspector.UIString("apply revision cont ent");
212 this._revertElement.addEventListener("click", this._revision.revertToThis.bi nd(this._revision), false); 212 this._revertElement.addEventListener("click", event => {this._revision.rever tToThis();}, false);
213 if (!allowRevert) 213 if (!allowRevert)
214 this._revertElement.classList.add("hidden"); 214 this._revertElement.classList.add("hidden");
215 } 215 }
216 216
217 WebInspector.RevisionHistoryTreeElement.prototype = { 217 WebInspector.RevisionHistoryTreeElement.prototype = {
218 onattach: function() 218 onattach: function()
219 { 219 {
220 this.listItemElement.classList.add("revision-history-revision"); 220 this.listItemElement.classList.add("revision-history-revision");
221 }, 221 },
222 222
223 onpopulate: function() 223 onpopulate: function()
224 { 224 {
225 this.listItemElement.appendChild(this._revertElement); 225 this.listItemElement.appendChild(this._revertElement);
226 226
227 this.childrenListElement.classList.add("source-code"); 227 this.childrenListElement.classList.add("source-code");
228 if (this._baseRevision) 228 Promise.all([
229 this._baseRevision.requestContent(step1.bind(this)); 229 this._baseRevision ? this._baseRevision.requestContent() : this._rev ision.uiSourceCode.requestOriginalContent(),
230 else 230 this._revision.requestContent()
231 this._revision.uiSourceCode.requestOriginalContent(step1.bind(this)) ; 231 ]).spread(diff.bind(this));
232
233 /**
234 * @param {?string} baseContent
235 * @this {WebInspector.RevisionHistoryTreeElement}
236 */
237 function step1(baseContent)
238 {
239 this._revision.requestContent(step2.bind(this, baseContent));
240 }
241 232
242 /** 233 /**
243 * @param {?string} baseContent 234 * @param {?string} baseContent
244 * @param {?string} newContent 235 * @param {?string} newContent
245 * @this {WebInspector.RevisionHistoryTreeElement} 236 * @this {WebInspector.RevisionHistoryTreeElement}
246 */ 237 */
247 function step2(baseContent, newContent) 238 function diff(baseContent, newContent)
248 { 239 {
249 var baseLines = baseContent.split("\n"); 240 var baseLines = baseContent.split("\n");
250 var newLines = newContent.split("\n"); 241 var newLines = newContent.split("\n");
251 var opcodes = WebInspector.Diff.lineDiff(baseLines, newLines); 242 var opcodes = WebInspector.Diff.lineDiff(baseLines, newLines);
252 var lastWasSeparator = false; 243 var lastWasSeparator = false;
253 244
254 var baseLineNumber = 0; 245 var baseLineNumber = 0;
255 var newLineNumber = 0; 246 var newLineNumber = 0;
256 for (var idx = 0; idx < opcodes.length; idx++) { 247 for (var idx = 0; idx < opcodes.length; idx++) {
257 var code = opcodes[idx][0]; 248 var code = opcodes[idx][0];
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 contentSpan.classList.add("revision-history-line-" + changeType); 304 contentSpan.classList.add("revision-history-line-" + changeType);
314 }, 305 },
315 306
316 allowRevert: function() 307 allowRevert: function()
317 { 308 {
318 this._revertElement.classList.remove("hidden"); 309 this._revertElement.classList.remove("hidden");
319 }, 310 },
320 311
321 __proto__: TreeElement.prototype 312 __proto__: TreeElement.prototype
322 } 313 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698