Diff
Modified: branches/chromium/912/LayoutTests/inspector/debugger/raw-source-code.html (98246 => 98247)
--- branches/chromium/912/LayoutTests/inspector/debugger/raw-source-code.html 2011-10-24 15:26:48 UTC (rev 98246)
+++ branches/chromium/912/LayoutTests/inspector/debugger/raw-source-code.html 2011-10-24 15:54:10 UTC (rev 98247)
@@ -112,7 +112,7 @@
InspectorTest.assertEquals(true, uiSourceCode.isContentScript);
InspectorTest.assertEquals(rawSourceCode, uiSourceCode.rawSourceCode);
checkUILocation(uiSourceCode, 0, 5, sourceMapping.rawLocationToUILocation(createRawLocation(0, 5)));
- checkRawLocation(script, 10, 0, sourceMapping.uiLocationToRawLocation(uiSourceCode, 10));
+ checkRawLocation(script, 10, 0, sourceMapping.uiLocationToRawLocation(uiSourceCode, 10, 0));
uiSourceCode.requestContent(didRequestContent);
function didRequestContent(mimeType, content)
@@ -178,8 +178,8 @@
rawSourceCode.addScript(script2);
rawSourceCode.forceUpdateSourceMapping();
checkUILocation(uiSourceCode, 1, 20, sourceMapping.rawLocationToUILocation(createRawLocation(1, 20)));
- checkRawLocation(script1, 1, 0, sourceMapping.uiLocationToRawLocation(uiSourceCode, 1));
- checkRawLocation(script2, 6, 0, sourceMapping.uiLocationToRawLocation(uiSourceCode, 6));
+ checkRawLocation(script1, 1, 0, sourceMapping.uiLocationToRawLocation(uiSourceCode, 1, 0));
+ checkRawLocation(script2, 6, 0, sourceMapping.uiLocationToRawLocation(uiSourceCode, 6, 0));
next();
}
@@ -264,7 +264,7 @@
InspectorTest.assertEquals(1, sourceMapping.uiSourceCodeList().length);
var uiSourceCode = sourceMapping.uiSourceCodeList()[0];
checkUILocation(uiSourceCode, 1, 2, sourceMapping.rawLocationToUILocation(createRawLocation(1, 2)));
- checkRawLocation(script, 2, 0, sourceMapping.uiLocationToRawLocation(uiSourceCode, 2));
+ checkRawLocation(script, 2, 0, sourceMapping.uiLocationToRawLocation(uiSourceCode, 2, 0));
uiSourceCode.requestContent(didRequestContent);
function didRequestContent(mimeType, content)
@@ -283,7 +283,7 @@
InspectorTest.assertEquals(1, sourceMapping.uiSourceCodeList().length);
var uiSourceCode = sourceMapping.uiSourceCodeList()[0];
checkUILocation(uiSourceCode, 2, 4, sourceMapping.rawLocationToUILocation(createRawLocation(1, 2)));
- checkRawLocation(script, 1, 0, sourceMapping.uiLocationToRawLocation(uiSourceCode, 2));
+ checkRawLocation(script, 1, 0, sourceMapping.uiLocationToRawLocation(uiSourceCode, 2, 0));
uiSourceCode.requestContent(didRequestFormattedContent);
}
@@ -302,7 +302,7 @@
InspectorTest.assertEquals(1, sourceMapping.uiSourceCodeList().length);
var uiSourceCode = sourceMapping.uiSourceCodeList()[0];
checkUILocation(uiSourceCode, 1, 2, sourceMapping.rawLocationToUILocation(createRawLocation(1, 2)));
- checkRawLocation(script, 2, 0, sourceMapping.uiLocationToRawLocation(uiSourceCode, 2));
+ checkRawLocation(script, 2, 0, sourceMapping.uiLocationToRawLocation(uiSourceCode, 2, 0));
uiSourceCode.requestContent(didRequestNotFormattedContent);
}
@@ -332,7 +332,7 @@
InspectorTest.assertEquals(1, sourceMapping.uiSourceCodeList().length);
var uiSourceCode = sourceMapping.uiSourceCodeList()[0];
checkUILocation(uiSourceCode, 2, 4, sourceMapping.rawLocationToUILocation(createRawLocation(1, 2)));
- checkRawLocation(script, 1, 0, sourceMapping.uiLocationToRawLocation(uiSourceCode, 2));
+ checkRawLocation(script, 1, 0, sourceMapping.uiLocationToRawLocation(uiSourceCode, 2, 0));
next();
}
},
@@ -381,8 +381,8 @@
uiSourceCodeByURL[uiSourceCodeList[i].url] = uiSourceCodeList[i];
checkUILocation(uiSourceCodeByURL["source1.js"], 2, 4, sourceMapping.rawLocationToUILocation(createRawLocation(1, 2)));
checkUILocation(uiSourceCodeByURL["source2.js"], 10, 40, sourceMapping.rawLocationToUILocation(createRawLocation(15, 20)));
- checkRawLocation(script, 1, 0, sourceMapping.uiLocationToRawLocation(uiSourceCodeByURL["source1.js"], 2));
- checkRawLocation(script, 15, 0, sourceMapping.uiLocationToRawLocation(uiSourceCodeByURL["source2.js"], 10));
+ checkRawLocation(script, 1, 0, sourceMapping.uiLocationToRawLocation(uiSourceCodeByURL["source1.js"], 2, 0));
+ checkRawLocation(script, 15, 0, sourceMapping.uiLocationToRawLocation(uiSourceCodeByURL["source2.js"], 10, 0));
uiSourceCodeList[0].requestContent(didRequestContent1);
}
Modified: branches/chromium/912/Source/WebCore/inspector/front-end/AdvancedSearchController.js (98246 => 98247)
--- branches/chromium/912/Source/WebCore/inspector/front-end/AdvancedSearchController.js 2011-10-24 15:26:48 UTC (rev 98246)
+++ branches/chromium/912/Source/WebCore/inspector/front-end/AdvancedSearchController.js 2011-10-24 15:54:10 UTC (rev 98247)
@@ -296,9 +296,10 @@
stopSearch: function() { },
/**
+ * @param {WebInspector.SearchConfig} searchConfig
* @return WebInspector.SearchResultsPane}
*/
- createSearchResultsPane: function() { }
+ createSearchResultsPane: function(searchConfig) { }
}
/**
@@ -349,9 +350,10 @@
/**
* @param {Object} file
* @param {number} lineNumber
+ * @param {number} columnNumber
* @return {Element}
*/
- createAnchor: function(file, lineNumber) { },
+ createAnchor: function(file, lineNumber, columnNumber) { },
/**
* @param {Object} file
@@ -372,11 +374,13 @@
// Expand first file with matches only.
var fileTreeElement = this._addFileTreeElement(fileName, searchMatches.length, this._searchResults.length === 1);
- var regexObject = createSearchRegex(this._searchConfig.query, !this._searchConfig.ignoreCase, this._searchConfig.isRegex);
+ var regex = createSearchRegex(this._searchConfig.query, !this._searchConfig.ignoreCase, this._searchConfig.isRegex);
for (var i = 0; i < searchMatches.length; i++) {
var lineNumber = searchMatches[i].lineNumber;
+ var lineContent = searchMatches[i].lineContent;
+ var matchRanges = this._regexMatchRanges(lineContent, regex);
- var anchor = this.createAnchor(file, lineNumber);
+ var anchor = this.createAnchor(file, lineNumber, matchRanges[0].offset);
var numberString = numberToStringWithSpacesPadding(lineNumber + 1, 4);
var lineNumberSpan = document.createElement("span");
@@ -385,7 +389,7 @@
lineNumberSpan.textContent = numberString;
anchor.appendChild(lineNumberSpan);
- var contentSpan = this._createContentSpan(searchMatches[i].lineContent, regexObject);
+ var contentSpan = this._createContentSpan(lineContent, matchRanges);
anchor.appendChild(contentSpan);
var searchMatchElement = new TreeElement("", null, false);
@@ -429,24 +433,31 @@
/**
* @param {string} lineContent
- * @param {RegExp} regexObject
+ * @param {RegExp} regex
+ * @return {Array.<Object>}
*/
- _createContentSpan: function(lineContent, regexObject)
+ _regexMatchRanges: function(lineContent, regex)
{
+ regex.lastIndex = 0;
+ var match;
+ var offset = 0;
+ var matchRanges = [];
+ while (match = regex.exec(lineContent))
+ matchRanges.push({ offset: match.index, length: match[0].length });
+
+ return matchRanges;
+ },
+
+ /**
+ * @param {string} lineContent
+ * @param {Array.<Object>} matchRanges
+ */
+ _createContentSpan: function(lineContent, matchRanges)
+ {
var contentSpan = document.createElement("span");
contentSpan.className = "search-match-content";
contentSpan.textContent = lineContent;
-
- regexObject.lastIndex = 0;
- var match = regexObject.exec(lineContent);
- var offset = 0;
- var matchRanges = [];
- while (match) {
- matchRanges.push({ offset: match.index, length: match[0].length });
- match = regexObject.exec(lineContent);
- }
highlightRangesWithStyleClass(contentSpan, matchRanges, "highlighted-match");
-
return contentSpan;
}
}
Modified: branches/chromium/912/Source/WebCore/inspector/front-end/BreakpointManager.js (98246 => 98247)
--- branches/chromium/912/Source/WebCore/inspector/front-end/BreakpointManager.js 2011-10-24 15:26:48 UTC (rev 98246)
+++ branches/chromium/912/Source/WebCore/inspector/front-end/BreakpointManager.js 2011-10-24 15:54:10 UTC (rev 98247)
@@ -127,7 +127,7 @@
return;
breakpoint._materialized = true;
- var rawLocation = sourceMapping.uiLocationToRawLocation(uiSourceCode, breakpoint.lineNumber);
+ var rawLocation = sourceMapping.uiLocationToRawLocation(uiSourceCode, breakpoint.lineNumber, 0);
this._setBreakpointInDebugger(breakpoint, rawLocation);
},
Modified: branches/chromium/912/Source/WebCore/inspector/front-end/CompilerSourceMapping.js (98246 => 98247)
--- branches/chromium/912/Source/WebCore/inspector/front-end/CompilerSourceMapping.js 2011-10-24 15:26:48 UTC (rev 98246)
+++ branches/chromium/912/Source/WebCore/inspector/front-end/CompilerSourceMapping.js 2011-10-24 15:54:10 UTC (rev 98247)
@@ -46,10 +46,9 @@
/**
* @param {string} sourceURL
* @param {number} lineNumber
- * @param {number} columnNumber
* @return {Object}
*/
- sourceLocationToCompiledLocation: function(sourceURL, lineNumber, columnNumber) { },
+ sourceLocationToCompiledLocation: function(sourceURL, lineNumber) { },
/**
* @return {Array.<string>}
Modified: branches/chromium/912/Source/WebCore/inspector/front-end/DebuggerPresentationModel.js (98246 => 98247)
--- branches/chromium/912/Source/WebCore/inspector/front-end/DebuggerPresentationModel.js 2011-10-24 15:26:48 UTC (rev 98246)
+++ branches/chromium/912/Source/WebCore/inspector/front-end/DebuggerPresentationModel.js 2011-10-24 15:54:10 UTC (rev 98247)
@@ -68,9 +68,12 @@
}
WebInspector.DebuggerPresentationModel.prototype = {
- createLinkifier: function()
+ /**
+ * @param {WebInspector.DebuggerPresentationModel.LinkifierFormatter=} formatter
+ */
+ createLinkifier: function(formatter)
{
- return new WebInspector.DebuggerPresentationModel.Linkifier(this);
+ return new WebInspector.DebuggerPresentationModel.Linkifier(this, formatter);
},
/**
@@ -362,7 +365,7 @@
continueToLine: function(uiSourceCode, lineNumber)
{
// FIXME: use RawSourceCode.uiLocationToRawLocation.
- var rawLocation = uiSourceCode.rawSourceCode.sourceMapping.uiLocationToRawLocation(uiSourceCode, lineNumber);
+ var rawLocation = uiSourceCode.rawSourceCode.sourceMapping.uiLocationToRawLocation(uiSourceCode, lineNumber, 0);
WebInspector.debuggerModel.continueToLocation(rawLocation);
},
@@ -763,12 +766,59 @@
}
/**
+ * @interface
+ */
+WebInspector.DebuggerPresentationModel.LinkifierFormatter = function()
+{
+}
+
+WebInspector.DebuggerPresentationModel.LinkifierFormatter.prototype = {
+ /**
+ * @param {WebInspector.RawSourceCode} rawSourceCode
+ * @param {Element} anchor
+ */
+ formatRawSourceCodeAnchor: function(rawSourceCode, anchor) { },
+}
+
+/**
* @constructor
+ * @implements {WebInspector.DebuggerPresentationModel.LinkifierFormatter}
+ * @param {number=} maxLength
+ */
+WebInspector.DebuggerPresentationModel.DefaultLinkifierFormatter = function(maxLength)
+{
+ this._maxLength = maxLength;
+}
+
+WebInspector.DebuggerPresentationModel.DefaultLinkifierFormatter.prototype = {
+ /**
+ * @param {WebInspector.RawSourceCode} rawSourceCode
+ * @param {Element} anchor
+ */
+ formatRawSourceCodeAnchor: function(rawSourceCode, anchor)
+ {
+ var uiLocation = rawSourceCode.sourceMapping.rawLocationToUILocation(anchor.rawLocation);
+
+ anchor.textContent = WebInspector.formatLinkText(uiLocation.uiSourceCode.url, uiLocation.lineNumber);
+
+ var text = WebInspector.formatLinkText(uiLocation.uiSourceCode.url, uiLocation.lineNumber);
+ if (this._maxLength)
+ text = text.trimMiddle(this._maxLength);
+ anchor.textContent = text;
+ }
+}
+
+WebInspector.DebuggerPresentationModel.DefaultLinkifierFormatter.prototype.__proto__ = WebInspector.DebuggerPresentationModel.LinkifierFormatter.prototype;
+
+/**
+ * @constructor
* @param {WebInspector.DebuggerPresentationModel} model
+ * @param {WebInspector.DebuggerPresentationModel.LinkifierFormatter=} formatter
*/
-WebInspector.DebuggerPresentationModel.Linkifier = function(model)
+WebInspector.DebuggerPresentationModel.Linkifier = function(model, formatter)
{
this._model = model;
+ this._formatter = formatter || new WebInspector.DebuggerPresentationModel.DefaultLinkifierFormatter();
this._anchorsForRawSourceCode = {};
}
@@ -781,17 +831,38 @@
*/
linkifyLocation: function(sourceURL, lineNumber, columnNumber, classes)
{
+ var rawSourceCode = this._model._rawSourceCodeForScriptWithURL(sourceURL);
+ if (!rawSourceCode)
+ return this.linkifyResource(sourceURL, lineNumber, classes);
+
+ return this.linkifyRawSourceCode(rawSourceCode, lineNumber, columnNumber, classes);
+ },
+
+ /**
+ * @param {string} sourceURL
+ * @param {number=} lineNumber
+ * @param {string=} classes
+ */
+ linkifyResource: function(sourceURL, lineNumber, classes)
+ {
var linkText = WebInspector.formatLinkText(sourceURL, lineNumber);
var anchor = WebInspector.linkifyURLAsNode(sourceURL, linkText, classes, false);
+ anchor.setAttribute("preferred_panel", "resources");
+ anchor.setAttribute("line_number", lineNumber);
+ return anchor;
+ },
+
+ /**
+ * @param {WebInspector.RawSourceCode} rawSourceCode
+ * @param {number=} lineNumber
+ * @param {number=} columnNumber
+ * @param {string=} classes
+ */
+ linkifyRawSourceCode: function(rawSourceCode, lineNumber, columnNumber, classes)
+ {
+ var anchor = WebInspector.linkifyURLAsNode(rawSourceCode.url, "", classes, false);
anchor.rawLocation = { lineNumber: lineNumber, columnNumber: columnNumber };
- var rawSourceCode = this._model._rawSourceCodeForScriptWithURL(sourceURL);
- if (!rawSourceCode) {
- anchor.setAttribute("preferred_panel", "resources");
- anchor.setAttribute("line_number", lineNumber);
- return anchor;
- }
-
var anchors = this._anchorsForRawSourceCode[rawSourceCode.id];
if (!anchors) {
anchors = [];
@@ -832,10 +903,11 @@
_updateAnchor: function(rawSourceCode, anchor)
{
var uiLocation = rawSourceCode.sourceMapping.rawLocationToUILocation(anchor.rawLocation);
- anchor.textContent = WebInspector.formatLinkText(uiLocation.uiSourceCode.url, uiLocation.lineNumber);
anchor.setAttribute("preferred_panel", "scripts");
anchor.uiSourceCode = uiLocation.uiSourceCode;
anchor.lineNumber = uiLocation.lineNumber;
+
+ this._formatter.formatRawSourceCodeAnchor(rawSourceCode, anchor);
}
}
Modified: branches/chromium/912/Source/WebCore/inspector/front-end/RawSourceCode.js (98246 => 98247)
--- branches/chromium/912/Source/WebCore/inspector/front-end/RawSourceCode.js 2011-10-24 15:26:48 UTC (rev 98246)
+++ branches/chromium/912/Source/WebCore/inspector/front-end/RawSourceCode.js 2011-10-24 15:54:10 UTC (rev 98247)
@@ -266,9 +266,10 @@
/**
* @param {WebInspector.UISourceCode} uiSourceCode
* @param {number} lineNumber
+ * @param {number} columnNumber
* @return {DebuggerAgent.Location}
*/
- uiLocationToRawLocation: function(uiSourceCode, lineNumber) { }
+ uiLocationToRawLocation: function(uiSourceCode, lineNumber, columnNumber) { }
}
/**
@@ -296,12 +297,13 @@
/**
* @param {WebInspector.UISourceCode} uiSourceCode
* @param {number} lineNumber
+ * @param {number} columnNumber
* @return {DebuggerAgent.Location}
*/
- uiLocationToRawLocation: function(uiSourceCode, lineNumber)
+ uiLocationToRawLocation: function(uiSourceCode, lineNumber, columnNumber)
{
console.assert(uiSourceCode === this._uiSourceCodeList[0]);
- var rawLocation = { lineNumber: lineNumber, columnNumber: 0 };
+ var rawLocation = { lineNumber: lineNumber, columnNumber: columnNumber };
rawLocation.scriptId = this._rawSourceCode._scriptForRawLocation(rawLocation.lineNumber, rawLocation.columnNumber).scriptId;
return /** @type {DebuggerAgent.Location} */ rawLocation;
},
@@ -342,12 +344,13 @@
/**
* @param {WebInspector.UISourceCode} uiSourceCode
* @param {number} lineNumber
+ * @param {number} columnNumber
* @return {DebuggerAgent.Location}
*/
- uiLocationToRawLocation: function(uiSourceCode, lineNumber)
+ uiLocationToRawLocation: function(uiSourceCode, lineNumber, columnNumber)
{
console.assert(uiSourceCode === this._uiSourceCodeList[0]);
- var rawLocation = this._mapping.formattedToOriginal({ lineNumber: lineNumber, columnNumber: 0 });
+ var rawLocation = this._mapping.formattedToOriginal({ lineNumber: lineNumber, columnNumber: columnNumber });
rawLocation.scriptId = this._rawSourceCode._scriptForRawLocation(rawLocation.lineNumber, rawLocation.columnNumber).scriptId;
return rawLocation;
},
@@ -392,11 +395,12 @@
/**
* @param {WebInspector.UISourceCode} uiSourceCode
* @param {number} lineNumber
+ * @param {number} columnNumber
* @return {DebuggerAgent.Location}
*/
- uiLocationToRawLocation: function(uiSourceCode, lineNumber)
+ uiLocationToRawLocation: function(uiSourceCode, lineNumber, columnNumber)
{
- var rawLocation = this._mapping.sourceLocationToCompiledLocation(uiSourceCode.url, lineNumber, 0);
+ var rawLocation = this._mapping.sourceLocationToCompiledLocation(uiSourceCode.url, lineNumber);
rawLocation.scriptId = this._rawSourceCode._scriptForRawLocation(rawLocation.lineNumber, rawLocation.columnNumber).scriptId;
return /** @type {DebuggerAgent.Location} */ rawLocation;
},
Modified: branches/chromium/912/Source/WebCore/inspector/front-end/ScriptsSearchScope.js (98246 => 98247)
--- branches/chromium/912/Source/WebCore/inspector/front-end/ScriptsSearchScope.js 2011-10-24 15:26:48 UTC (rev 98246)
+++ branches/chromium/912/Source/WebCore/inspector/front-end/ScriptsSearchScope.js 2011-10-24 15:54:10 UTC (rev 98247)
@@ -125,23 +125,24 @@
WebInspector.ScriptsSearchResultsPane = function(searchConfig)
{
WebInspector.FileBasedSearchResultsPane.call(this, searchConfig)
+
+ this._linkifier = WebInspector.debuggerPresentationModel.createLinkifier(new WebInspector.ScriptsSearchResultsPane.LinkifierFormatter());
}
WebInspector.ScriptsSearchResultsPane.prototype = {
/**
* @param {Object} file
* @param {number} lineNumber
+ * @param {number} columnNumber
*/
- createAnchor: function(file, lineNumber)
+ createAnchor: function(file, lineNumber, columnNumber)
{
+
var uiSourceCode = file;
-
- var anchor = WebInspector.linkifyURLAsNode(uiSourceCode.url, "");
- anchor.setAttribute("preferred_panel", "scripts");
- anchor.uiSourceCode = uiSourceCode;
- anchor.lineNumber = lineNumber;
+ var rawSourceCode = uiSourceCode.rawSourceCode;
+ var rawLocation = rawSourceCode.sourceMapping.uiLocationToRawLocation(uiSourceCode, lineNumber, columnNumber);
+ var anchor = this._linkifier.linkifyRawSourceCode(uiSourceCode.rawSourceCode, rawLocation.lineNumber, rawLocation.columnNumber);
anchor.removeChildren();
-
return anchor;
},
@@ -157,3 +158,24 @@
}
WebInspector.ScriptsSearchResultsPane.prototype.__proto__ = WebInspector.FileBasedSearchResultsPane.prototype;
+
+/**
+ * @constructor
+ * @implements {WebInspector.DebuggerPresentationModel.LinkifierFormatter}
+ */
+WebInspector.ScriptsSearchResultsPane.LinkifierFormatter = function()
+{
+}
+
+WebInspector.ScriptsSearchResultsPane.LinkifierFormatter.prototype = {
+ /**
+ * @param {WebInspector.RawSourceCode} rawSourceCode
+ * @param {Element} anchor
+ */
+ formatRawSourceCodeAnchor: function(rawSourceCode, anchor)
+ {
+ // Empty because we don't want to ever update anchor contents after creation.
+ }
+}
+
+WebInspector.ScriptsSearchResultsPane.LinkifierFormatter.prototype.__proto__ = WebInspector.DebuggerPresentationModel.LinkifierFormatter.prototype;
Modified: branches/chromium/912/Source/WebCore/inspector/front-end/inspector.html (98246 => 98247)
--- branches/chromium/912/Source/WebCore/inspector/front-end/inspector.html 2011-10-24 15:26:48 UTC (rev 98246)
+++ branches/chromium/912/Source/WebCore/inspector/front-end/inspector.html 2011-10-24 15:54:10 UTC (rev 98247)
@@ -115,7 +115,6 @@
<script type="text/_javascript_" src=""
<script type="text/_javascript_" src=""
<script type="text/_javascript_" src=""
- <script type="text/_javascript_" src=""
<script type="text/_javascript_" src=""
<script type="text/_javascript_" src=""
<script type="text/_javascript_" src=""
@@ -169,6 +168,7 @@
<script type="text/_javascript_" src=""
<script type="text/_javascript_" src=""
<script type="text/_javascript_" src=""
+ <script type="text/_javascript_" src=""
<script type="text/_javascript_" src=""
<script type="text/_javascript_" src=""
<script type="text/_javascript_" src=""