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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/sources/CSSSourceFrame.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) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 if (!token) { 89 if (!token) {
90 if (selection.startColumn > 0) 90 if (selection.startColumn > 0)
91 token = this.textEditor.tokenAtTextPosition(selection.startLine, selection.startColumn - 1); 91 token = this.textEditor.tokenAtTextPosition(selection.startLine, selection.startColumn - 1);
92 if (!token) 92 if (!token)
93 return false; 93 return false;
94 } 94 }
95 if (token.type !== "css-number") 95 if (token.type !== "css-number")
96 return false; 96 return false;
97 97
98 var cssUnitRange = new WebInspector.TextRange(selection.startLine, token .startColumn, selection.startLine, token.endColumn); 98 var cssUnitRange = new WebInspector.TextRange(selection.startLine, token .startColumn, selection.startLine, token.endColumn);
99 var cssUnitText = this.textEditor.copyRange(cssUnitRange); 99 var cssUnitText = this.textEditor.text(cssUnitRange);
100 var newUnitText = this._modifyUnit(cssUnitText, change); 100 var newUnitText = this._modifyUnit(cssUnitText, change);
101 if (!newUnitText) 101 if (!newUnitText)
102 return false; 102 return false;
103 this.textEditor.editRange(cssUnitRange, newUnitText); 103 this.textEditor.editRange(cssUnitRange, newUnitText);
104 selection.startColumn = token.startColumn; 104 selection.startColumn = token.startColumn;
105 selection.endColumn = selection.startColumn + newUnitText.length; 105 selection.endColumn = selection.startColumn + newUnitText.length;
106 this.textEditor.setSelection(selection); 106 this.textEditor.setSelection(selection);
107 return true; 107 return true;
108 }, 108 },
109 109
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 return WebInspector.TextUtils.isWordChar(char) || char === "." || char = == "-" || char === "$"; 265 return WebInspector.TextUtils.isWordChar(char) || char === "." || char = == "-" || char === "$";
266 }, 266 },
267 267
268 /** 268 /**
269 * @param {!WebInspector.TextRange} prefixRange 269 * @param {!WebInspector.TextRange} prefixRange
270 * @param {!WebInspector.TextRange} substituteRange 270 * @param {!WebInspector.TextRange} substituteRange
271 * @return {?Promise.<!WebInspector.SuggestBox.Suggestions>} 271 * @return {?Promise.<!WebInspector.SuggestBox.Suggestions>}
272 */ 272 */
273 _cssSuggestions: function(prefixRange, substituteRange) 273 _cssSuggestions: function(prefixRange, substituteRange)
274 { 274 {
275 var prefix = this._textEditor.copyRange(prefixRange); 275 var prefix = this._textEditor.text(prefixRange);
276 if (prefix.startsWith("$")) 276 if (prefix.startsWith("$"))
277 return null; 277 return null;
278 278
279 var propertyToken = this._backtrackPropertyToken(prefixRange.startLine, prefixRange.startColumn - 1); 279 var propertyToken = this._backtrackPropertyToken(prefixRange.startLine, prefixRange.startColumn - 1);
280 if (!propertyToken) 280 if (!propertyToken)
281 return null; 281 return null;
282 282
283 var line = this._textEditor.line(prefixRange.startLine); 283 var line = this._textEditor.line(prefixRange.startLine);
284 var tokenContent = line.substring(propertyToken.startColumn, propertyTok en.endColumn); 284 var tokenContent = line.substring(propertyToken.startColumn, propertyTok en.endColumn);
285 var propertyValues = WebInspector.cssMetadata().propertyValues(tokenCont ent); 285 var propertyValues = WebInspector.cssMetadata().propertyValues(tokenCont ent);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 * @param {!WebInspector.Color} color 326 * @param {!WebInspector.Color} color
327 * @param {number} lineNumber 327 * @param {number} lineNumber
328 * @param {number} startColumn 328 * @param {number} startColumn
329 * @param {number} textLength 329 * @param {number} textLength
330 */ 330 */
331 WebInspector.CSSSourceFrame.ColorPosition = function(color, lineNumber, startCol umn, textLength) 331 WebInspector.CSSSourceFrame.ColorPosition = function(color, lineNumber, startCol umn, textLength)
332 { 332 {
333 this.color = color; 333 this.color = color;
334 this.textRange = new WebInspector.TextRange(lineNumber, startColumn, lineNum ber, startColumn + textLength); 334 this.textRange = new WebInspector.TextRange(lineNumber, startColumn, lineNum ber, startColumn + textLength);
335 } 335 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698