aboutsummaryrefslogtreecommitdiff
path: root/js/controllers/styles-controller.js
diff options
context:
space:
mode:
authorNivesh Rajbhandari2012-02-28 15:04:33 -0800
committerNivesh Rajbhandari2012-02-28 15:04:33 -0800
commiteb27ed35bf282262843de13b00af89a2bceac53f (patch)
tree6d78d3223062a2693d5b61499dc97fd8cb7161cd /js/controllers/styles-controller.js
parentea5962641519b9d32499c4440112e7fa821e3a79 (diff)
parent7c9291a5bab4abd849547f8878f6fb962fc88250 (diff)
downloadninja-eb27ed35bf282262843de13b00af89a2bceac53f.tar.gz
Merge branch 'refs/heads/ninja-internal' into ToolFixes
Diffstat (limited to 'js/controllers/styles-controller.js')
-rwxr-xr-xjs/controllers/styles-controller.js44
1 files changed, 22 insertions, 22 deletions
diff --git a/js/controllers/styles-controller.js b/js/controllers/styles-controller.js
index 885d710f..662816f5 100755
--- a/js/controllers/styles-controller.js
+++ b/js/controllers/styles-controller.js
@@ -317,7 +317,7 @@ var stylesController = exports.StylesController = Montage.create(Component, {
317 isInlineStyle : true, 317 isInlineStyle : true,
318 style : element.style 318 style : element.style
319 }; 319 };
320 320
321 ///// Now splice it into the matched rules 321 ///// Now splice it into the matched rules
322 ///// By inserting the inline style at the beginning, 322 ///// By inserting the inline style at the beginning,
323 ///// we keep the correct order of specificity 323 ///// we keep the correct order of specificity
@@ -572,37 +572,36 @@ var stylesController = exports.StylesController = Montage.create(Component, {
572 win = element.ownerDocument.defaultView, 572 win = element.ownerDocument.defaultView,
573 self = this; 573 self = this;
574 574
575 if(!win) {
576 return null;
577 }
578
579 if(!omitPseudos) { 575 if(!omitPseudos) {
580 pseudos.concat(['link', 'visited', 'active', 'hover', 'focus', 'first-letter', 576 pseudos.concat(['link', 'visited', 'active', 'hover', 'focus', 'first-letter',
581 'first-line', 'first-child', 'before', 'after', 'lang', 'target']); 577 'first-line', 'first-child', 'before', 'after', 'lang', 'target']);
582 } 578 }
583 579
584 pseudos.forEach(function(pseudo) { 580 try {
585 rules = rules.concat(nj.toArray(win.getMatchedCSSRules(element, pseudo)).filter(function(rule) { 581 pseudos.forEach(function(pseudo) {
586 //// useStageStyleSheet flag indicates whether to only return rules from the stylesheet, 582 rules = rules.concat(nj.toArray(win.getMatchedCSSRules(element, pseudo)).filter(function(rule) {
587 //// or only use rules for other stylesheets 583 //// useStageStyleSheet flag indicates whether to only return rules from the stylesheet,
588 584 //// or only use rules for other stylesheets
589 var sheetId = (rule.parentStyleSheet) ? rule.parentStyleSheet.ownerNode.id : null,
590 isStageStyleSheet = sheetId === this.CONST.STAGE_SHEET_ID;
591 585
592 ///// filter out (return false) depending on flag 586 var sheetId = (rule.parentStyleSheet) ? rule.parentStyleSheet.ownerNode.id : null,
593 if(useStageStyleSheet && !isStageStyleSheet) { return false; } 587 isStageStyleSheet = sheetId === this.CONST.STAGE_SHEET_ID;
594 if(!useStageStyleSheet && isStageStyleSheet) { return false; }
595 588
596 ///// Non-filter code - just assigning specificity to the rule 589 ///// filter out (return false) depending on flag
597 if(!rule[this.CONST.SPECIFICITY_KEY]) { 590 if(useStageStyleSheet && !isStageStyleSheet) { return false; }
598 rule[this.CONST.SPECIFICITY_KEY] = this.getSpecificity(rule.selectorText); 591 if(!useStageStyleSheet && isStageStyleSheet) { return false; }
599 }
600 592
601 return true; 593 ///// Non-filter code - just assigning specificity to the rule
594 if(!rule[this.CONST.SPECIFICITY_KEY]) {
595 rule[this.CONST.SPECIFICITY_KEY] = this.getSpecificity(rule.selectorText);
596 }
602 597
603 }, this)); 598 return true;
604 }, this);
605 599
600 }, this));
601 }, this);
602 } catch(ERROR) {
603 console.warn('StylesController::getMatchingRules - Un-attached element queried.');
604 }
606 ///// Function for sorting by specificity values 605 ///// Function for sorting by specificity values
607 function sorter(ruleA, ruleB) { 606 function sorter(ruleA, ruleB) {
608 var a, b, order, sheetAIndex, sheetBIndex, ruleAIndex, ruleBIndex; 607 var a, b, order, sheetAIndex, sheetBIndex, ruleAIndex, ruleBIndex;
@@ -981,6 +980,7 @@ var stylesController = exports.StylesController = Montage.create(Component, {
981 ///// Pass "true" to method to return an override object, which 980 ///// Pass "true" to method to return an override object, which
982 ///// has the rule to override, and whether the !important flag is needed 981 ///// has the rule to override, and whether the !important flag is needed
983 dominantRule = this.getDominantRuleForElement(element, property, true, isStageElement); 982 dominantRule = this.getDominantRuleForElement(element, property, true, isStageElement);
983
984 } 984 }
985 985
986 ///// Did we find a dominant rule? 986 ///// Did we find a dominant rule?