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

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

Issue 2604883002: DevTools: namespace globals (Closed)
Patch Set: address CL feedback Created 3 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 18 matching lines...) Expand all
29 */ 29 */
30 30
31 /** 31 /**
32 * @unrestricted 32 * @unrestricted
33 */ 33 */
34 Sources.RevisionHistoryView = class extends UI.VBox { 34 Sources.RevisionHistoryView = class extends UI.VBox {
35 constructor() { 35 constructor() {
36 super(); 36 super();
37 this._uiSourceCodeItems = new Map(); 37 this._uiSourceCodeItems = new Map();
38 38
39 this._treeOutline = new TreeOutlineInShadow(); 39 this._treeOutline = new UI.TreeOutlineInShadow();
40 this._treeOutline.registerRequiredCSS('sources/revisionHistory.css'); 40 this._treeOutline.registerRequiredCSS('sources/revisionHistory.css');
41 this._treeOutline.makeDense(); 41 this._treeOutline.makeDense();
42 this.element.appendChild(this._treeOutline.element); 42 this.element.appendChild(this._treeOutline.element);
43 43
44 /** 44 /**
45 * @param {!Workspace.UISourceCode} uiSourceCode 45 * @param {!Workspace.UISourceCode} uiSourceCode
46 * @this {Sources.RevisionHistoryView} 46 * @this {Sources.RevisionHistoryView}
47 */ 47 */
48 function populateRevisions(uiSourceCode) { 48 function populateRevisions(uiSourceCode) {
49 if (uiSourceCode.history.length) 49 if (uiSourceCode.history.length)
(...skipping 15 matching lines...) Expand all
65 UI.viewManager.showView('sources.history'); 65 UI.viewManager.showView('sources.history');
66 var historyView = 66 var historyView =
67 /** @type {!Sources.RevisionHistoryView} */ (self.runtime.sharedInstance (Sources.RevisionHistoryView)); 67 /** @type {!Sources.RevisionHistoryView} */ (self.runtime.sharedInstance (Sources.RevisionHistoryView));
68 historyView._revealUISourceCode(uiSourceCode); 68 historyView._revealUISourceCode(uiSourceCode);
69 } 69 }
70 70
71 /** 71 /**
72 * @param {!Workspace.UISourceCode} uiSourceCode 72 * @param {!Workspace.UISourceCode} uiSourceCode
73 */ 73 */
74 _createUISourceCodeItem(uiSourceCode) { 74 _createUISourceCodeItem(uiSourceCode) {
75 var uiSourceCodeItem = new TreeElement(uiSourceCode.displayName(), true); 75 var uiSourceCodeItem = new UI.TreeElement(uiSourceCode.displayName(), true);
76 uiSourceCodeItem.selectable = false; 76 uiSourceCodeItem.selectable = false;
77 77
78 // Insert in sorted order 78 // Insert in sorted order
79 var rootElement = this._treeOutline.rootElement(); 79 var rootElement = this._treeOutline.rootElement();
80 for (var i = 0; i < rootElement.childCount(); ++i) { 80 for (var i = 0; i < rootElement.childCount(); ++i) {
81 if (rootElement.childAt(i).title.localeCompare(uiSourceCode.displayName()) > 0) { 81 if (rootElement.childAt(i).title.localeCompare(uiSourceCode.displayName()) > 0) {
82 rootElement.insertChild(uiSourceCodeItem, i); 82 rootElement.insertChild(uiSourceCodeItem, i);
83 break; 83 break;
84 } 84 }
85 } 85 }
86 if (i === rootElement.childCount()) 86 if (i === rootElement.childCount())
87 rootElement.appendChild(uiSourceCodeItem); 87 rootElement.appendChild(uiSourceCodeItem);
88 88
89 this._uiSourceCodeItems.set(uiSourceCode, uiSourceCodeItem); 89 this._uiSourceCodeItems.set(uiSourceCode, uiSourceCodeItem);
90 90
91 var revisionCount = uiSourceCode.history.length; 91 var revisionCount = uiSourceCode.history.length;
92 for (var i = revisionCount - 1; i >= 0; --i) { 92 for (var i = revisionCount - 1; i >= 0; --i) {
93 var revision = uiSourceCode.history[i]; 93 var revision = uiSourceCode.history[i];
94 var historyItem = 94 var historyItem =
95 new Sources.RevisionHistoryTreeElement(revision, uiSourceCode.history[ i - 1], i !== revisionCount - 1); 95 new Sources.RevisionHistoryTreeElement(revision, uiSourceCode.history[ i - 1], i !== revisionCount - 1);
96 uiSourceCodeItem.appendChild(historyItem); 96 uiSourceCodeItem.appendChild(historyItem);
97 } 97 }
98 98
99 var linkItem = new TreeElement(); 99 var linkItem = new UI.TreeElement();
100 linkItem.selectable = false; 100 linkItem.selectable = false;
101 uiSourceCodeItem.appendChild(linkItem); 101 uiSourceCodeItem.appendChild(linkItem);
102 102
103 var revertToOriginal = 103 var revertToOriginal =
104 linkItem.listItemElement.createChild('span', 'revision-history-link revi sion-history-link-row'); 104 linkItem.listItemElement.createChild('span', 'revision-history-link revi sion-history-link-row');
105 revertToOriginal.textContent = Common.UIString('apply original content'); 105 revertToOriginal.textContent = Common.UIString('apply original content');
106 revertToOriginal.addEventListener('click', this._revertToOriginal.bind(this, uiSourceCode)); 106 revertToOriginal.addEventListener('click', this._revertToOriginal.bind(this, uiSourceCode));
107 107
108 var clearHistoryElement = uiSourceCodeItem.listItemElement.createChild('span ', 'revision-history-link'); 108 var clearHistoryElement = uiSourceCodeItem.listItemElement.createChild('span ', 'revision-history-link');
109 clearHistoryElement.textContent = Common.UIString('revert'); 109 clearHistoryElement.textContent = Common.UIString('revert');
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 _projectRemoved(event) { 171 _projectRemoved(event) {
172 var project = event.data; 172 var project = event.data;
173 project.uiSourceCodes().forEach(this._removeUISourceCode.bind(this)); 173 project.uiSourceCodes().forEach(this._removeUISourceCode.bind(this));
174 } 174 }
175 }; 175 };
176 176
177 177
178 /** 178 /**
179 * @unrestricted 179 * @unrestricted
180 */ 180 */
181 Sources.RevisionHistoryTreeElement = class extends TreeElement { 181 Sources.RevisionHistoryTreeElement = class extends UI.TreeElement {
182 /** 182 /**
183 * @param {!Workspace.Revision} revision 183 * @param {!Workspace.Revision} revision
184 * @param {!Workspace.Revision} baseRevision 184 * @param {!Workspace.Revision} baseRevision
185 * @param {boolean} allowRevert 185 * @param {boolean} allowRevert
186 */ 186 */
187 constructor(revision, baseRevision, allowRevert) { 187 constructor(revision, baseRevision, allowRevert) {
188 super(revision.timestamp.toLocaleTimeString(), true); 188 super(revision.timestamp.toLocaleTimeString(), true);
189 this.selectable = false; 189 this.selectable = false;
190 190
191 this._revision = revision; 191 this._revision = revision;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 this._revertElement.remove(); 267 this._revertElement.remove();
268 } 268 }
269 269
270 /** 270 /**
271 * @param {?number} baseLineNumber 271 * @param {?number} baseLineNumber
272 * @param {?number} newLineNumber 272 * @param {?number} newLineNumber
273 * @param {string} lineContent 273 * @param {string} lineContent
274 * @param {string} changeType 274 * @param {string} changeType
275 */ 275 */
276 _createLine(baseLineNumber, newLineNumber, lineContent, changeType) { 276 _createLine(baseLineNumber, newLineNumber, lineContent, changeType) {
277 var child = new TreeElement(); 277 var child = new UI.TreeElement();
278 child.selectable = false; 278 child.selectable = false;
279 this.appendChild(child); 279 this.appendChild(child);
280 280
281 function appendLineNumber(lineNumber) { 281 function appendLineNumber(lineNumber) {
282 var numberString = lineNumber !== null ? numberToStringWithSpacesPadding(l ineNumber + 1, 4) : spacesPadding(4); 282 var numberString = lineNumber !== null ? numberToStringWithSpacesPadding(l ineNumber + 1, 4) : spacesPadding(4);
283 var lineNumberSpan = createElement('span'); 283 var lineNumberSpan = createElement('span');
284 lineNumberSpan.classList.add('webkit-line-number'); 284 lineNumberSpan.classList.add('webkit-line-number');
285 lineNumberSpan.textContent = numberString; 285 lineNumberSpan.textContent = numberString;
286 child.listItemElement.appendChild(lineNumberSpan); 286 child.listItemElement.appendChild(lineNumberSpan);
287 } 287 }
288 288
289 appendLineNumber(baseLineNumber); 289 appendLineNumber(baseLineNumber);
290 appendLineNumber(newLineNumber); 290 appendLineNumber(newLineNumber);
291 291
292 var contentSpan = createElement('span'); 292 var contentSpan = createElement('span');
293 contentSpan.textContent = lineContent; 293 contentSpan.textContent = lineContent;
294 child.listItemElement.appendChild(contentSpan); 294 child.listItemElement.appendChild(contentSpan);
295 child.listItemElement.classList.add('revision-history-line'); 295 child.listItemElement.classList.add('revision-history-line');
296 contentSpan.classList.add('revision-history-line-' + changeType); 296 contentSpan.classList.add('revision-history-line-' + changeType);
297 } 297 }
298 298
299 allowRevert() { 299 allowRevert() {
300 this._revertElement.classList.remove('hidden'); 300 this._revertElement.classList.remove('hidden');
301 } 301 }
302 }; 302 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698