Changeset 10932 for lang/actionscript
- Timestamp:
- 05/02/08 15:16:18 (5 years ago)
- Location:
- lang/actionscript/ascss/src
- Files:
-
- 4 modified
-
SelectTest.swf (modified) (previous)
-
css/CSSRuleData.as (modified) (2 diffs)
-
css/CSSSelector.as (modified) (1 diff)
-
css/CSSStyleSelector.as (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/actionscript/ascss/src/css/CSSRuleData.as
r10847 r10932 7 7 private var mRule:CSSStyleRule; 8 8 private var mSelector:CSSSelector; 9 private var mPosition:uint; 9 10 function CSSRuleData(pos:uint, r:CSSStyleRule, sel:CSSSelector, prev:CSSRuleData = null) 10 11 { 12 mPosition = pos; 11 13 mSelector = sel; 12 14 mRule = r; … … 30 32 return mSelector; 31 33 } 34 35 public function get position():uint 36 { 37 return mPosition; 38 } 32 39 } 33 40 } -
lang/actionscript/ascss/src/css/CSSSelector.as
r10876 r10932 224 224 return m_relation; 225 225 } 226 227 public function get specificity():uint 228 { 229 // FIXME: Pseudo-elements and pseudo-classes do not have the same specificity. This function 230 // isn't quite correct. 231 var s:int = (m_tag.localName == '*' ? 0 : 1); 232 switch (m_match) { 233 case Id: 234 s += 0x10000; 235 break; 236 case Exact: 237 case Class: 238 case Set: 239 case List: 240 case Hyphen: 241 case PseudoClass: 242 case PseudoElement: 243 case Contain: 244 case Begin: 245 case End: 246 s += 0x100; 247 case None: 248 break; 249 } 250 251 if (m_tagHistory) 252 s += m_tagHistory.specificity; 253 254 // make sure it doesn't overflow 255 return s & 0xffffff; 256 } 257 226 258 } 227 259 } -
lang/actionscript/ascss/src/css/CSSStyleSelector.as
r10876 r10932 5 5 public class CSSStyleSelector 6 6 { 7 private static const FIRST:uint = 0; 8 private static const LAST:uint = 1; 7 9 private static var pseudoState:uint; 8 10 … … 70 72 } 71 73 74 private function sortMatchedRules(start:uint, end:uint):void 75 { 76 if (start >= end || ((end - start) == 1)) 77 return; // Sanity check. 78 79 if ((end - start) <= 6) { 80 } 81 } 82 72 83 public function matchRules(rules:CSSRuleSet, aRuleIndexes:Array /* first, last */):void 73 84 { … … 90 101 91 102 matchRulesForList(rules.getTagRules(mElement.localName), aRuleIndexes); 103 104 // If we didn't match any rules, we're done. 105 if (matchedRulesIsEmpty) 106 return; 107 108 // Sort the set of matched rules. 109 sortMatchedRules(0, mMatchedRules.length); 110 } 111 112 private function get matchedRulesIsEmpty():Boolean 113 { 114 return mMatchedRules.length < 1; 92 115 } 93 116 … … 119 142 } else { 120 143 // Update our first/last rule indices in the matched rules array. 121 aRuleIndexes[ 1] = mMatchedDecls.length + mMatchedRules.length;122 if (aRuleIndexes[ 0] == -1)123 aRuleIndexes[ 0] = aRuleIndexes[1];144 aRuleIndexes[LAST] = mMatchedDecls.length + mMatchedRules.length; 145 if (aRuleIndexes[FIRST] == -1) 146 aRuleIndexes[FIRST] = aRuleIndexes[LAST]; 124 147 125 148 SelectTest.puts("selector matched for <"+localName+">"); … … 224 247 mMatchedDecls = []; 225 248 } 249 250 public static function greaterThan(r1:CSSRuleData, r2:CSSRuleData):Boolean 251 { 252 var spec1:int = r1.selector.specificity; 253 var spec2:int = r2.selector.specificity; 254 return (spec1 == spec2) ? (r1.position > r2.position) : (spec1 > spec2); 255 } 256 257 public static function lesseq(r1:CSSRuleData, r2:CSSRuleData):Boolean 258 { 259 return !(r1 > r2); 260 } 226 261 } 227 262 }
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)