home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2012 April / ME_04_2012.iso / Video-Tutorial / iPhoto / media / player.swf / scripts / mx / styles / StyleManagerImpl.as < prev    next >
Encoding:
Text File  |  2011-11-11  |  30.9 KB  |  990 lines

  1. package mx.styles
  2. {
  3.    import flash.display.DisplayObject;
  4.    import flash.events.Event;
  5.    import flash.events.EventDispatcher;
  6.    import flash.events.IEventDispatcher;
  7.    import flash.events.TimerEvent;
  8.    import flash.system.ApplicationDomain;
  9.    import flash.system.SecurityDomain;
  10.    import flash.utils.Timer;
  11.    import mx.core.FlexVersion;
  12.    import mx.core.IFlexModuleFactory;
  13.    import mx.core.mx_internal;
  14.    import mx.events.FlexChangeEvent;
  15.    import mx.events.ModuleEvent;
  16.    import mx.events.Request;
  17.    import mx.events.StyleEvent;
  18.    import mx.managers.ISystemManager;
  19.    import mx.managers.SystemManagerGlobals;
  20.    import mx.modules.IModuleInfo;
  21.    import mx.modules.ModuleManager;
  22.    import mx.resources.IResourceManager;
  23.    import mx.resources.ResourceManager;
  24.    import mx.utils.MediaQueryParser;
  25.    
  26.    use namespace mx_internal;
  27.    
  28.    public class StyleManagerImpl extends EventDispatcher implements IStyleManager2
  29.    {
  30.       private static var instance:IStyleManager2;
  31.       
  32.       mx_internal static const VERSION:String = "4.5.0.20967";
  33.       
  34.       private static var _qualifiedTypeSelectors:Boolean = true;
  35.       
  36.       private var mqp:MediaQueryParser;
  37.       
  38.       private var inheritingTextFormatStyles:Object;
  39.       
  40.       private var sizeInvalidatingStyles:Object;
  41.       
  42.       private var parentSizeInvalidatingStyles:Object;
  43.       
  44.       private var parentDisplayListInvalidatingStyles:Object;
  45.       
  46.       private var colorNames:Object;
  47.       
  48.       private var _hasAdvancedSelectors:Boolean;
  49.       
  50.       private var _pseudoCSSStates:Object;
  51.       
  52.       private var _selectors:Object;
  53.       
  54.       private var styleModules:Object;
  55.       
  56.       private var _subjects:Object;
  57.       
  58.       private var resourceManager:IResourceManager;
  59.       
  60.       private var mergedInheritingStylesCache:Object;
  61.       
  62.       private var moduleFactory:IFlexModuleFactory;
  63.       
  64.       private var _parent:IStyleManager2;
  65.       
  66.       private var _stylesRoot:Object;
  67.       
  68.       private var _inheritingStyles:Object;
  69.       
  70.       private var _typeHierarchyCache:Object;
  71.       
  72.       private var _typeSelectorCache:Object;
  73.       
  74.       public function StyleManagerImpl(param1:IFlexModuleFactory)
  75.       {
  76.          var _loc2_:Request = null;
  77.          var _loc3_:IFlexModuleFactory = null;
  78.          this.inheritingTextFormatStyles = {
  79.             "align":true,
  80.             "bold":true,
  81.             "color":true,
  82.             "font":true,
  83.             "indent":true,
  84.             "italic":true,
  85.             "size":true
  86.          };
  87.          this.sizeInvalidatingStyles = {
  88.             "alignmentBaseline":true,
  89.             "baselineShift":true,
  90.             "blockProgression":true,
  91.             "borderStyle":true,
  92.             "borderThickness":true,
  93.             "breakOpportunity":true,
  94.             "cffHinting":true,
  95.             "columnCount":true,
  96.             "columnGap":true,
  97.             "columnWidth":true,
  98.             "digitCase":true,
  99.             "digitWidth":true,
  100.             "direction":true,
  101.             "dominantBaseline":true,
  102.             "firstBaselineOffset":true,
  103.             "fontAntiAliasType":true,
  104.             "fontFamily":true,
  105.             "fontGridFitType":true,
  106.             "fontLookup":true,
  107.             "fontSharpness":true,
  108.             "fontSize":true,
  109.             "fontStyle":true,
  110.             "fontThickness":true,
  111.             "fontWeight":true,
  112.             "headerHeight":true,
  113.             "horizontalAlign":true,
  114.             "horizontalGap":true,
  115.             "justificationRule":true,
  116.             "justificationStyle":true,
  117.             "kerning":true,
  118.             "leading":true,
  119.             "leadingModel":true,
  120.             "letterSpacing":true,
  121.             "ligatureLevel":true,
  122.             "lineBreak":true,
  123.             "lineHeight":true,
  124.             "lineThrough":true,
  125.             "listAutoPadding":true,
  126.             "listStylePosition":true,
  127.             "listStyleType":true,
  128.             "locale":true,
  129.             "marginBottom":true,
  130.             "marginLeft":true,
  131.             "marginRight":true,
  132.             "marginTop":true,
  133.             "paddingBottom":true,
  134.             "paddingLeft":true,
  135.             "paddingRight":true,
  136.             "paddingTop":true,
  137.             "paragraphEndIndent":true,
  138.             "paragraphStartIndent":true,
  139.             "paragraphSpaceAfter":true,
  140.             "paragraphSpaceBefore":true,
  141.             "renderingMode":true,
  142.             "strokeWidth":true,
  143.             "tabHeight":true,
  144.             "tabWidth":true,
  145.             "tabStops":true,
  146.             "textAlign":true,
  147.             "textAlignLast":true,
  148.             "textDecoration":true,
  149.             "textIndent":true,
  150.             "textJustify":true,
  151.             "textRotation":true,
  152.             "tracking":true,
  153.             "trackingLeft":true,
  154.             "trackingRight":true,
  155.             "typographicCase":true,
  156.             "verticalAlign":true,
  157.             "verticalGap":true,
  158.             "wordSpacing":true,
  159.             "whitespaceCollapse":true
  160.          };
  161.          this.parentSizeInvalidatingStyles = {
  162.             "baseline":true,
  163.             "bottom":true,
  164.             "horizontalCenter":true,
  165.             "left":true,
  166.             "right":true,
  167.             "top":true,
  168.             "verticalCenter":true
  169.          };
  170.          this.parentDisplayListInvalidatingStyles = {
  171.             "baseline":true,
  172.             "bottom":true,
  173.             "horizontalCenter":true,
  174.             "left":true,
  175.             "right":true,
  176.             "top":true,
  177.             "verticalCenter":true
  178.          };
  179.          this.colorNames = {
  180.             "transparent":"transparent",
  181.             "black":0,
  182.             "blue":255,
  183.             "green":32768,
  184.             "gray":8421504,
  185.             "silver":12632256,
  186.             "lime":65280,
  187.             "olive":8421376,
  188.             "white":16777215,
  189.             "yellow":16776960,
  190.             "maroon":8388608,
  191.             "navy":128,
  192.             "red":16711680,
  193.             "purple":8388736,
  194.             "teal":32896,
  195.             "fuchsia":16711935,
  196.             "aqua":65535,
  197.             "magenta":16711935,
  198.             "cyan":65535,
  199.             "halogreen":8453965,
  200.             "haloblue":40447,
  201.             "haloorange":16758272,
  202.             "halosilver":11455193
  203.          };
  204.          this._selectors = {};
  205.          this.styleModules = {};
  206.          this._subjects = {};
  207.          this.resourceManager = ResourceManager.getInstance();
  208.          this._inheritingStyles = {};
  209.          super();
  210.          this.moduleFactory = param1;
  211.          this.moduleFactory.registerImplementation("mx.styles::IStyleManager2",this);
  212.          if(param1 is DisplayObject)
  213.          {
  214.             _loc2_ = new Request(Request.GET_PARENT_FLEX_MODULE_FACTORY_REQUEST);
  215.             DisplayObject(param1).dispatchEvent(_loc2_);
  216.             _loc3_ = _loc2_.value as IFlexModuleFactory;
  217.             if(_loc3_)
  218.             {
  219.                this._parent = IStyleManager2(_loc3_.getImplementation("mx.styles::IStyleManager2"));
  220.                if(this._parent is IEventDispatcher)
  221.                {
  222.                   IEventDispatcher(this._parent).addEventListener(FlexChangeEvent.STYLE_MANAGER_CHANGE,this.styleManagerChangeHandler,false,0,true);
  223.                }
  224.             }
  225.          }
  226.       }
  227.       
  228.       public static function getInstance() : IStyleManager2
  229.       {
  230.          if(!instance)
  231.          {
  232.             instance = IStyleManager2(IFlexModuleFactory(SystemManagerGlobals.topLevelSystemManagers[0]).getImplementation("mx.styles::IStyleManager2"));
  233.             if(!instance)
  234.             {
  235.                instance = new StyleManagerImpl(SystemManagerGlobals.topLevelSystemManagers[0]);
  236.             }
  237.          }
  238.          return instance;
  239.       }
  240.       
  241.       public function get parent() : IStyleManager2
  242.       {
  243.          return this._parent;
  244.       }
  245.       
  246.       public function get qualifiedTypeSelectors() : Boolean
  247.       {
  248.          if(FlexVersion.compatibilityVersion < FlexVersion.VERSION_4_0)
  249.          {
  250.             return false;
  251.          }
  252.          if(_qualifiedTypeSelectors)
  253.          {
  254.             return _qualifiedTypeSelectors;
  255.          }
  256.          if(this.parent)
  257.          {
  258.             return this.parent.qualifiedTypeSelectors;
  259.          }
  260.          return false;
  261.       }
  262.       
  263.       public function set qualifiedTypeSelectors(param1:Boolean) : void
  264.       {
  265.          _qualifiedTypeSelectors = param1;
  266.       }
  267.       
  268.       public function get stylesRoot() : Object
  269.       {
  270.          return this._stylesRoot;
  271.       }
  272.       
  273.       public function set stylesRoot(param1:Object) : void
  274.       {
  275.          this._stylesRoot = param1;
  276.       }
  277.       
  278.       public function get inheritingStyles() : Object
  279.       {
  280.          var _loc2_:Object = null;
  281.          var _loc3_:Object = null;
  282.          if(this.mergedInheritingStylesCache)
  283.          {
  284.             return this.mergedInheritingStylesCache;
  285.          }
  286.          var _loc1_:Object = this._inheritingStyles;
  287.          if(this.parent)
  288.          {
  289.             _loc2_ = this.parent.inheritingStyles;
  290.             for(_loc3_ in _loc2_)
  291.             {
  292.                if(_loc1_[_loc3_] === undefined)
  293.                {
  294.                   _loc1_[_loc3_] = _loc2_[_loc3_];
  295.                }
  296.             }
  297.          }
  298.          this.mergedInheritingStylesCache = _loc1_;
  299.          return _loc1_;
  300.       }
  301.       
  302.       public function set inheritingStyles(param1:Object) : void
  303.       {
  304.          this._inheritingStyles = param1;
  305.          this.mergedInheritingStylesCache = null;
  306.          if(hasEventListener(FlexChangeEvent.STYLE_MANAGER_CHANGE))
  307.          {
  308.             this.dispatchInheritingStylesChangeEvent();
  309.          }
  310.       }
  311.       
  312.       public function get typeHierarchyCache() : Object
  313.       {
  314.          if(this._typeHierarchyCache == null)
  315.          {
  316.             this._typeHierarchyCache = {};
  317.          }
  318.          return this._typeHierarchyCache;
  319.       }
  320.       
  321.       public function set typeHierarchyCache(param1:Object) : void
  322.       {
  323.          this._typeHierarchyCache = param1;
  324.       }
  325.       
  326.       public function get typeSelectorCache() : Object
  327.       {
  328.          if(this._typeSelectorCache == null)
  329.          {
  330.             this._typeSelectorCache = {};
  331.          }
  332.          return this._typeSelectorCache;
  333.       }
  334.       
  335.       public function set typeSelectorCache(param1:Object) : void
  336.       {
  337.          this._typeSelectorCache = param1;
  338.       }
  339.       
  340.       public function initProtoChainRoots() : void
  341.       {
  342.          var _loc1_:CSSStyleDeclaration = null;
  343.          if(!this.stylesRoot)
  344.          {
  345.             _loc1_ = this.getMergedStyleDeclaration("global");
  346.             if(_loc1_ != null)
  347.             {
  348.                this.stylesRoot = _loc1_.mx_internal::addStyleToProtoChain({},null);
  349.             }
  350.          }
  351.       }
  352.       
  353.       public function get selectors() : Array
  354.       {
  355.          var _loc2_:String = null;
  356.          var _loc3_:Array = null;
  357.          var _loc1_:Array = [];
  358.          for(_loc2_ in this._selectors)
  359.          {
  360.             _loc1_.push(_loc2_);
  361.          }
  362.          if(this.parent)
  363.          {
  364.             _loc3_ = this.parent.selectors;
  365.             for(_loc2_ in _loc3_)
  366.             {
  367.                _loc1_.push(_loc2_);
  368.             }
  369.          }
  370.          return _loc1_;
  371.       }
  372.       
  373.       public function hasAdvancedSelectors() : Boolean
  374.       {
  375.          if(this._hasAdvancedSelectors)
  376.          {
  377.             return true;
  378.          }
  379.          if(this.parent)
  380.          {
  381.             return this.parent.hasAdvancedSelectors();
  382.          }
  383.          return false;
  384.       }
  385.       
  386.       public function hasPseudoCondition(param1:String) : Boolean
  387.       {
  388.          if(this._pseudoCSSStates != null && this._pseudoCSSStates[param1] != null)
  389.          {
  390.             return true;
  391.          }
  392.          if(this.parent)
  393.          {
  394.             return this.parent.hasPseudoCondition(param1);
  395.          }
  396.          return false;
  397.       }
  398.       
  399.       public function getStyleDeclarations(param1:String) : Array
  400.       {
  401.          var _loc3_:int = 0;
  402.          var _loc4_:Array = null;
  403.          if(FlexVersion.compatibilityVersion < FlexVersion.VERSION_4_0)
  404.          {
  405.             if(param1.charAt(0) != ".")
  406.             {
  407.                _loc3_ = int(param1.lastIndexOf("."));
  408.                if(_loc3_ != -1)
  409.                {
  410.                   param1 = param1.substr(_loc3_ + 1);
  411.                }
  412.             }
  413.          }
  414.          var _loc2_:Array = null;
  415.          if(this.parent)
  416.          {
  417.             _loc2_ = this.parent.getStyleDeclarations(param1);
  418.          }
  419.          if(!_loc2_)
  420.          {
  421.             _loc2_ = this._subjects[param1] as Array;
  422.          }
  423.          else
  424.          {
  425.             _loc4_ = this._subjects[param1] as Array;
  426.             if(_loc4_)
  427.             {
  428.                _loc2_ = _loc2_.concat(_loc4_);
  429.             }
  430.          }
  431.          return _loc2_;
  432.       }
  433.       
  434.       private function isUnique(param1:*, param2:int, param3:Array) : Boolean
  435.       {
  436.          return param3.indexOf(param1) >= 0;
  437.       }
  438.       
  439.       public function getStyleDeclaration(param1:String) : CSSStyleDeclaration
  440.       {
  441.          var _loc2_:int = 0;
  442.          if(FlexVersion.compatibilityVersion < FlexVersion.VERSION_4_0)
  443.          {
  444.             if(param1.charAt(0) != ".")
  445.             {
  446.                _loc2_ = int(param1.lastIndexOf("."));
  447.                if(_loc2_ != -1)
  448.                {
  449.                   param1 = param1.substr(_loc2_ + 1);
  450.                }
  451.             }
  452.          }
  453.          return this._selectors[param1];
  454.       }
  455.       
  456.       public function getMergedStyleDeclaration(param1:String) : CSSStyleDeclaration
  457.       {
  458.          var _loc2_:CSSStyleDeclaration = this.getStyleDeclaration(param1);
  459.          var _loc3_:CSSStyleDeclaration = null;
  460.          if(this.parent)
  461.          {
  462.             _loc3_ = this.parent.getMergedStyleDeclaration(param1);
  463.          }
  464.          if(Boolean(_loc2_) || Boolean(_loc3_))
  465.          {
  466.             _loc2_ = new CSSMergedStyleDeclaration(_loc2_,_loc3_,!!_loc2_ ? _loc2_.mx_internal::selectorString : _loc3_.mx_internal::selectorString,this,false);
  467.          }
  468.          return _loc2_;
  469.       }
  470.       
  471.       public function setStyleDeclaration(param1:String, param2:CSSStyleDeclaration, param3:Boolean) : void
  472.       {
  473.          var _loc6_:int = 0;
  474.          var _loc7_:String = null;
  475.          var _loc8_:Array = null;
  476.          if(FlexVersion.compatibilityVersion < FlexVersion.VERSION_4_0)
  477.          {
  478.             if(param1.charAt(0) != ".")
  479.             {
  480.                _loc6_ = int(param1.lastIndexOf("."));
  481.                if(_loc6_ != -1)
  482.                {
  483.                   param1 = param1.substr(_loc6_ + 1);
  484.                }
  485.             }
  486.          }
  487.          ++param2.mx_internal::selectorRefCount;
  488.          this._selectors[param1] = param2;
  489.          var _loc4_:String = param2.subject;
  490.          if(param1)
  491.          {
  492.             if(!param2.subject)
  493.             {
  494.                param2.mx_internal::selectorString = param1;
  495.                _loc4_ = param2.subject;
  496.             }
  497.             else if(param1 != param2.mx_internal::selectorString)
  498.             {
  499.                _loc7_ = param1.charAt(0);
  500.                if(_loc7_ == "." || _loc7_ == ":" || _loc7_ == "#")
  501.                {
  502.                   _loc4_ = "*";
  503.                }
  504.                else
  505.                {
  506.                   _loc4_ = param1;
  507.                }
  508.                param2.mx_internal::selectorString = param1;
  509.             }
  510.          }
  511.          if(_loc4_ != null)
  512.          {
  513.             _loc8_ = this._subjects[_loc4_] as Array;
  514.             if(_loc8_ == null)
  515.             {
  516.                _loc8_ = [param2];
  517.                this._subjects[_loc4_] = _loc8_;
  518.             }
  519.             else
  520.             {
  521.                _loc8_.push(param2);
  522.             }
  523.          }
  524.          var _loc5_:String = param2.mx_internal::getPseudoCondition();
  525.          if(_loc5_ != null)
  526.          {
  527.             if(this._pseudoCSSStates == null)
  528.             {
  529.                this._pseudoCSSStates = {};
  530.             }
  531.             this._pseudoCSSStates[_loc5_] = true;
  532.          }
  533.          if(param2.mx_internal::isAdvanced())
  534.          {
  535.             this._hasAdvancedSelectors = true;
  536.          }
  537.          if(this._typeSelectorCache)
  538.          {
  539.             this._typeSelectorCache = {};
  540.          }
  541.          if(param3)
  542.          {
  543.             this.styleDeclarationsChanged();
  544.          }
  545.       }
  546.       
  547.       public function clearStyleDeclaration(param1:String, param2:Boolean) : void
  548.       {
  549.          var _loc4_:Array = null;
  550.          var _loc5_:int = 0;
  551.          var _loc6_:CSSStyleDeclaration = null;
  552.          var _loc7_:Boolean = false;
  553.          var _loc3_:CSSStyleDeclaration = this.getStyleDeclaration(param1);
  554.          if(Boolean(_loc3_) && _loc3_.mx_internal::selectorRefCount > 0)
  555.          {
  556.             --_loc3_.mx_internal::selectorRefCount;
  557.          }
  558.          delete this._selectors[param1];
  559.          if(Boolean(_loc3_) && Boolean(_loc3_.subject))
  560.          {
  561.             _loc4_ = this._subjects[_loc3_.subject] as Array;
  562.             if(_loc4_)
  563.             {
  564.                _loc5_ = int(_loc4_.length - 1);
  565.                while(_loc5_ >= 0)
  566.                {
  567.                   _loc6_ = _loc4_[_loc5_];
  568.                   if((Boolean(_loc6_)) && _loc6_.mx_internal::selectorString == param1)
  569.                   {
  570.                      if(_loc4_.length == 1)
  571.                      {
  572.                         delete this._subjects[_loc3_.subject];
  573.                      }
  574.                      else
  575.                      {
  576.                         _loc4_.splice(_loc5_,1);
  577.                      }
  578.                   }
  579.                   _loc5_--;
  580.                }
  581.             }
  582.          }
  583.          else
  584.          {
  585.             _loc7_ = false;
  586.             for each(_loc4_ in this._subjects)
  587.             {
  588.                if(_loc4_)
  589.                {
  590.                   _loc5_ = int(_loc4_.length - 1);
  591.                   while(_loc5_ >= 0)
  592.                   {
  593.                      _loc6_ = _loc4_[_loc5_];
  594.                      if((Boolean(_loc6_)) && _loc6_.mx_internal::selectorString == param1)
  595.                      {
  596.                         _loc7_ = true;
  597.                         if(_loc4_.length == 1)
  598.                         {
  599.                            delete this._subjects[_loc6_.subject];
  600.                         }
  601.                         else
  602.                         {
  603.                            _loc4_.splice(_loc5_,1);
  604.                         }
  605.                      }
  606.                      _loc5_--;
  607.                   }
  608.                   if(_loc7_)
  609.                   {
  610.                      break;
  611.                   }
  612.                }
  613.             }
  614.          }
  615.          if(param2)
  616.          {
  617.             this.styleDeclarationsChanged();
  618.          }
  619.       }
  620.       
  621.       public function styleDeclarationsChanged() : void
  622.       {
  623.          var _loc4_:ISystemManager = null;
  624.          var _loc5_:Object = null;
  625.          var _loc1_:Array = SystemManagerGlobals.topLevelSystemManagers;
  626.          var _loc2_:int = int(_loc1_.length);
  627.          var _loc3_:int = 0;
  628.          while(_loc3_ < _loc2_)
  629.          {
  630.             _loc4_ = _loc1_[_loc3_];
  631.             _loc5_ = _loc4_.getImplementation("mx.managers::ISystemManagerChildManager");
  632.             Object(_loc5_).regenerateStyleCache(true);
  633.             Object(_loc5_).notifyStyleChangeInChildren(null,true);
  634.             _loc3_++;
  635.          }
  636.       }
  637.       
  638.       public function registerInheritingStyle(param1:String) : void
  639.       {
  640.          if(this._inheritingStyles[param1] != true)
  641.          {
  642.             this._inheritingStyles[param1] = true;
  643.             this.mergedInheritingStylesCache = null;
  644.             if(hasEventListener(FlexChangeEvent.STYLE_MANAGER_CHANGE))
  645.             {
  646.                this.dispatchInheritingStylesChangeEvent();
  647.             }
  648.          }
  649.       }
  650.       
  651.       public function isInheritingStyle(param1:String) : Boolean
  652.       {
  653.          if(this.mergedInheritingStylesCache)
  654.          {
  655.             return this.mergedInheritingStylesCache[param1] == true;
  656.          }
  657.          if(this._inheritingStyles[param1] == true)
  658.          {
  659.             return true;
  660.          }
  661.          if(Boolean(this.parent) && Boolean(this.parent.isInheritingStyle(param1)))
  662.          {
  663.             return true;
  664.          }
  665.          return false;
  666.       }
  667.       
  668.       public function isInheritingTextFormatStyle(param1:String) : Boolean
  669.       {
  670.          if(this.inheritingTextFormatStyles[param1] == true)
  671.          {
  672.             return true;
  673.          }
  674.          if(Boolean(this.parent) && Boolean(this.parent.isInheritingTextFormatStyle(param1)))
  675.          {
  676.             return true;
  677.          }
  678.          return false;
  679.       }
  680.       
  681.       public function registerSizeInvalidatingStyle(param1:String) : void
  682.       {
  683.          this.sizeInvalidatingStyles[param1] = true;
  684.       }
  685.       
  686.       public function isSizeInvalidatingStyle(param1:String) : Boolean
  687.       {
  688.          if(this.sizeInvalidatingStyles[param1] == true)
  689.          {
  690.             return true;
  691.          }
  692.          if(Boolean(this.parent) && Boolean(this.parent.isSizeInvalidatingStyle(param1)))
  693.          {
  694.             return true;
  695.          }
  696.          return false;
  697.       }
  698.       
  699.       public function registerParentSizeInvalidatingStyle(param1:String) : void
  700.       {
  701.          this.parentSizeInvalidatingStyles[param1] = true;
  702.       }
  703.       
  704.       public function isParentSizeInvalidatingStyle(param1:String) : Boolean
  705.       {
  706.          if(this.parentSizeInvalidatingStyles[param1] == true)
  707.          {
  708.             return true;
  709.          }
  710.          if(Boolean(this.parent) && Boolean(this.parent.isParentSizeInvalidatingStyle(param1)))
  711.          {
  712.             return true;
  713.          }
  714.          return false;
  715.       }
  716.       
  717.       public function registerParentDisplayListInvalidatingStyle(param1:String) : void
  718.       {
  719.          this.parentDisplayListInvalidatingStyles[param1] = true;
  720.       }
  721.       
  722.       public function isParentDisplayListInvalidatingStyle(param1:String) : Boolean
  723.       {
  724.          if(this.parentDisplayListInvalidatingStyles[param1] == true)
  725.          {
  726.             return true;
  727.          }
  728.          if(Boolean(this.parent) && Boolean(this.parent.isParentDisplayListInvalidatingStyle(param1)))
  729.          {
  730.             return true;
  731.          }
  732.          return false;
  733.       }
  734.       
  735.       public function registerColorName(param1:String, param2:uint) : void
  736.       {
  737.          this.colorNames[param1.toLowerCase()] = param2;
  738.       }
  739.       
  740.       public function isColorName(param1:String) : Boolean
  741.       {
  742.          if(this.colorNames[param1.toLowerCase()] !== undefined)
  743.          {
  744.             return true;
  745.          }
  746.          if(Boolean(this.parent) && Boolean(this.parent.isColorName(param1)))
  747.          {
  748.             return true;
  749.          }
  750.          return false;
  751.       }
  752.       
  753.       public function getColorName(param1:Object) : uint
  754.       {
  755.          var _loc2_:Number = NaN;
  756.          var _loc3_:* = undefined;
  757.          if(param1 is String)
  758.          {
  759.             if(param1.charAt(0) == "#")
  760.             {
  761.                _loc2_ = Number("0x" + param1.slice(1));
  762.                return isNaN(_loc2_) ? StyleManager.NOT_A_COLOR : uint(_loc2_);
  763.             }
  764.             if(param1.charAt(1) == "x" && param1.charAt(0) == "0")
  765.             {
  766.                _loc2_ = Number(param1);
  767.                return isNaN(_loc2_) ? StyleManager.NOT_A_COLOR : uint(_loc2_);
  768.             }
  769.             _loc3_ = this.colorNames[param1.toLowerCase()];
  770.             if(_loc3_ === undefined)
  771.             {
  772.                if(this.parent)
  773.                {
  774.                   _loc3_ = this.parent.getColorName(param1);
  775.                }
  776.             }
  777.             if(_loc3_ === undefined)
  778.             {
  779.                return StyleManager.NOT_A_COLOR;
  780.             }
  781.             return uint(_loc3_);
  782.          }
  783.          return uint(param1);
  784.       }
  785.       
  786.       public function getColorNames(param1:Array) : void
  787.       {
  788.          var _loc4_:uint = 0;
  789.          if(!param1)
  790.          {
  791.             return;
  792.          }
  793.          var _loc2_:int = int(param1.length);
  794.          var _loc3_:int = 0;
  795.          while(_loc3_ < _loc2_)
  796.          {
  797.             if(param1[_loc3_] != null && isNaN(param1[_loc3_]))
  798.             {
  799.                _loc4_ = this.getColorName(param1[_loc3_]);
  800.                if(_loc4_ != StyleManager.NOT_A_COLOR)
  801.                {
  802.                   param1[_loc3_] = _loc4_;
  803.                }
  804.             }
  805.             _loc3_++;
  806.          }
  807.       }
  808.       
  809.       public function isValidStyleValue(param1:*) : Boolean
  810.       {
  811.          if(param1 !== undefined)
  812.          {
  813.             return true;
  814.          }
  815.          if(this.parent)
  816.          {
  817.             return this.parent.isValidStyleValue(param1);
  818.          }
  819.          return false;
  820.       }
  821.       
  822.       public function loadStyleDeclarations(param1:String, param2:Boolean = true, param3:Boolean = false, param4:ApplicationDomain = null, param5:SecurityDomain = null) : IEventDispatcher
  823.       {
  824.          return this.loadStyleDeclarations2(param1,param2,param4,param5);
  825.       }
  826.       
  827.       public function loadStyleDeclarations2(param1:String, param2:Boolean = true, param3:ApplicationDomain = null, param4:SecurityDomain = null) : IEventDispatcher
  828.       {
  829.          var errorHandler:Function;
  830.          var module:IModuleInfo = null;
  831.          var thisStyleManager:IStyleManager2 = null;
  832.          var styleEventDispatcher:StyleEventDispatcher = null;
  833.          var timer:Timer = null;
  834.          var timerHandler:Function = null;
  835.          var url:String = param1;
  836.          var update:Boolean = param2;
  837.          var applicationDomain:ApplicationDomain = param3;
  838.          var securityDomain:SecurityDomain = param4;
  839.          module = ModuleManager.getModule(url);
  840.          thisStyleManager = this;
  841.          var readyHandler:Function = function(param1:ModuleEvent):void
  842.          {
  843.             var _loc2_:IStyleModule = IStyleModule(param1.module.factory.create());
  844.             param1.module.factory.registerImplementation("mx.styles::IStyleManager2",thisStyleManager);
  845.             _loc2_.setStyleDeclarations(thisStyleManager);
  846.             styleModules[param1.module.url].styleModule = _loc2_;
  847.             if(update)
  848.             {
  849.                styleDeclarationsChanged();
  850.             }
  851.          };
  852.          module.addEventListener(ModuleEvent.READY,readyHandler,false,0,true);
  853.          styleEventDispatcher = new StyleEventDispatcher(module);
  854.          errorHandler = function(param1:ModuleEvent):void
  855.          {
  856.             var _loc3_:StyleEvent = null;
  857.             var _loc2_:String = resourceManager.getString("styles","unableToLoad",[param1.errorText,url]);
  858.             if(styleEventDispatcher.willTrigger(StyleEvent.ERROR))
  859.             {
  860.                _loc3_ = new StyleEvent(StyleEvent.ERROR,param1.bubbles,param1.cancelable);
  861.                _loc3_.bytesLoaded = 0;
  862.                _loc3_.bytesTotal = 0;
  863.                _loc3_.errorText = _loc2_;
  864.                styleEventDispatcher.dispatchEvent(_loc3_);
  865.                return;
  866.             }
  867.             throw new Error(_loc2_);
  868.          };
  869.          module.addEventListener(ModuleEvent.ERROR,errorHandler,false,0,true);
  870.          this.styleModules[url] = new StyleModuleInfo(module,readyHandler,errorHandler);
  871.          timer = new Timer(0);
  872.          timerHandler = function(param1:TimerEvent):void
  873.          {
  874.             timer.removeEventListener(TimerEvent.TIMER,timerHandler);
  875.             timer.stop();
  876.             module.load(applicationDomain,securityDomain);
  877.          };
  878.          timer.addEventListener(TimerEvent.TIMER,timerHandler,false,0,true);
  879.          timer.start();
  880.          return styleEventDispatcher;
  881.       }
  882.       
  883.       public function unloadStyleDeclarations(param1:String, param2:Boolean = true) : void
  884.       {
  885.          var _loc4_:IModuleInfo = null;
  886.          var _loc3_:StyleModuleInfo = this.styleModules[param1];
  887.          if(_loc3_)
  888.          {
  889.             _loc3_.styleModule.unload();
  890.             _loc4_ = _loc3_.module;
  891.             _loc4_.unload();
  892.             _loc4_.removeEventListener(ModuleEvent.READY,_loc3_.readyHandler);
  893.             _loc4_.removeEventListener(ModuleEvent.ERROR,_loc3_.errorHandler);
  894.             this.styleModules[param1] = null;
  895.          }
  896.          if(param2)
  897.          {
  898.             this.styleDeclarationsChanged();
  899.          }
  900.       }
  901.       
  902.       private function dispatchInheritingStylesChangeEvent() : void
  903.       {
  904.          var _loc1_:Event = new FlexChangeEvent(FlexChangeEvent.STYLE_MANAGER_CHANGE,false,false,{"property":"inheritingStyles"});
  905.          dispatchEvent(_loc1_);
  906.       }
  907.       
  908.       public function acceptMediaList(param1:String) : Boolean
  909.       {
  910.          if(!this.mqp)
  911.          {
  912.             this.mqp = MediaQueryParser.instance;
  913.             if(!this.mqp)
  914.             {
  915.                this.mqp = new MediaQueryParser(this.moduleFactory);
  916.                MediaQueryParser.instance = this.mqp;
  917.             }
  918.          }
  919.          return this.mqp.parse(param1);
  920.       }
  921.       
  922.       private function styleManagerChangeHandler(param1:FlexChangeEvent) : void
  923.       {
  924.          if(!param1.data)
  925.          {
  926.             return;
  927.          }
  928.          var _loc2_:String = param1.data["property"];
  929.          if(_loc2_ == "inheritingStyles")
  930.          {
  931.             this.mergedInheritingStylesCache = null;
  932.          }
  933.          if(hasEventListener(FlexChangeEvent.STYLE_MANAGER_CHANGE))
  934.          {
  935.             dispatchEvent(param1);
  936.          }
  937.       }
  938.    }
  939. }
  940.  
  941. import flash.events.EventDispatcher;
  942. import mx.events.ModuleEvent;
  943. import mx.events.StyleEvent;
  944. import mx.modules.IModuleInfo;
  945.  
  946. class StyleEventDispatcher extends EventDispatcher
  947. {
  948.    public function StyleEventDispatcher(param1:IModuleInfo)
  949.    {
  950.       super();
  951.       param1.addEventListener(ModuleEvent.PROGRESS,this.moduleInfo_progressHandler,false,0,true);
  952.       param1.addEventListener(ModuleEvent.READY,this.moduleInfo_readyHandler,false,0,true);
  953.    }
  954.    
  955.    private function moduleInfo_progressHandler(param1:ModuleEvent) : void
  956.    {
  957.       var _loc2_:StyleEvent = new StyleEvent(StyleEvent.PROGRESS,param1.bubbles,param1.cancelable);
  958.       _loc2_.bytesLoaded = param1.bytesLoaded;
  959.       _loc2_.bytesTotal = param1.bytesTotal;
  960.       dispatchEvent(_loc2_);
  961.    }
  962.    
  963.    private function moduleInfo_readyHandler(param1:ModuleEvent) : void
  964.    {
  965.       var _loc2_:StyleEvent = new StyleEvent(StyleEvent.COMPLETE);
  966.       _loc2_.bytesLoaded = param1.bytesLoaded;
  967.       _loc2_.bytesTotal = param1.bytesTotal;
  968.       dispatchEvent(_loc2_);
  969.    }
  970. }
  971.  
  972. class StyleModuleInfo
  973. {
  974.    public var errorHandler:Function;
  975.    
  976.    public var readyHandler:Function;
  977.    
  978.    public var styleModule:IStyleModule;
  979.    
  980.    public var module:IModuleInfo;
  981.    
  982.    public function StyleModuleInfo(param1:IModuleInfo, param2:Function, param3:Function)
  983.    {
  984.       super();
  985.       this.module = param1;
  986.       this.readyHandler = param2;
  987.       this.errorHandler = param3;
  988.    }
  989. }
  990.