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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/sources/CSSSourceFrame.js

Issue 2626143004: DevTools: move from Common module - Geometry and CSSShadowModel (Closed)
Patch Set: minimize test diff Created 3 years, 11 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 } 103 }
104 104
105 /** 105 /**
106 * @param {number} startLine 106 * @param {number} startLine
107 * @param {number} endLine 107 * @param {number} endLine
108 */ 108 */
109 _updateSwatches(startLine, endLine) { 109 _updateSwatches(startLine, endLine) {
110 var swatches = []; 110 var swatches = [];
111 var swatchPositions = []; 111 var swatchPositions = [];
112 112
113 var regexes = [ 113 var regexes =
114 SDK.CSSMetadata.VariableRegex, SDK.CSSMetadata.URLRegex, Common.Geometry.C ubicBezier.Regex, Common.Color.Regex 114 [SDK.CSSMetadata.VariableRegex, SDK.CSSMetadata.URLRegex, UI.Geometry.Cu bicBezier.Regex, Common.Color.Regex];
115 ];
116 var handlers = new Map(); 115 var handlers = new Map();
117 handlers.set(Common.Color.Regex, this._createColorSwatch.bind(this)); 116 handlers.set(Common.Color.Regex, this._createColorSwatch.bind(this));
118 handlers.set(Common.Geometry.CubicBezier.Regex, this._createBezierSwatch.bin d(this)); 117 handlers.set(UI.Geometry.CubicBezier.Regex, this._createBezierSwatch.bind(th is));
119 118
120 for (var lineNumber = startLine; lineNumber <= endLine; lineNumber++) { 119 for (var lineNumber = startLine; lineNumber <= endLine; lineNumber++) {
121 var line = this.textEditor.line(lineNumber).substring(0, Sources.CSSSource Frame.maxSwatchProcessingLength); 120 var line = this.textEditor.line(lineNumber).substring(0, Sources.CSSSource Frame.maxSwatchProcessingLength);
122 var results = Common.TextUtils.splitStringByRegexes(line, regexes); 121 var results = Common.TextUtils.splitStringByRegexes(line, regexes);
123 for (var i = 0; i < results.length; i++) { 122 for (var i = 0; i < results.length; i++) {
124 var result = results[i]; 123 var result = results[i];
125 if (result.regexIndex === -1 || !handlers.has(regexes[result.regexIndex] )) 124 if (result.regexIndex === -1 || !handlers.has(regexes[result.regexIndex] ))
126 continue; 125 continue;
127 var delimiters = /[\s:;,(){}]/; 126 var delimiters = /[\s:;,(){}]/;
128 var positionBefore = result.position - 1; 127 var positionBefore = result.position - 1;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 swatch.iconElement().addEventListener('click', this._swatchIconClicked.bind( this, swatch), false); 169 swatch.iconElement().addEventListener('click', this._swatchIconClicked.bind( this, swatch), false);
171 swatch.hideText(true); 170 swatch.hideText(true);
172 return swatch; 171 return swatch;
173 } 172 }
174 173
175 /** 174 /**
176 * @param {string} text 175 * @param {string} text
177 * @return {?InlineEditor.BezierSwatch} 176 * @return {?InlineEditor.BezierSwatch}
178 */ 177 */
179 _createBezierSwatch(text) { 178 _createBezierSwatch(text) {
180 if (!Common.Geometry.CubicBezier.parse(text)) 179 if (!UI.Geometry.CubicBezier.parse(text))
181 return null; 180 return null;
182 var swatch = InlineEditor.BezierSwatch.create(); 181 var swatch = InlineEditor.BezierSwatch.create();
183 swatch.setBezierText(text); 182 swatch.setBezierText(text);
184 swatch.iconElement().title = Common.UIString('Open cubic bezier editor.'); 183 swatch.iconElement().title = Common.UIString('Open cubic bezier editor.');
185 swatch.iconElement().addEventListener('click', this._swatchIconClicked.bind( this, swatch), false); 184 swatch.iconElement().addEventListener('click', this._swatchIconClicked.bind( this, swatch), false);
186 swatch.hideText(true); 185 swatch.hideText(true);
187 return swatch; 186 return swatch;
188 } 187 }
189 188
190 /** 189 /**
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 } 239 }
241 240
242 /** 241 /**
243 * @param {!InlineEditor.BezierSwatch} swatch 242 * @param {!InlineEditor.BezierSwatch} swatch
244 */ 243 */
245 _showBezierEditor(swatch) { 244 _showBezierEditor(swatch) {
246 if (!this._bezierEditor) { 245 if (!this._bezierEditor) {
247 this._bezierEditor = new InlineEditor.BezierEditor(); 246 this._bezierEditor = new InlineEditor.BezierEditor();
248 this._bezierEditor.addEventListener(InlineEditor.BezierEditor.Events.Bezie rChanged, this._bezierChanged, this); 247 this._bezierEditor.addEventListener(InlineEditor.BezierEditor.Events.Bezie rChanged, this._bezierChanged, this);
249 } 248 }
250 var cubicBezier = Common.Geometry.CubicBezier.parse(swatch.bezierText()); 249 var cubicBezier = UI.Geometry.CubicBezier.parse(swatch.bezierText());
251 if (!cubicBezier) { 250 if (!cubicBezier) {
252 cubicBezier = 251 cubicBezier =
253 /** @type {!Common.Geometry.CubicBezier} */ (Common.Geometry.CubicBezi er.parse('linear')); 252 /** @type {!UI.Geometry.CubicBezier} */ (UI.Geometry.CubicBezier.parse ('linear'));
254 } 253 }
255 this._bezierEditor.setBezier(cubicBezier); 254 this._bezierEditor.setBezier(cubicBezier);
256 this._swatchPopoverHelper.show(this._bezierEditor, swatch.iconElement(), thi s._swatchPopoverHidden.bind(this)); 255 this._swatchPopoverHelper.show(this._bezierEditor, swatch.iconElement(), thi s._swatchPopoverHidden.bind(this));
257 } 256 }
258 257
259 /** 258 /**
260 * @param {!Common.Event} event 259 * @param {!Common.Event} event
261 */ 260 */
262 _bezierChanged(event) { 261 _bezierChanged(event) {
263 var bezierString = /** @type {string} */ (event.data); 262 var bezierString = /** @type {string} */ (event.data);
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 tokenPosition = token.startColumn - 1; 359 tokenPosition = token.startColumn - 1;
361 } 360 }
362 return null; 361 return null;
363 } 362 }
364 }; 363 };
365 364
366 /** @type {number} */ 365 /** @type {number} */
367 Sources.CSSSourceFrame.maxSwatchProcessingLength = 300; 366 Sources.CSSSourceFrame.maxSwatchProcessingLength = 300;
368 /** @type {symbol} */ 367 /** @type {symbol} */
369 Sources.CSSSourceFrame.SwatchBookmark = Symbol('swatch'); 368 Sources.CSSSourceFrame.SwatchBookmark = Symbol('swatch');
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698