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

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

Issue 2450663004: DevTools: do not allow using 'this' before call into super. (Closed)
Patch Set: rebaselined Created 4 years, 1 month 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 WebInspector.SimpleView.call(this, WebInspector.UIString("Source")); 42 WebInspector.SimpleView.call(this, WebInspector.UIString("Source"));
43 43
44 this._url = url; 44 this._url = url;
45 this._lazyContent = lazyContent; 45 this._lazyContent = lazyContent;
46 46
47 this._textEditor = new WebInspector.SourcesTextEditor(this); 47 this._textEditor = new WebInspector.SourcesTextEditor(this);
48 48
49 this._currentSearchResultIndex = -1; 49 this._currentSearchResultIndex = -1;
50 this._searchResults = []; 50 this._searchResults = [];
51 51
52 this._textEditor.setReadOnly(!this.canEditSource());
53 this._textEditor.addEventListener(WebInspector.SourcesTextEditor.Events.Edit orFocused, this._resetCurrentSearchResultIndex, this); 52 this._textEditor.addEventListener(WebInspector.SourcesTextEditor.Events.Edit orFocused, this._resetCurrentSearchResultIndex, this);
54 this._textEditor.addEventListener(WebInspector.SourcesTextEditor.Events.Sele ctionChanged, this._updateSourcePosition, this); 53 this._textEditor.addEventListener(WebInspector.SourcesTextEditor.Events.Sele ctionChanged, this._updateSourcePosition, this);
55 this._textEditor.addEventListener(WebInspector.SourcesTextEditor.Events.Text Changed, event => this.onTextChanged(event.data.oldRange, event.data.newRange)); 54 this._textEditor.addEventListener(WebInspector.SourcesTextEditor.Events.Text Changed, event => this.onTextChanged(event.data.oldRange, event.data.newRange));
56 55
57 this._shortcuts = {}; 56 this._shortcuts = {};
58 this.element.addEventListener("keydown", this._handleKeyDown.bind(this), fal se); 57 this.element.addEventListener("keydown", this._handleKeyDown.bind(this), fal se);
59 58
60 this._sourcePosition = new WebInspector.ToolbarText(); 59 this._sourcePosition = new WebInspector.ToolbarText();
61 60
62 /** 61 /**
63 * @type {?WebInspector.SearchableView} 62 * @type {?WebInspector.SearchableView}
64 */ 63 */
65 this._searchableView = null; 64 this._searchableView = null;
65 this._editable = false;
66 }; 66 };
67 67
68 WebInspector.SourceFrame.prototype = { 68 WebInspector.SourceFrame.prototype = {
69 /** 69 /**
70 * @param {boolean} editable
71 */
72 setEditable: function(editable)
73 {
74 this._editable = editable;
75 this._textEditor.setReadOnly(editable);
76 },
77
78 /**
70 * @param {number} key 79 * @param {number} key
71 * @param {function():boolean} handler 80 * @param {function():boolean} handler
72 */ 81 */
73 addShortcut: function(key, handler) 82 addShortcut: function(key, handler)
74 { 83 {
75 this._shortcuts[key] = handler; 84 this._shortcuts[key] = handler;
76 }, 85 },
77 86
78 /** 87 /**
79 * @override 88 * @override
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 populateTextAreaContextMenu: function(contextMenu, lineNumber, columnNumber) 570 populateTextAreaContextMenu: function(contextMenu, lineNumber, columnNumber)
562 { 571 {
563 return Promise.resolve(); 572 return Promise.resolve();
564 }, 573 },
565 574
566 /** 575 /**
567 * @return {boolean} 576 * @return {boolean}
568 */ 577 */
569 canEditSource: function() 578 canEditSource: function()
570 { 579 {
571 return false; 580 return this._editable;
572 }, 581 },
573 582
574 _updateSourcePosition: function() 583 _updateSourcePosition: function()
575 { 584 {
576 var selections = this._textEditor.selections(); 585 var selections = this._textEditor.selections();
577 if (!selections.length) 586 if (!selections.length)
578 return; 587 return;
579 if (selections.length > 1) { 588 if (selections.length > 1) {
580 this._sourcePosition.setText(WebInspector.UIString("%d selection reg ions", selections.length)); 589 this._sourcePosition.setText(WebInspector.UIString("%d selection reg ions", selections.length));
581 return; 590 return;
(...skipping 15 matching lines...) Expand all
597 _handleKeyDown: function(e) 606 _handleKeyDown: function(e)
598 { 607 {
599 var shortcutKey = WebInspector.KeyboardShortcut.makeKeyFromEvent(e); 608 var shortcutKey = WebInspector.KeyboardShortcut.makeKeyFromEvent(e);
600 var handler = this._shortcuts[shortcutKey]; 609 var handler = this._shortcuts[shortcutKey];
601 if (handler && handler()) 610 if (handler && handler())
602 e.consume(true); 611 e.consume(true);
603 }, 612 },
604 613
605 __proto__: WebInspector.SimpleView.prototype 614 __proto__: WebInspector.SimpleView.prototype
606 }; 615 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698