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

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

Issue 1641893002: DevTools: [SASS] introduce workspace/cssModel adapter for SASS processor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove settimeout from test Created 4 years, 10 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 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 {!WebInspector.CSSParser} parser 8 * @param {!WebInspector.CSSParser} parser
9 * @param {string} url 9 * @param {string} url
10 * @param {string} text 10 * @param {string} text
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 this.type = type; 587 this.type = type;
588 this.oldRule = oldRule; 588 this.oldRule = oldRule;
589 this.newRule = newRule; 589 this.newRule = newRule;
590 this.oldPropertyIndex = oldPropertyIndex; 590 this.oldPropertyIndex = oldPropertyIndex;
591 this.newPropertyIndex = newPropertyIndex; 591 this.newPropertyIndex = newPropertyIndex;
592 } 592 }
593 593
594 /** 594 /**
595 * @constructor 595 * @constructor
596 * @param {string} url 596 * @param {string} url
597 * @param {!WebInspector.SASSSupport.AST} oldAST
598 * @param {!WebInspector.SASSSupport.AST} newAST
597 * @param {!Map<!WebInspector.SASSSupport.TextNode, !WebInspector.SASSSupport.Te xtNode>} mapping 599 * @param {!Map<!WebInspector.SASSSupport.TextNode, !WebInspector.SASSSupport.Te xtNode>} mapping
598 * @param {!Array<!WebInspector.SASSSupport.PropertyChange>} changes 600 * @param {!Array<!WebInspector.SASSSupport.PropertyChange>} changes
599 */ 601 */
600 WebInspector.SASSSupport.ASTDiff = function(url, mapping, changes) 602 WebInspector.SASSSupport.ASTDiff = function(url, oldAST, newAST, mapping, change s)
601 { 603 {
602 this.url = url; 604 this.url = url;
603 this.mapping = mapping; 605 this.mapping = mapping;
604 this.changes = changes; 606 this.changes = changes;
607 this.oldAST = oldAST;
608 this.newAST = newAST;
605 } 609 }
606 610
607 /** 611 /**
608 * @param {!WebInspector.SASSSupport.AST} oldAST 612 * @param {!WebInspector.SASSSupport.AST} oldAST
609 * @param {!WebInspector.SASSSupport.AST} newAST 613 * @param {!WebInspector.SASSSupport.AST} newAST
610 * @return {!WebInspector.SASSSupport.ASTDiff} 614 * @return {!WebInspector.SASSSupport.ASTDiff}
611 */ 615 */
612 WebInspector.SASSSupport.diffModels = function(oldAST, newAST) 616 WebInspector.SASSSupport.diffModels = function(oldAST, newAST)
613 { 617 {
614 console.assert(oldAST.rules.length === newAST.rules.length, "Not implemented for rule diff."); 618 console.assert(oldAST.rules.length === newAST.rules.length, "Not implemented for rule diff.");
615 console.assert(oldAST.document.url === newAST.document.url, "Diff makes sens e for models with the same url."); 619 console.assert(oldAST.document.url === newAST.document.url, "Diff makes sens e for models with the same url.");
616 var T = WebInspector.SASSSupport.PropertyChangeType; 620 var T = WebInspector.SASSSupport.PropertyChangeType;
617 var changes = []; 621 var changes = [];
618 /** @type {!Map<!WebInspector.SASSSupport.TextNode, !WebInspector.SASSSuppor t.TextNode>} */ 622 /** @type {!Map<!WebInspector.SASSSupport.TextNode, !WebInspector.SASSSuppor t.TextNode>} */
619 var mapping = new Map(); 623 var mapping = new Map();
620 for (var i = 0; i < oldAST.rules.length; ++i) { 624 for (var i = 0; i < oldAST.rules.length; ++i) {
621 var oldRule = oldAST.rules[i]; 625 var oldRule = oldAST.rules[i];
622 var newRule = newAST.rules[i]; 626 var newRule = newAST.rules[i];
623 computeRuleDiff(mapping, oldRule, newRule); 627 computeRuleDiff(mapping, oldRule, newRule);
624 } 628 }
625 return new WebInspector.SASSSupport.ASTDiff(oldAST.document.url, mapping, ch anges); 629 return new WebInspector.SASSSupport.ASTDiff(oldAST.document.url, oldAST, new AST, mapping, changes);
626 630
627 /** 631 /**
628 * @param {!WebInspector.SASSSupport.PropertyChangeType} type 632 * @param {!WebInspector.SASSSupport.PropertyChangeType} type
629 * @param {!WebInspector.SASSSupport.Rule} oldRule 633 * @param {!WebInspector.SASSSupport.Rule} oldRule
630 * @param {!WebInspector.SASSSupport.Rule} newRule 634 * @param {!WebInspector.SASSSupport.Rule} newRule
631 * @param {number} oldPropertyIndex 635 * @param {number} oldPropertyIndex
632 * @param {number} newPropertyIndex 636 * @param {number} newPropertyIndex
633 */ 637 */
634 function addChange(type, oldRule, newRule, oldPropertyIndex, newPropertyInde x) 638 function addChange(type, oldRule, newRule, oldPropertyIndex, newPropertyInde x)
635 { 639 {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 mapping.set(oldProperty.name, newProperty.name); 686 mapping.set(oldProperty.name, newProperty.name);
683 mapping.set(oldProperty.value, newProperty.value); 687 mapping.set(oldProperty.value, newProperty.value);
684 if (oldProperty.name.text.trim() !== newProperty.name.text.trim()) 688 if (oldProperty.name.text.trim() !== newProperty.name.text.trim())
685 addChange(T.NameChanged, oldRule, newRule, oldPropertyIndex, newProp ertyIndex); 689 addChange(T.NameChanged, oldRule, newRule, oldPropertyIndex, newProp ertyIndex);
686 if (oldProperty.value.text.trim() !== newProperty.value.text.trim()) 690 if (oldProperty.value.text.trim() !== newProperty.value.text.trim())
687 addChange(T.ValueChanged, oldRule, newRule, oldPropertyIndex, newPro pertyIndex); 691 addChange(T.ValueChanged, oldRule, newRule, oldPropertyIndex, newPro pertyIndex);
688 if (oldProperty.disabled !== newProperty.disabled) 692 if (oldProperty.disabled !== newProperty.disabled)
689 addChange(T.PropertyToggled, oldRule, newRule, oldPropertyIndex, new PropertyIndex); 693 addChange(T.PropertyToggled, oldRule, newRule, oldPropertyIndex, new PropertyIndex);
690 } 694 }
691 } 695 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698