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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/inline_editor/CSSShadowModel.js

Issue 2769843003: DevTools: split text_utils out of common module (Closed)
Patch Set: rebaseline Created 3 years, 9 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 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 /** 4 /**
5 * @unrestricted 5 * @unrestricted
6 */ 6 */
7 InlineEditor.CSSShadowModel = class { 7 InlineEditor.CSSShadowModel = class {
8 /** 8 /**
9 * @param {boolean} isBoxShadow 9 * @param {boolean} isBoxShadow
10 */ 10 */
(...skipping 25 matching lines...) Expand all
36 } 36 }
37 37
38 /** 38 /**
39 * @param {string} text 39 * @param {string} text
40 * @param {boolean} isBoxShadow 40 * @param {boolean} isBoxShadow
41 * @return {!Array<!InlineEditor.CSSShadowModel>} 41 * @return {!Array<!InlineEditor.CSSShadowModel>}
42 */ 42 */
43 static _parseShadow(text, isBoxShadow) { 43 static _parseShadow(text, isBoxShadow) {
44 var shadowTexts = []; 44 var shadowTexts = [];
45 // Split by commas that aren't inside of color values to get the individual shadow values. 45 // Split by commas that aren't inside of color values to get the individual shadow values.
46 var splits = Common.TextUtils.splitStringByRegexes(text, [Common.Color.Regex , /,/g]); 46 var splits = TextUtils.TextUtils.splitStringByRegexes(text, [Common.Color.Re gex, /,/g]);
47 var currentIndex = 0; 47 var currentIndex = 0;
48 for (var i = 0; i < splits.length; i++) { 48 for (var i = 0; i < splits.length; i++) {
49 if (splits[i].regexIndex === 1) { 49 if (splits[i].regexIndex === 1) {
50 var comma = splits[i]; 50 var comma = splits[i];
51 shadowTexts.push(text.substring(currentIndex, comma.position)); 51 shadowTexts.push(text.substring(currentIndex, comma.position));
52 currentIndex = comma.position + 1; 52 currentIndex = comma.position + 1;
53 } 53 }
54 } 54 }
55 shadowTexts.push(text.substring(currentIndex, text.length)); 55 shadowTexts.push(text.substring(currentIndex, text.length));
56 56
57 var shadows = []; 57 var shadows = [];
58 for (var i = 0; i < shadowTexts.length; i++) { 58 for (var i = 0; i < shadowTexts.length; i++) {
59 var shadow = new InlineEditor.CSSShadowModel(isBoxShadow); 59 var shadow = new InlineEditor.CSSShadowModel(isBoxShadow);
60 shadow._format = []; 60 shadow._format = [];
61 var nextPartAllowed = true; 61 var nextPartAllowed = true;
62 var regexes = [/inset/gi, Common.Color.Regex, InlineEditor.CSSLength.Regex ]; 62 var regexes = [/inset/gi, Common.Color.Regex, InlineEditor.CSSLength.Regex ];
63 var results = Common.TextUtils.splitStringByRegexes(shadowTexts[i], regexe s); 63 var results = TextUtils.TextUtils.splitStringByRegexes(shadowTexts[i], reg exes);
64 for (var j = 0; j < results.length; j++) { 64 for (var j = 0; j < results.length; j++) {
65 var result = results[j]; 65 var result = results[j];
66 if (result.regexIndex === -1) { 66 if (result.regexIndex === -1) {
67 // Don't allow anything other than inset, color, length values, and wh itespace. 67 // Don't allow anything other than inset, color, length values, and wh itespace.
68 if (/\S/.test(result.value)) 68 if (/\S/.test(result.value))
69 return []; 69 return [];
70 // All parts must be separated by whitespace. 70 // All parts must be separated by whitespace.
71 nextPartAllowed = true; 71 nextPartAllowed = true;
72 } else { 72 } else {
73 if (!nextPartAllowed) 73 if (!nextPartAllowed)
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 } 314 }
315 }; 315 };
316 316
317 /** @type {!RegExp} */ 317 /** @type {!RegExp} */
318 InlineEditor.CSSLength.Regex = (function() { 318 InlineEditor.CSSLength.Regex = (function() {
319 var number = '([+-]?(?:[0-9]*[.])?[0-9]+(?:[eE][+-]?[0-9]+)?)'; 319 var number = '([+-]?(?:[0-9]*[.])?[0-9]+(?:[eE][+-]?[0-9]+)?)';
320 var unit = '(ch|cm|em|ex|in|mm|pc|pt|px|rem|vh|vmax|vmin|vw)'; 320 var unit = '(ch|cm|em|ex|in|mm|pc|pt|px|rem|vh|vmax|vmin|vw)';
321 var zero = '[+-]?(?:0*[.])?0+(?:[eE][+-]?[0-9]+)?'; 321 var zero = '[+-]?(?:0*[.])?0+(?:[eE][+-]?[0-9]+)?';
322 return new RegExp(number + unit + '|' + zero, 'gi'); 322 return new RegExp(number + unit + '|' + zero, 'gi');
323 })(); 323 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698