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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/sass/SASSSupport.js

Issue 1941283002: DevTools: [SASS] start parsing CSS with SCSS parser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@1-scss
Patch Set: rebaseline Created 4 years, 7 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
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/sass/ASTService.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 WebInspector.SASSSupport = {} 5 WebInspector.SASSSupport = {}
6 6
7 /** 7 /**
8 * @param {string} url 8 * @param {string} url
9 * @param {string} text
10 * @return {!Promise<!WebInspector.SASSSupport.AST>}
11 */
12 WebInspector.SASSSupport.parseCSS = function(url, text)
13 {
14 var cssParser = new WebInspector.CSSParser();
15 return cssParser.parsePromise(text)
16 .then(onParsed);
17
18 /**
19 * @param {!Array.<!WebInspector.CSSParser.Rule>} parsedCSS
20 * @return {!WebInspector.SASSSupport.AST}
21 */
22 function onParsed(parsedCSS)
23 {
24 var document = new WebInspector.SASSSupport.ASTDocument(url, new WebInsp ector.Text(text));
25 var rules = [];
26 for (var i = 0; i < parsedCSS.length; ++i) {
27 var rule = parsedCSS[i];
28 if (!rule.properties)
29 continue;
30 var properties = [];
31 for (var j = 0; j < rule.properties.length; ++j) {
32 var cssProperty = rule.properties[j];
33 var name = new WebInspector.SASSSupport.TextNode(document, cssPr operty.name, WebInspector.TextRange.fromObject(cssProperty.nameRange));
34 var value = new WebInspector.SASSSupport.TextNode(document, cssP roperty.value, WebInspector.TextRange.fromObject(cssProperty.valueRange));
35 var property = new WebInspector.SASSSupport.Property(document, n ame, value, WebInspector.TextRange.fromObject(cssProperty.range), !!cssProperty. disabled);
36 properties.push(property);
37 }
38 rules.push(new WebInspector.SASSSupport.Rule(document, rule.selector Text, WebInspector.TextRange.fromObject(rule.styleRange), properties));
39 }
40 return new WebInspector.SASSSupport.AST(document, rules);
41 }
42 }
43
44 /**
45 * @param {string} url
46 * @param {string} content 9 * @param {string} content
47 * @return {!Promise<!WebInspector.SASSSupport.AST>} 10 * @return {!Promise<!WebInspector.SASSSupport.AST>}
48 */ 11 */
49 WebInspector.SASSSupport.parseSCSS = function(url, content) 12 WebInspector.SASSSupport.parseSCSS = function(url, content)
50 { 13 {
51 var text = new WebInspector.Text(content); 14 var text = new WebInspector.Text(content);
52 var document = new WebInspector.SASSSupport.ASTDocument(url, text); 15 var document = new WebInspector.SASSSupport.ASTDocument(url, text);
53 16
54 return WebInspector.formatterWorkerPool.runTask("parseSCSS", {content: conte nt}).then(onParsed); 17 return WebInspector.formatterWorkerPool.runTask("parseSCSS", {content: conte nt}).then(onParsed);
55 18
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 mapping.set(oldProperty.name, newProperty.name); 667 mapping.set(oldProperty.name, newProperty.name);
705 mapping.set(oldProperty.value, newProperty.value); 668 mapping.set(oldProperty.value, newProperty.value);
706 if (oldProperty.name.text.trim() !== newProperty.name.text.trim()) 669 if (oldProperty.name.text.trim() !== newProperty.name.text.trim())
707 addChange(T.NameChanged, oldRule, newRule, oldPropertyIndex, newProp ertyIndex); 670 addChange(T.NameChanged, oldRule, newRule, oldPropertyIndex, newProp ertyIndex);
708 if (oldProperty.value.text.trim() !== newProperty.value.text.trim()) 671 if (oldProperty.value.text.trim() !== newProperty.value.text.trim())
709 addChange(T.ValueChanged, oldRule, newRule, oldPropertyIndex, newPro pertyIndex); 672 addChange(T.ValueChanged, oldRule, newRule, oldPropertyIndex, newPro pertyIndex);
710 if (oldProperty.disabled !== newProperty.disabled) 673 if (oldProperty.disabled !== newProperty.disabled)
711 addChange(T.PropertyToggled, oldRule, newRule, oldPropertyIndex, new PropertyIndex); 674 addChange(T.PropertyToggled, oldRule, newRule, oldPropertyIndex, new PropertyIndex);
712 } 675 }
713 } 676 }
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/sass/ASTService.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698