Commit f52baea1 authored by Joel Einbinder's avatar Joel Einbinder Committed by Commit Bot

DevTools: CSSSourceFrame -> CSSPlugin

Moves UISourceCodeFrame to sources
Introduces UISourceCodeFrame.Plugin
Moves CSSSourceFrame from being a subclass to a plugin

Bug: 778043
Change-Id: Ia93a4bc2b26ae1a28505d2f82220ad5c21882f0b
Reviewed-on: https://chromium-review.googlesource.com/736672
Commit-Queue: Joel Einbinder <einbinder@chromium.org>
Reviewed-by: default avatarAndrey Lushnikov <lushnikov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#512729}
parent 739f0c55
...@@ -11,31 +11,32 @@ ...@@ -11,31 +11,32 @@
SourcesTestRunner.showScriptSource('bezier.css', onSourceFrame); SourcesTestRunner.showScriptSource('bezier.css', onSourceFrame);
function onSourceFrame(sourceFrame) { function onSourceFrame(sourceFrame) {
var cssPlugin = sourceFrame._plugins.find(plugin => plugin instanceof Sources.CSSPlugin);
TestRunner.addResult('Initial swatch positions:'); TestRunner.addResult('Initial swatch positions:');
SourcesTestRunner.dumpSwatchPositions(sourceFrame, Sources.CSSSourceFrame.SwatchBookmark); SourcesTestRunner.dumpSwatchPositions(sourceFrame, Sources.CSSPlugin.SwatchBookmark);
TestRunner.runTestSuite([ TestRunner.runTestSuite([
function testEditBezier(next) { function testEditBezier(next) {
var swatch = sourceFrame.textEditor._codeMirrorElement.querySelector('span[is=bezier-swatch]'); var swatch = sourceFrame.textEditor._codeMirrorElement.querySelector('span[is=bezier-swatch]');
swatch.shadowRoot.querySelector('.bezier-swatch-icon').click(); swatch.shadowRoot.querySelector('.bezier-swatch-icon').click();
sourceFrame._bezierEditor.setBezier(UI.Geometry.CubicBezier.parse('linear')); cssPlugin._bezierEditor.setBezier(UI.Geometry.CubicBezier.parse('linear'));
sourceFrame._bezierEditor._onchange(); cssPlugin._bezierEditor._onchange();
sourceFrame._swatchPopoverHelper.hide(true); cssPlugin._swatchPopoverHelper.hide(true);
SourcesTestRunner.dumpSwatchPositions(sourceFrame, Sources.CSSSourceFrame.SwatchBookmark); SourcesTestRunner.dumpSwatchPositions(sourceFrame, Sources.CSSPlugin.SwatchBookmark);
next(); next();
}, },
function testAddBezier(next) { function testAddBezier(next) {
var bodyLineEnd = new TextUtils.TextRange(1, 37, 1, 37); var bodyLineEnd = new TextUtils.TextRange(1, 37, 1, 37);
sourceFrame.textEditor.editRange(bodyLineEnd, ' transition: height 1s cubic-bezier(0, 0.5, 1, 1);'); sourceFrame.textEditor.editRange(bodyLineEnd, ' transition: height 1s cubic-bezier(0, 0.5, 1, 1);');
SourcesTestRunner.dumpSwatchPositions(sourceFrame, Sources.CSSSourceFrame.SwatchBookmark); SourcesTestRunner.dumpSwatchPositions(sourceFrame, Sources.CSSPlugin.SwatchBookmark);
next(); next();
}, },
function testInvalidateBezier(next) { function testInvalidateBezier(next) {
var startParenthesis = new TextUtils.TextRange(1, 67, 1, 68); var startParenthesis = new TextUtils.TextRange(1, 67, 1, 68);
sourceFrame.textEditor.editRange(startParenthesis, '['); sourceFrame.textEditor.editRange(startParenthesis, '[');
SourcesTestRunner.dumpSwatchPositions(sourceFrame, Sources.CSSSourceFrame.SwatchBookmark); SourcesTestRunner.dumpSwatchPositions(sourceFrame, Sources.CSSPlugin.SwatchBookmark);
next(); next();
} }
]); ]);
......
...@@ -11,53 +11,54 @@ ...@@ -11,53 +11,54 @@
SourcesTestRunner.showScriptSource('color.css', onSourceFrame); SourcesTestRunner.showScriptSource('color.css', onSourceFrame);
function onSourceFrame(sourceFrame) { function onSourceFrame(sourceFrame) {
var cssPlugin = sourceFrame._plugins.find(plugin => plugin instanceof Sources.CSSPlugin);
TestRunner.addResult('Initial swatch positions:'); TestRunner.addResult('Initial swatch positions:');
SourcesTestRunner.dumpSwatchPositions(sourceFrame, Sources.CSSSourceFrame.SwatchBookmark); SourcesTestRunner.dumpSwatchPositions(sourceFrame, Sources.CSSPlugin.SwatchBookmark);
TestRunner.runTestSuite([ TestRunner.runTestSuite([
function testEditSpectrum(next) { function testEditSpectrum(next) {
var swatch = sourceFrame.textEditor._codeMirrorElement.querySelector('span[is=color-swatch]'); var swatch = sourceFrame.textEditor._codeMirrorElement.querySelector('span[is=color-swatch]');
swatch.shadowRoot.querySelector('.color-swatch-inner').click(); swatch.shadowRoot.querySelector('.color-swatch-inner').click();
sourceFrame._spectrum._innerSetColor( cssPlugin._spectrum._innerSetColor(
Common.Color.parse('#008000').hsva(), '', Common.Color.Format.HEX, Common.Color.parse('#008000').hsva(), '', Common.Color.Format.HEX,
ColorPicker.Spectrum._ChangeSource.Other); ColorPicker.Spectrum._ChangeSource.Other);
sourceFrame._swatchPopoverHelper.hide(true); cssPlugin._swatchPopoverHelper.hide(true);
SourcesTestRunner.dumpSwatchPositions(sourceFrame, Sources.CSSSourceFrame.SwatchBookmark); SourcesTestRunner.dumpSwatchPositions(sourceFrame, Sources.CSSPlugin.SwatchBookmark);
next(); next();
}, },
function testAddLine(next) { function testAddLine(next) {
var start = TextUtils.TextRange.createFromLocation(0, 0); var start = TextUtils.TextRange.createFromLocation(0, 0);
sourceFrame.textEditor.editRange(start, '/* New line */\n'); sourceFrame.textEditor.editRange(start, '/* New line */\n');
SourcesTestRunner.dumpSwatchPositions(sourceFrame, Sources.CSSSourceFrame.SwatchBookmark); SourcesTestRunner.dumpSwatchPositions(sourceFrame, Sources.CSSPlugin.SwatchBookmark);
next(); next();
}, },
function testDeleteLine(next) { function testDeleteLine(next) {
var bodyLine = new TextUtils.TextRange(2, 0, 3, 0); var bodyLine = new TextUtils.TextRange(2, 0, 3, 0);
sourceFrame.textEditor.editRange(bodyLine, ''); sourceFrame.textEditor.editRange(bodyLine, '');
SourcesTestRunner.dumpSwatchPositions(sourceFrame, Sources.CSSSourceFrame.SwatchBookmark); SourcesTestRunner.dumpSwatchPositions(sourceFrame, Sources.CSSPlugin.SwatchBookmark);
next(); next();
}, },
function testAddColor(next) { function testAddColor(next) {
var emptyBodyLine = new TextUtils.TextRange(2, 0, 2, 0); var emptyBodyLine = new TextUtils.TextRange(2, 0, 2, 0);
sourceFrame.textEditor.editRange(emptyBodyLine, 'color: hsl(300, 100%, 35%);'); sourceFrame.textEditor.editRange(emptyBodyLine, 'color: hsl(300, 100%, 35%);');
SourcesTestRunner.dumpSwatchPositions(sourceFrame, Sources.CSSSourceFrame.SwatchBookmark); SourcesTestRunner.dumpSwatchPositions(sourceFrame, Sources.CSSPlugin.SwatchBookmark);
next(); next();
}, },
function testInvalidateColor(next) { function testInvalidateColor(next) {
var endParenthesis = new TextUtils.TextRange(2, 25, 2, 26); var endParenthesis = new TextUtils.TextRange(2, 25, 2, 26);
sourceFrame.textEditor.editRange(endParenthesis, ']'); sourceFrame.textEditor.editRange(endParenthesis, ']');
SourcesTestRunner.dumpSwatchPositions(sourceFrame, Sources.CSSSourceFrame.SwatchBookmark); SourcesTestRunner.dumpSwatchPositions(sourceFrame, Sources.CSSPlugin.SwatchBookmark);
next(); next();
}, },
function testBookmarksAtLineStart(next) { function testBookmarksAtLineStart(next) {
var lineStart = new TextUtils.TextRange(5, 0, 5, 0); var lineStart = new TextUtils.TextRange(5, 0, 5, 0);
sourceFrame.textEditor.editRange(lineStart, 'background color:\n#ff0;\n'); sourceFrame.textEditor.editRange(lineStart, 'background color:\n#ff0;\n');
SourcesTestRunner.dumpSwatchPositions(sourceFrame, Sources.CSSSourceFrame.SwatchBookmark); SourcesTestRunner.dumpSwatchPositions(sourceFrame, Sources.CSSPlugin.SwatchBookmark);
next(); next();
} }
]); ]);
......
...@@ -38,8 +38,8 @@ ...@@ -38,8 +38,8 @@
function didShowScriptSource(sourceFrame) { function didShowScriptSource(sourceFrame) {
TestRunner.addResult('Script source was shown.'); TestRunner.addResult('Script source was shown.');
shownSourceFrame = sourceFrame; shownSourceFrame = sourceFrame;
TestRunner.addSniffer(SourceFrame.UISourceCodeFrame.prototype, '_addMessageToSource', didAddMessage); TestRunner.addSniffer(Sources.UISourceCodeFrame.prototype, '_addMessageToSource', didAddMessage);
TestRunner.addSniffer(SourceFrame.UISourceCodeFrame.prototype, '_removeMessageFromSource', didRemoveMessage); TestRunner.addSniffer(Sources.UISourceCodeFrame.prototype, '_removeMessageFromSource', didRemoveMessage);
TestRunner.evaluateInPage('addErrorToConsole()'); TestRunner.evaluateInPage('addErrorToConsole()');
} }
......
...@@ -614,7 +614,6 @@ all_devtools_files = [ ...@@ -614,7 +614,6 @@ all_devtools_files = [
"front_end/source_frame/SourceCodeDiff.js", "front_end/source_frame/SourceCodeDiff.js",
"front_end/source_frame/SourceFrame.js", "front_end/source_frame/SourceFrame.js",
"front_end/source_frame/SourcesTextEditor.js", "front_end/source_frame/SourcesTextEditor.js",
"front_end/source_frame/UISourceCodeFrame.js",
"front_end/source_frame/xmlTree.css", "front_end/source_frame/xmlTree.css",
"front_end/source_frame/xmlView.css", "front_end/source_frame/xmlView.css",
"front_end/source_frame/XMLView.js", "front_end/source_frame/XMLView.js",
...@@ -622,7 +621,7 @@ all_devtools_files = [ ...@@ -622,7 +621,7 @@ all_devtools_files = [
"front_end/sources/AdvancedSearchView.js", "front_end/sources/AdvancedSearchView.js",
"front_end/sources/callStackSidebarPane.css", "front_end/sources/callStackSidebarPane.css",
"front_end/sources/CallStackSidebarPane.js", "front_end/sources/CallStackSidebarPane.js",
"front_end/sources/CSSSourceFrame.js", "front_end/sources/CSSPlugin.js",
"front_end/sources/dialog.css", "front_end/sources/dialog.css",
"front_end/sources/EditingLocationHistoryManager.js", "front_end/sources/EditingLocationHistoryManager.js",
"front_end/sources/eventListenerBreakpoints.css", "front_end/sources/eventListenerBreakpoints.css",
...@@ -660,6 +659,7 @@ all_devtools_files = [ ...@@ -660,6 +659,7 @@ all_devtools_files = [
"front_end/sources/SourcesSearchScope.js", "front_end/sources/SourcesSearchScope.js",
"front_end/sources/sourcesView.css", "front_end/sources/sourcesView.css",
"front_end/sources/SourcesView.js", "front_end/sources/SourcesView.js",
"front_end/sources/UISourceCodeFrame.js",
"front_end/sources/TabbedEditorContainer.js", "front_end/sources/TabbedEditorContainer.js",
"front_end/sources/threadsSidebarPane.css", "front_end/sources/threadsSidebarPane.css",
"front_end/sources/ThreadsSidebarPane.js", "front_end/sources/ThreadsSidebarPane.js",
......
...@@ -263,7 +263,7 @@ Coverage.CoverageDecorationManager = class { ...@@ -263,7 +263,7 @@ Coverage.CoverageDecorationManager = class {
Coverage.CoverageDecorationManager._decoratorType = 'coverage'; Coverage.CoverageDecorationManager._decoratorType = 'coverage';
/** /**
* @implements {SourceFrame.UISourceCodeFrame.LineDecorator} * @implements {SourceFrame.LineDecorator}
*/ */
Coverage.CoverageView.LineDecorator = class { Coverage.CoverageView.LineDecorator = class {
/** /**
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
"order": 100 "order": 100
}, },
{ {
"type": "@SourceFrame.UISourceCodeFrame.LineDecorator", "type": "@SourceFrame.LineDecorator",
"className": "Coverage.CoverageView.LineDecorator", "className": "Coverage.CoverageView.LineDecorator",
"decoratorType": "coverage" "decoratorType": "coverage"
}, },
......
...@@ -120,7 +120,7 @@ PerfUI.LineLevelProfile.Presentation = class { ...@@ -120,7 +120,7 @@ PerfUI.LineLevelProfile.Presentation = class {
}; };
/** /**
* @implements {SourceFrame.UISourceCodeFrame.LineDecorator} * @implements {SourceFrame.LineDecorator}
* @unrestricted * @unrestricted
*/ */
PerfUI.LineLevelProfile.LineDecorator = class { PerfUI.LineLevelProfile.LineDecorator = class {
......
{ {
"extensions": [ "extensions": [
{ {
"type": "@SourceFrame.UISourceCodeFrame.LineDecorator", "type": "@SourceFrame.LineDecorator",
"className": "PerfUI.LineLevelProfile.LineDecorator", "className": "PerfUI.LineLevelProfile.LineDecorator",
"decoratorType": "performance" "decoratorType": "performance"
}, },
......
...@@ -62,9 +62,6 @@ SourceFrame.SourceFrame = class extends UI.SimpleView { ...@@ -62,9 +62,6 @@ SourceFrame.SourceFrame = class extends UI.SimpleView {
/** @type {boolean} */ /** @type {boolean} */
this._muteChangeEventsForSetContent = false; this._muteChangeEventsForSetContent = false;
this._shortcuts = {};
this.element.addEventListener('keydown', this._handleKeyDown.bind(this), false);
this._sourcePosition = new UI.ToolbarText(); this._sourcePosition = new UI.ToolbarText();
/** /**
...@@ -93,14 +90,6 @@ SourceFrame.SourceFrame = class extends UI.SimpleView { ...@@ -93,14 +90,6 @@ SourceFrame.SourceFrame = class extends UI.SimpleView {
this._textEditor.setReadOnly(!editable); this._textEditor.setReadOnly(!editable);
} }
/**
* @param {number} key
* @param {function():boolean} handler
*/
addShortcut(key, handler) {
this._shortcuts[key] = handler;
}
/** /**
* @override * @override
*/ */
...@@ -563,11 +552,17 @@ SourceFrame.SourceFrame = class extends UI.SimpleView { ...@@ -563,11 +552,17 @@ SourceFrame.SourceFrame = class extends UI.SimpleView {
'%d lines, %d characters selected', textRange.endLine - textRange.startLine + 1, selectedText.length)); '%d lines, %d characters selected', textRange.endLine - textRange.startLine + 1, selectedText.length));
} }
} }
};
_handleKeyDown(e) { /**
var shortcutKey = UI.KeyboardShortcut.makeKeyFromEvent(e); * @interface
var handler = this._shortcuts[shortcutKey]; */
if (handler && handler()) SourceFrame.LineDecorator = function() {};
e.consume(true);
} SourceFrame.LineDecorator.prototype = {
/**
* @param {!Workspace.UISourceCode} uiSourceCode
* @param {!TextEditor.CodeMirrorTextEditor} textEditor
*/
decorate(uiSourceCode, textEditor) {}
}; };
...@@ -51,6 +51,11 @@ SourceFrame.SourcesTextEditor = class extends TextEditor.CodeMirrorTextEditor { ...@@ -51,6 +51,11 @@ SourceFrame.SourcesTextEditor = class extends TextEditor.CodeMirrorTextEditor {
Common.moduleSetting('textEditorAutoDetectIndent').addChangeListener(this._onUpdateEditorIndentation, this); Common.moduleSetting('textEditorAutoDetectIndent').addChangeListener(this._onUpdateEditorIndentation, this);
Common.moduleSetting('showWhitespacesInEditor').addChangeListener(this._updateWhitespace, this); Common.moduleSetting('showWhitespacesInEditor').addChangeListener(this._updateWhitespace, this);
/** @type {?UI.AutocompleteConfig} */
this._autocompleteConfig = {isWordChar: TextUtils.TextUtils.isWordChar};
Common.moduleSetting('textEditorAutocompletion').addChangeListener(this._updateAutocomplete, this);
this._updateAutocomplete();
this._onUpdateEditorIndentation(); this._onUpdateEditorIndentation();
this._setupWhitespaceHighlight(); this._setupWhitespaceHighlight();
} }
...@@ -569,6 +574,20 @@ SourceFrame.SourcesTextEditor = class extends TextEditor.CodeMirrorTextEditor { ...@@ -569,6 +574,20 @@ SourceFrame.SourcesTextEditor = class extends TextEditor.CodeMirrorTextEditor {
style.textContent = rules; style.textContent = rules;
doc.head.appendChild(style); doc.head.appendChild(style);
} }
/**
* @override
* @param {?UI.AutocompleteConfig} config
*/
configureAutocomplete(config) {
this._autocompleteConfig = config;
this._updateAutocomplete();
}
_updateAutocomplete() {
super.configureAutocomplete(
Common.moduleSetting('textEditorAutocompletion').get() ? this._autocompleteConfig : null);
}
}; };
/** @typedef {{lineNumber: number, event: !Event}} */ /** @typedef {{lineNumber: number, event: !Event}} */
......
...@@ -46,7 +46,6 @@ ...@@ -46,7 +46,6 @@
"ImageView.js", "ImageView.js",
"SourceFrame.js", "SourceFrame.js",
"ResourceSourceFrame.js", "ResourceSourceFrame.js",
"UISourceCodeFrame.js",
"JSONView.js", "JSONView.js",
"XMLView.js", "XMLView.js",
"PreviewFactory.js", "PreviewFactory.js",
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
Sources.EditingLocationHistoryManager = class { Sources.EditingLocationHistoryManager = class {
/** /**
* @param {!Sources.SourcesView} sourcesView * @param {!Sources.SourcesView} sourcesView
* @param {function():?SourceFrame.UISourceCodeFrame} currentSourceFrameCallback * @param {function():?Sources.UISourceCodeFrame} currentSourceFrameCallback
*/ */
constructor(sourcesView, currentSourceFrameCallback) { constructor(sourcesView, currentSourceFrameCallback) {
this._sourcesView = sourcesView; this._sourcesView = sourcesView;
...@@ -43,7 +43,7 @@ Sources.EditingLocationHistoryManager = class { ...@@ -43,7 +43,7 @@ Sources.EditingLocationHistoryManager = class {
} }
/** /**
* @param {!SourceFrame.UISourceCodeFrame} sourceFrame * @param {!Sources.UISourceCodeFrame} sourceFrame
*/ */
trackSourceFrameCursorJumps(sourceFrame) { trackSourceFrameCursorJumps(sourceFrame) {
sourceFrame.textEditor.addEventListener( sourceFrame.textEditor.addEventListener(
...@@ -129,7 +129,7 @@ Sources.EditingLocationHistoryEntry = class { ...@@ -129,7 +129,7 @@ Sources.EditingLocationHistoryEntry = class {
/** /**
* @param {!Sources.SourcesView} sourcesView * @param {!Sources.SourcesView} sourcesView
* @param {!Sources.EditingLocationHistoryManager} editingLocationManager * @param {!Sources.EditingLocationHistoryManager} editingLocationManager
* @param {!SourceFrame.UISourceCodeFrame} sourceFrame * @param {!Sources.UISourceCodeFrame} sourceFrame
* @param {!TextUtils.TextRange} selection * @param {!TextUtils.TextRange} selection
*/ */
constructor(sourcesView, editingLocationManager, sourceFrame, selection) { constructor(sourcesView, editingLocationManager, sourceFrame, selection) {
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
/** /**
* @unrestricted * @unrestricted
*/ */
Sources.JavaScriptSourceFrame = class extends SourceFrame.UISourceCodeFrame { Sources.JavaScriptSourceFrame = class extends Sources.UISourceCodeFrame {
/** /**
* @param {!Workspace.UISourceCode} uiSourceCode * @param {!Workspace.UISourceCode} uiSourceCode
*/ */
......
...@@ -824,7 +824,7 @@ Sources.SourcesPanel = class extends UI.Panel { ...@@ -824,7 +824,7 @@ Sources.SourcesPanel = class extends UI.Panel {
* @param {!Object} target * @param {!Object} target
*/ */
_appendUISourceCodeFrameItems(event, contextMenu, target) { _appendUISourceCodeFrameItems(event, contextMenu, target) {
if (!(target instanceof SourceFrame.UISourceCodeFrame)) if (!(target instanceof Sources.UISourceCodeFrame))
return; return;
contextMenu.debugSection().appendAction('debugger.evaluate-selection'); contextMenu.debugSection().appendAction('debugger.evaluate-selection');
} }
...@@ -1240,7 +1240,7 @@ Sources.SourcesPanel.DebuggingActionDelegate = class { ...@@ -1240,7 +1240,7 @@ Sources.SourcesPanel.DebuggingActionDelegate = class {
panel._toggleBreakpointsActive(); panel._toggleBreakpointsActive();
return true; return true;
case 'debugger.evaluate-selection': case 'debugger.evaluate-selection':
var frame = UI.context.flavor(SourceFrame.UISourceCodeFrame); var frame = UI.context.flavor(Sources.UISourceCodeFrame);
if (frame) { if (frame) {
var text = frame.textEditor.text(frame.textEditor.selection()); var text = frame.textEditor.text(frame.textEditor.selection());
var executionContext = UI.context.flavor(SDK.ExecutionContext); var executionContext = UI.context.flavor(SDK.ExecutionContext);
......
...@@ -237,13 +237,13 @@ Sources.SourcesView = class extends UI.VBox { ...@@ -237,13 +237,13 @@ Sources.SourcesView = class extends UI.VBox {
} }
/** /**
* @return {?SourceFrame.UISourceCodeFrame} * @return {?Sources.UISourceCodeFrame}
*/ */
currentSourceFrame() { currentSourceFrame() {
var view = this.visibleView(); var view = this.visibleView();
if (!(view instanceof SourceFrame.UISourceCodeFrame)) if (!(view instanceof Sources.UISourceCodeFrame))
return null; return null;
return /** @type {!SourceFrame.UISourceCodeFrame} */ (view); return /** @type {!Sources.UISourceCodeFrame} */ (view);
} }
/** /**
...@@ -357,14 +357,12 @@ Sources.SourcesView = class extends UI.VBox { ...@@ -357,14 +357,12 @@ Sources.SourcesView = class extends UI.VBox {
if (contentType.hasScripts()) if (contentType.hasScripts())
sourceFrame = new Sources.JavaScriptSourceFrame(uiSourceCode); sourceFrame = new Sources.JavaScriptSourceFrame(uiSourceCode);
else if (contentType.isStyleSheet())
sourceFrame = new Sources.CSSSourceFrame(uiSourceCode);
else if (contentType === Common.resourceTypes.Image) else if (contentType === Common.resourceTypes.Image)
sourceView = new SourceFrame.ImageView(uiSourceCode.mimeType(), uiSourceCode); sourceView = new SourceFrame.ImageView(uiSourceCode.mimeType(), uiSourceCode);
else if (contentType === Common.resourceTypes.Font) else if (contentType === Common.resourceTypes.Font)
sourceView = new SourceFrame.FontView(uiSourceCode.mimeType(), uiSourceCode); sourceView = new SourceFrame.FontView(uiSourceCode.mimeType(), uiSourceCode);
else else
sourceFrame = new SourceFrame.UISourceCodeFrame(uiSourceCode); sourceFrame = new Sources.UISourceCodeFrame(uiSourceCode);
if (sourceFrame) { if (sourceFrame) {
sourceFrame.setHighlighterType(uiSourceCode.mimeType()); sourceFrame.setHighlighterType(uiSourceCode.mimeType());
...@@ -385,15 +383,13 @@ Sources.SourcesView = class extends UI.VBox { ...@@ -385,15 +383,13 @@ Sources.SourcesView = class extends UI.VBox {
} }
/** /**
* @param {!SourceFrame.UISourceCodeFrame} sourceFrame * @param {!Sources.UISourceCodeFrame} sourceFrame
* @param {!Workspace.UISourceCode} uiSourceCode * @param {!Workspace.UISourceCode} uiSourceCode
* @return {boolean} * @return {boolean}
*/ */
_sourceFrameMatchesUISourceCode(sourceFrame, uiSourceCode) { _sourceFrameMatchesUISourceCode(sourceFrame, uiSourceCode) {
if (uiSourceCode.contentType().hasScripts()) if (uiSourceCode.contentType().hasScripts())
return sourceFrame instanceof Sources.JavaScriptSourceFrame; return sourceFrame instanceof Sources.JavaScriptSourceFrame;
if (uiSourceCode.contentType().isStyleSheet())
return sourceFrame instanceof Sources.CSSSourceFrame;
return !(sourceFrame instanceof Sources.JavaScriptSourceFrame); return !(sourceFrame instanceof Sources.JavaScriptSourceFrame);
} }
...@@ -402,9 +398,9 @@ Sources.SourcesView = class extends UI.VBox { ...@@ -402,9 +398,9 @@ Sources.SourcesView = class extends UI.VBox {
*/ */
_recreateSourceFrameIfNeeded(uiSourceCode) { _recreateSourceFrameIfNeeded(uiSourceCode) {
var oldSourceView = this._sourceViewByUISourceCode.get(uiSourceCode); var oldSourceView = this._sourceViewByUISourceCode.get(uiSourceCode);
if (!oldSourceView || !(oldSourceView instanceof SourceFrame.UISourceCodeFrame)) if (!oldSourceView || !(oldSourceView instanceof Sources.UISourceCodeFrame))
return; return;
var oldSourceFrame = /** @type {!SourceFrame.UISourceCodeFrame} */ (oldSourceView); var oldSourceFrame = /** @type {!Sources.UISourceCodeFrame} */ (oldSourceView);
if (this._sourceFrameMatchesUISourceCode(oldSourceFrame, uiSourceCode)) { if (this._sourceFrameMatchesUISourceCode(oldSourceFrame, uiSourceCode)) {
oldSourceFrame.setHighlighterType(uiSourceCode.mimeType()); oldSourceFrame.setHighlighterType(uiSourceCode.mimeType());
} else { } else {
...@@ -429,8 +425,8 @@ Sources.SourcesView = class extends UI.VBox { ...@@ -429,8 +425,8 @@ Sources.SourcesView = class extends UI.VBox {
var sourceView = this._sourceViewByUISourceCode.get(uiSourceCode); var sourceView = this._sourceViewByUISourceCode.get(uiSourceCode);
this._sourceViewByUISourceCode.remove(uiSourceCode); this._sourceViewByUISourceCode.remove(uiSourceCode);
uiSourceCode.removeEventListener(Workspace.UISourceCode.Events.TitleChanged, this._uiSourceCodeTitleChanged, this); uiSourceCode.removeEventListener(Workspace.UISourceCode.Events.TitleChanged, this._uiSourceCodeTitleChanged, this);
if (sourceView && sourceView instanceof SourceFrame.UISourceCodeFrame) if (sourceView && sourceView instanceof Sources.UISourceCodeFrame)
/** @type {!SourceFrame.UISourceCodeFrame} */ (sourceView).dispose(); /** @type {!Sources.UISourceCodeFrame} */ (sourceView).dispose();
} }
_onBindingChanged() { _onBindingChanged() {
...@@ -456,7 +452,7 @@ Sources.SourcesView = class extends UI.VBox { ...@@ -456,7 +452,7 @@ Sources.SourcesView = class extends UI.VBox {
var binding = Persistence.persistence.binding(uiLocation.uiSourceCode); var binding = Persistence.persistence.binding(uiLocation.uiSourceCode);
var uiSourceCode = binding ? binding.fileSystem : uiLocation.uiSourceCode; var uiSourceCode = binding ? binding.fileSystem : uiLocation.uiSourceCode;
var sourceView = this._getOrCreateSourceView(uiSourceCode); var sourceView = this._getOrCreateSourceView(uiSourceCode);
if (!(sourceView instanceof SourceFrame.UISourceCodeFrame)) if (!(sourceView instanceof Sources.UISourceCodeFrame))
return; return;
Persistence.persistence.subscribeForBindingEvent(uiLocation.uiSourceCode, this._bindingChangeBound); Persistence.persistence.subscribeForBindingEvent(uiLocation.uiSourceCode, this._bindingChangeBound);
var sourceFrame = /** @type {!Sources.JavaScriptSourceFrame} */ (sourceView); var sourceFrame = /** @type {!Sources.JavaScriptSourceFrame} */ (sourceView);
...@@ -492,11 +488,11 @@ Sources.SourcesView = class extends UI.VBox { ...@@ -492,11 +488,11 @@ Sources.SourcesView = class extends UI.VBox {
*/ */
_editorSelected(event) { _editorSelected(event) {
var previousSourceFrame = var previousSourceFrame =
event.data.previousView instanceof SourceFrame.UISourceCodeFrame ? event.data.previousView : null; event.data.previousView instanceof Sources.UISourceCodeFrame ? event.data.previousView : null;
if (previousSourceFrame) if (previousSourceFrame)
previousSourceFrame.setSearchableView(null); previousSourceFrame.setSearchableView(null);
var currentSourceFrame = var currentSourceFrame =
event.data.currentView instanceof SourceFrame.UISourceCodeFrame ? event.data.currentView : null; event.data.currentView instanceof Sources.UISourceCodeFrame ? event.data.currentView : null;
if (currentSourceFrame) if (currentSourceFrame)
currentSourceFrame.setSearchableView(this._searchableView); currentSourceFrame.setSearchableView(this._searchableView);
...@@ -657,9 +653,9 @@ Sources.SourcesView = class extends UI.VBox { ...@@ -657,9 +653,9 @@ Sources.SourcesView = class extends UI.VBox {
* @param {?UI.Widget} sourceFrame * @param {?UI.Widget} sourceFrame
*/ */
_saveSourceFrame(sourceFrame) { _saveSourceFrame(sourceFrame) {
if (!(sourceFrame instanceof SourceFrame.UISourceCodeFrame)) if (!(sourceFrame instanceof Sources.UISourceCodeFrame))
return; return;
var uiSourceCodeFrame = /** @type {!SourceFrame.UISourceCodeFrame} */ (sourceFrame); var uiSourceCodeFrame = /** @type {!Sources.UISourceCodeFrame} */ (sourceFrame);
uiSourceCodeFrame.commitEditing(); uiSourceCodeFrame.commitEditing();
} }
......
...@@ -186,7 +186,7 @@ Sources.WatchExpressionsSidebarPane = class extends UI.ThrottledWidget { ...@@ -186,7 +186,7 @@ Sources.WatchExpressionsSidebarPane = class extends UI.ThrottledWidget {
* @return {boolean} * @return {boolean}
*/ */
handleAction(context, actionId) { handleAction(context, actionId) {
var frame = UI.context.flavor(SourceFrame.UISourceCodeFrame); var frame = UI.context.flavor(Sources.UISourceCodeFrame);
if (!frame) if (!frame)
return false; return false;
var text = frame.textEditor.text(frame.textEditor.selection()); var text = frame.textEditor.text(frame.textEditor.selection());
...@@ -204,7 +204,7 @@ Sources.WatchExpressionsSidebarPane = class extends UI.ThrottledWidget { ...@@ -204,7 +204,7 @@ Sources.WatchExpressionsSidebarPane = class extends UI.ThrottledWidget {
* @param {!Object} target * @param {!Object} target
*/ */
appendApplicableItems(event, contextMenu, target) { appendApplicableItems(event, contextMenu, target) {
var frame = UI.context.flavor(SourceFrame.UISourceCodeFrame); var frame = UI.context.flavor(Sources.UISourceCodeFrame);
if (!frame || frame.textEditor.selection().isEmpty()) if (!frame || frame.textEditor.selection().isEmpty())
return; return;
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
"Workspace.UILocation", "Workspace.UILocation",
"SDK.RemoteObject", "SDK.RemoteObject",
"SDK.NetworkRequest", "SDK.NetworkRequest",
"SourceFrame.UISourceCodeFrame" "Sources.UISourceCodeFrame"
], ],
"className": "Sources.SourcesPanel" "className": "Sources.SourcesPanel"
}, },
...@@ -185,7 +185,7 @@ ...@@ -185,7 +185,7 @@
"className": "Sources.WatchExpressionsSidebarPane", "className": "Sources.WatchExpressionsSidebarPane",
"title": "Add selected text to watches", "title": "Add selected text to watches",
"contextTypes": [ "contextTypes": [
"SourceFrame.UISourceCodeFrame" "Sources.UISourceCodeFrame"
], ],
"bindings": [ "bindings": [
{ {
...@@ -206,7 +206,7 @@ ...@@ -206,7 +206,7 @@
"className": "Sources.SourcesPanel.DebuggingActionDelegate", "className": "Sources.SourcesPanel.DebuggingActionDelegate",
"title": "Evaluate in console", "title": "Evaluate in console",
"contextTypes": [ "contextTypes": [
"SourceFrame.UISourceCodeFrame" "Sources.UISourceCodeFrame"
], ],
"bindings": [ "bindings": [
{ {
...@@ -648,8 +648,9 @@ ...@@ -648,8 +648,9 @@
"GoToLineQuickOpen.js", "GoToLineQuickOpen.js",
"SourceMapNamesResolver.js", "SourceMapNamesResolver.js",
"JavaScriptBreakpointsSidebarPane.js", "JavaScriptBreakpointsSidebarPane.js",
"UISourceCodeFrame.js",
"JavaScriptSourceFrame.js", "JavaScriptSourceFrame.js",
"CSSSourceFrame.js", "CSSPlugin.js",
"NavigatorView.js", "NavigatorView.js",
"RevisionHistoryView.js", "RevisionHistoryView.js",
"ScopeChainSidebarPane.js", "ScopeChainSidebarPane.js",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment