Commit 7d2f813d authored by vsevik@chromium.org's avatar vsevik@chromium.org

DevTools: Merge highlightPosition and revealLine methods on SourceFrame.

This patch keeps highlightPosition method on SourceFrame for backwards compatibility with corresponding virtual methods on View.

R=lushnikov@chromium.org, lushnikov, pfeldman

Review URL: https://codereview.chromium.org/204323003

git-svn-id: svn://svn.chromium.org/blink/trunk@169551 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 966dfcf1
......@@ -7,6 +7,7 @@ InspectorTest.createTestEditor = function(clientHeight, textEditorDelegate)
var textEditor = new WebInspector.CodeMirrorTextEditor("", textEditorDelegate || new WebInspector.TextEditorDelegate());
if (clientHeight)
textEditor.element.style.height = clientHeight + "px";
textEditor.element.style.flex = "none";
textEditor.show(WebInspector.inspectorView.element);
return textEditor;
};
......
......@@ -27,7 +27,7 @@ function test()
function testLineReveal(lineNumber)
{
textEditor.revealLine(lineNumber);
textEditor.revealPosition(lineNumber);
var firstLine = textEditor.firstVisibleLine();
var lastLine = textEditor.lastVisibleLine();
var lineCentered = Math.abs(2 * lineNumber - firstLine - lastLine) <= 1;
......
......@@ -16,7 +16,7 @@ var test = function()
{
var executionLineSet = false;
var executionLineRevealed = false;
InspectorTest.addSniffer(WebInspector.SourceFrame.prototype, "revealLine", didRevealLine);
InspectorTest.addSniffer(WebInspector.SourceFrame.prototype, "revealPosition", didRevealLine);
InspectorTest.addSniffer(WebInspector.JavaScriptSourceFrame.prototype, "setExecutionLine", didSetExecutionLine);
InspectorTest.runTestFunctionAndWaitUntilPaused(didPaused);
......
......@@ -339,7 +339,7 @@ WebInspector.CodeMirrorTextEditor.prototype = {
function innerHighlightRegex()
{
if (range) {
this.revealLine(range.startLine);
this._revealLine(range.startLine);
if (range.endColumn > WebInspector.CodeMirrorTextEditor.maxHighlightLength)
this.setSelection(range);
else
......@@ -685,7 +685,7 @@ WebInspector.CodeMirrorTextEditor.prototype = {
/**
* @param {number} lineNumber
*/
revealLine: function(lineNumber)
_revealLine: function(lineNumber)
{
this._innerRevealLine(lineNumber, this._codeMirror.getScrollInfo());
},
......@@ -794,8 +794,9 @@ WebInspector.CodeMirrorTextEditor.prototype = {
/**
* @param {number} lineNumber
* @param {number=} columnNumber
* @param {boolean=} shouldHighlight
*/
highlightPosition: function(lineNumber, columnNumber)
revealPosition: function(lineNumber, columnNumber, shouldHighlight)
{
lineNumber = Number.constrain(lineNumber, 0, this._codeMirror.lineCount() - 1);
if (typeof columnNumber !== "number")
......@@ -806,9 +807,11 @@ WebInspector.CodeMirrorTextEditor.prototype = {
this._highlightedLine = this._codeMirror.getLineHandle(lineNumber);
if (!this._highlightedLine)
return;
this.revealLine(lineNumber);
this._codeMirror.addLineClass(this._highlightedLine, null, "cm-highlight");
this._clearHighlightTimeout = setTimeout(this.clearPositionHighlight.bind(this), 2000);
this._revealLine(lineNumber);
if (shouldHighlight) {
this._codeMirror.addLineClass(this._highlightedLine, null, "cm-highlight");
this._clearHighlightTimeout = setTimeout(this.clearPositionHighlight.bind(this), 2000);
}
this.setSelection(WebInspector.TextRange.createFromLocation(lineNumber, columnNumber));
},
......
......@@ -125,8 +125,7 @@ WebInspector.SourceFrame.prototype = {
{
WebInspector.View.prototype.willHide.call(this);
this._clearPositionHighlight();
this._clearLineToReveal();
this._clearPositionToReveal();
},
/**
......@@ -213,56 +212,38 @@ WebInspector.SourceFrame.prototype = {
*/
highlightPosition: function(line, column)
{
this._clearLineToReveal();
this._clearLineToScrollTo();
this._clearSelectionToSet();
this._positionToHighlight = { line: line, column: column };
this._innerHighlightPositionIfNeeded();
},
_innerHighlightPositionIfNeeded: function()
{
if (!this._positionToHighlight)
return;
if (!this.loaded || !this._isEditorShowing())
return;
this._textEditor.highlightPosition(this._positionToHighlight.line, this._positionToHighlight.column);
delete this._positionToHighlight;
},
_clearPositionHighlight: function()
{
this._textEditor.clearPositionHighlight();
delete this._positionToHighlight;
this.revealPosition(line, column, true);
},
/**
* @param {number} line
* @param {number=} column
* @param {boolean=} shouldHighlight
*/
revealLine: function(line)
revealPosition: function(line, column, shouldHighlight)
{
this._clearPositionHighlight();
this._clearLineToScrollTo();
this._clearSelectionToSet();
this._lineToReveal = line;
this._innerRevealLineIfNeeded();
this._positionToReveal = { line: line, column: column, shouldHighlight: shouldHighlight };
this._innerRevealPositionIfNeeded();
},
_innerRevealLineIfNeeded: function()
_innerRevealPositionIfNeeded: function()
{
if (typeof this._lineToReveal === "number") {
if (this.loaded && this._isEditorShowing()) {
this._textEditor.revealLine(this._lineToReveal);
delete this._lineToReveal;
}
}
if (!this._positionToReveal)
return;
if (!this.loaded || !this._isEditorShowing())
return;
this._textEditor.revealPosition(this._positionToReveal.line, this._positionToReveal.column, this._positionToReveal.shouldHighlight);
delete this._positionToReveal;
},
_clearLineToReveal: function()
_clearPositionToReveal: function()
{
delete this._lineToReveal;
this._textEditor.clearPositionHighlight();
delete this._positionToReveal;
},
/**
......@@ -270,8 +251,7 @@ WebInspector.SourceFrame.prototype = {
*/
scrollToLine: function(line)
{
this._clearPositionHighlight();
this._clearLineToReveal();
this._clearPositionToReveal();
this._lineToScrollTo = line;
this._innerScrollToLineIfNeeded();
},
......@@ -323,8 +303,7 @@ WebInspector.SourceFrame.prototype = {
_wasShownOrLoaded: function()
{
this._innerHighlightPositionIfNeeded();
this._innerRevealLineIfNeeded();
this._innerRevealPositionIfNeeded();
this._innerSetSelectionIfNeeded();
this._innerScrollToLineIfNeeded();
},
......
......@@ -716,7 +716,7 @@ WebInspector.SourcesPanel.prototype = {
this._skipExecutionLineRevealing = true;
var sourceFrame = this._showFile(uiSourceCode);
sourceFrame.revealLine(uiLocation.lineNumber);
sourceFrame.revealPosition(uiLocation.lineNumber);
this._historyManager.pushNewState();
if (sourceFrame.canEditSource())
......
......@@ -112,11 +112,6 @@ WebInspector.TextEditor.prototype = {
*/
removeHighlight: function(highlightDescriptor) { },
/**
* @param {number} lineNumber
*/
revealLine: function(lineNumber) { },
/**
* @param {number} lineNumber
* @param {boolean} disabled
......@@ -157,8 +152,9 @@ WebInspector.TextEditor.prototype = {
/**
* @param {number} lineNumber
* @param {number=} columnNumber
* @param {boolean=} shouldHighlight
*/
highlightPosition: function(lineNumber, columnNumber) { },
revealPosition: function(lineNumber, columnNumber, shouldHighlight) { },
clearPositionHighlight: function() { },
......
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