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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/source_frame/SourceFrame.js

Issue 2269183003: DevTools: Merge CodeMirrorTextEditor's copyRange into text (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
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 * * 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 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 * @param {!WebInspector.SearchableView.SearchConfig} searchConfig 481 * @param {!WebInspector.SearchableView.SearchConfig} searchConfig
482 * @param {string} replacement 482 * @param {string} replacement
483 */ 483 */
484 replaceSelectionWith: function(searchConfig, replacement) 484 replaceSelectionWith: function(searchConfig, replacement)
485 { 485 {
486 var range = this._searchResults[this._currentSearchResultIndex]; 486 var range = this._searchResults[this._currentSearchResultIndex];
487 if (!range) 487 if (!range)
488 return; 488 return;
489 this._textEditor.highlightSearchResults(this._searchRegex, null); 489 this._textEditor.highlightSearchResults(this._searchRegex, null);
490 490
491 var oldText = this._textEditor.copyRange(range); 491 var oldText = this._textEditor.text(range);
492 var regex = searchConfig.toSearchRegex(); 492 var regex = searchConfig.toSearchRegex();
493 var text; 493 var text;
494 if (regex.__fromRegExpQuery) 494 if (regex.__fromRegExpQuery)
495 text = oldText.replace(regex, replacement); 495 text = oldText.replace(regex, replacement);
496 else 496 else
497 text = oldText.replace(regex, function() { return replacement; }); 497 text = oldText.replace(regex, function() { return replacement; });
498 498
499 var newRange = this._textEditor.editRange(range, text); 499 var newRange = this._textEditor.editRange(range, text);
500 this._textEditor.setSelection(newRange.collapseToEnd()); 500 this._textEditor.setSelection(newRange.collapseToEnd());
501 }, 501 },
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 this._sourcePosition.setText(WebInspector.UIString("%d selection reg ions", selections.length)); 616 this._sourcePosition.setText(WebInspector.UIString("%d selection reg ions", selections.length));
617 return; 617 return;
618 } 618 }
619 var textRange = selections[0]; 619 var textRange = selections[0];
620 if (textRange.isEmpty()) { 620 if (textRange.isEmpty()) {
621 this._sourcePosition.setText(WebInspector.UIString("Line %d, Column %d", textRange.endLine + 1, textRange.endColumn + 1)); 621 this._sourcePosition.setText(WebInspector.UIString("Line %d, Column %d", textRange.endLine + 1, textRange.endColumn + 1));
622 return; 622 return;
623 } 623 }
624 textRange = textRange.normalize(); 624 textRange = textRange.normalize();
625 625
626 var selectedText = this._textEditor.copyRange(textRange); 626 var selectedText = this._textEditor.text(textRange);
627 if (textRange.startLine === textRange.endLine) 627 if (textRange.startLine === textRange.endLine)
628 this._sourcePosition.setText(WebInspector.UIString("%d characters se lected", selectedText.length)); 628 this._sourcePosition.setText(WebInspector.UIString("%d characters se lected", selectedText.length));
629 else 629 else
630 this._sourcePosition.setText(WebInspector.UIString("%d lines, %d cha racters selected", textRange.endLine - textRange.startLine + 1, selectedText.len gth)); 630 this._sourcePosition.setText(WebInspector.UIString("%d lines, %d cha racters selected", textRange.endLine - textRange.startLine + 1, selectedText.len gth));
631 }, 631 },
632 632
633 /** 633 /**
634 * @override 634 * @override
635 * @param {number} lineNumber 635 * @param {number} lineNumber
636 */ 636 */
637 scrollChanged: function(lineNumber) 637 scrollChanged: function(lineNumber)
638 { 638 {
639 if (this._scrollTimer) 639 if (this._scrollTimer)
640 clearTimeout(this._scrollTimer); 640 clearTimeout(this._scrollTimer);
641 this._scrollTimer = setTimeout(this.dispatchEventToListeners.bind(this, WebInspector.SourceFrame.Events.ScrollChanged, lineNumber), 100); 641 this._scrollTimer = setTimeout(this.dispatchEventToListeners.bind(this, WebInspector.SourceFrame.Events.ScrollChanged, lineNumber), 100);
642 }, 642 },
643 643
644 _handleKeyDown: function(e) 644 _handleKeyDown: function(e)
645 { 645 {
646 var shortcutKey = WebInspector.KeyboardShortcut.makeKeyFromEvent(e); 646 var shortcutKey = WebInspector.KeyboardShortcut.makeKeyFromEvent(e);
647 var handler = this._shortcuts[shortcutKey]; 647 var handler = this._shortcuts[shortcutKey];
648 if (handler && handler()) 648 if (handler && handler())
649 e.consume(true); 649 e.consume(true);
650 }, 650 },
651 651
652 __proto__: WebInspector.SimpleView.prototype 652 __proto__: WebInspector.SimpleView.prototype
653 } 653 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698