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

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

Issue 2769843003: DevTools: split text_utils out of common module (Closed)
Patch Set: rebaseline Created 3 years, 9 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) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 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 * 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 * 10 *
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 */ 230 */
231 function saveHistory() { 231 function saveHistory() {
232 this._history.save(this._previouslyViewedFilesSetting); 232 this._history.save(this._previouslyViewedFilesSetting);
233 } 233 }
234 } 234 }
235 235
236 /** 236 /**
237 * @param {!Common.Event} event 237 * @param {!Common.Event} event
238 */ 238 */
239 _selectionChanged(event) { 239 _selectionChanged(event) {
240 var range = /** @type {!Common.TextRange} */ (event.data); 240 var range = /** @type {!TextUtils.TextRange} */ (event.data);
241 this._history.updateSelectionRange(this._currentFile.url(), range); 241 this._history.updateSelectionRange(this._currentFile.url(), range);
242 this._history.save(this._previouslyViewedFilesSetting); 242 this._history.save(this._previouslyViewedFilesSetting);
243 } 243 }
244 244
245 /** 245 /**
246 * @param {!Workspace.UISourceCode} uiSourceCode 246 * @param {!Workspace.UISourceCode} uiSourceCode
247 * @param {boolean=} userGesture 247 * @param {boolean=} userGesture
248 */ 248 */
249 _innerShowFile(uiSourceCode, userGesture) { 249 _innerShowFile(uiSourceCode, userGesture) {
250 var binding = Persistence.persistence.binding(uiSourceCode); 250 var binding = Persistence.persistence.binding(uiSourceCode);
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 446
447 this._tabbedPane.appendTab(tabId, title, view, tooltip, userGesture, undefin ed, index); 447 this._tabbedPane.appendTab(tabId, title, view, tooltip, userGesture, undefin ed, index);
448 448
449 this._updateFileTitle(uiSourceCode); 449 this._updateFileTitle(uiSourceCode);
450 this._addUISourceCodeListeners(uiSourceCode); 450 this._addUISourceCodeListeners(uiSourceCode);
451 return tabId; 451 return tabId;
452 } 452 }
453 453
454 /** 454 /**
455 * @param {!UI.Widget} editorView 455 * @param {!UI.Widget} editorView
456 * @param {!Common.TextRange=} selection 456 * @param {!TextUtils.TextRange=} selection
457 * @param {number=} firstLineNumber 457 * @param {number=} firstLineNumber
458 */ 458 */
459 _restoreEditorProperties(editorView, selection, firstLineNumber) { 459 _restoreEditorProperties(editorView, selection, firstLineNumber) {
460 var sourceFrame = 460 var sourceFrame =
461 editorView instanceof SourceFrame.SourceFrame ? /** @type {!SourceFrame. SourceFrame} */ (editorView) : null; 461 editorView instanceof SourceFrame.SourceFrame ? /** @type {!SourceFrame. SourceFrame} */ (editorView) : null;
462 if (!sourceFrame) 462 if (!sourceFrame)
463 return; 463 return;
464 if (selection) 464 if (selection)
465 sourceFrame.setSelection(selection); 465 sourceFrame.setSelection(selection);
466 if (typeof firstLineNumber === 'number') 466 if (typeof firstLineNumber === 'number')
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 Sources.TabbedEditorContainer._tabId = 0; 592 Sources.TabbedEditorContainer._tabId = 0;
593 593
594 Sources.TabbedEditorContainer.maximalPreviouslyViewedFilesCount = 30; 594 Sources.TabbedEditorContainer.maximalPreviouslyViewedFilesCount = 30;
595 595
596 /** 596 /**
597 * @unrestricted 597 * @unrestricted
598 */ 598 */
599 Sources.TabbedEditorContainer.HistoryItem = class { 599 Sources.TabbedEditorContainer.HistoryItem = class {
600 /** 600 /**
601 * @param {string} url 601 * @param {string} url
602 * @param {!Common.TextRange=} selectionRange 602 * @param {!TextUtils.TextRange=} selectionRange
603 * @param {number=} scrollLineNumber 603 * @param {number=} scrollLineNumber
604 */ 604 */
605 constructor(url, selectionRange, scrollLineNumber) { 605 constructor(url, selectionRange, scrollLineNumber) {
606 /** @const */ this.url = url; 606 /** @const */ this.url = url;
607 /** @const */ this._isSerializable = 607 /** @const */ this._isSerializable =
608 url.length < Sources.TabbedEditorContainer.HistoryItem.serializableUrlLe ngthLimit; 608 url.length < Sources.TabbedEditorContainer.HistoryItem.serializableUrlLe ngthLimit;
609 this.selectionRange = selectionRange; 609 this.selectionRange = selectionRange;
610 this.scrollLineNumber = scrollLineNumber; 610 this.scrollLineNumber = scrollLineNumber;
611 } 611 }
612 612
613 /** 613 /**
614 * @param {!Object} serializedHistoryItem 614 * @param {!Object} serializedHistoryItem
615 * @return {!Sources.TabbedEditorContainer.HistoryItem} 615 * @return {!Sources.TabbedEditorContainer.HistoryItem}
616 */ 616 */
617 static fromObject(serializedHistoryItem) { 617 static fromObject(serializedHistoryItem) {
618 var selectionRange = serializedHistoryItem.selectionRange ? 618 var selectionRange = serializedHistoryItem.selectionRange ?
619 Common.TextRange.fromObject(serializedHistoryItem.selectionRange) : 619 TextUtils.TextRange.fromObject(serializedHistoryItem.selectionRange) :
620 undefined; 620 undefined;
621 return new Sources.TabbedEditorContainer.HistoryItem( 621 return new Sources.TabbedEditorContainer.HistoryItem(
622 serializedHistoryItem.url, selectionRange, serializedHistoryItem.scrollL ineNumber); 622 serializedHistoryItem.url, selectionRange, serializedHistoryItem.scrollL ineNumber);
623 } 623 }
624 624
625 /** 625 /**
626 * @return {?Object} 626 * @return {?Object}
627 */ 627 */
628 serializeToObject() { 628 serializeToObject() {
629 if (!this._isSerializable) 629 if (!this._isSerializable)
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 /** @type {!Map<string, number>} */ 674 /** @type {!Map<string, number>} */
675 this._itemsIndex = new Map(); 675 this._itemsIndex = new Map();
676 for (var i = 0; i < this._items.length; ++i) { 676 for (var i = 0; i < this._items.length; ++i) {
677 console.assert(!this._itemsIndex.has(this._items[i].url)); 677 console.assert(!this._itemsIndex.has(this._items[i].url));
678 this._itemsIndex.set(this._items[i].url, i); 678 this._itemsIndex.set(this._items[i].url, i);
679 } 679 }
680 } 680 }
681 681
682 /** 682 /**
683 * @param {string} url 683 * @param {string} url
684 * @return {!Common.TextRange|undefined} 684 * @return {!TextUtils.TextRange|undefined}
685 */ 685 */
686 selectionRange(url) { 686 selectionRange(url) {
687 var index = this.index(url); 687 var index = this.index(url);
688 return index !== -1 ? this._items[index].selectionRange : undefined; 688 return index !== -1 ? this._items[index].selectionRange : undefined;
689 } 689 }
690 690
691 /** 691 /**
692 * @param {string} url 692 * @param {string} url
693 * @param {!Common.TextRange=} selectionRange 693 * @param {!TextUtils.TextRange=} selectionRange
694 */ 694 */
695 updateSelectionRange(url, selectionRange) { 695 updateSelectionRange(url, selectionRange) {
696 if (!selectionRange) 696 if (!selectionRange)
697 return; 697 return;
698 var index = this.index(url); 698 var index = this.index(url);
699 if (index === -1) 699 if (index === -1)
700 return; 700 return;
701 this._items[index].selectionRange = selectionRange; 701 this._items[index].selectionRange = selectionRange;
702 } 702 }
703 703
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
807 807
808 /** 808 /**
809 * @override 809 * @override
810 * @param {string} tabId 810 * @param {string} tabId
811 * @param {!UI.ContextMenu} contextMenu 811 * @param {!UI.ContextMenu} contextMenu
812 */ 812 */
813 onContextMenu(tabId, contextMenu) { 813 onContextMenu(tabId, contextMenu) {
814 this._editorContainer._onContextMenu(tabId, contextMenu); 814 this._editorContainer._onContextMenu(tabId, contextMenu);
815 } 815 }
816 }; 816 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698