<commit_before>////////////////////////////////////////////////////////////////////////////////
//
//  Fork unstable media GmbH
//  Copyright 2006-2008 Fork unstable media GmbH
//  All Rights Reserved.
//
//  NOTICE: Fork unstable media permits you to use, modify, and distribute this
//  file in accordance with the terms of the license agreement accompanying it.
//
////////////////////////////////////////////////////////////////////////////////

package reprise.css
{
	import reprise.core.reprise;
	import reprise.css.propertyparsers.RuntimeParser;
	import reprise.data.collection.IndexedArray;
	import reprise.events.CommandEvent;
	import reprise.events.ResourceEvent;
	import reprise.external.AbstractResource;
	import reprise.external.BitmapResource;
	import reprise.external.ResourceLoader;
	import reprise.utils.StringUtil;
	
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import flash.utils.getTimer;
	
	use namespace reprise;

	public class CSS extends AbstractResource
	{
		/***************************************************************************
		*							public properties							   *
		***************************************************************************/
		public static const PROPERTY_TYPE_STRING : uint = 1;
		public static const PROPERTY_TYPE_INT : uint = 2;
		public static const PROPERTY_TYPE_FLOAT : uint = 3;
		public static const PROPERTY_TYPE_BOOL : uint = 4;
		public static const PROPERTY_TYPE_URL : uint = 5;
		public static const PROPERTY_TYPE_COLOR : uint = 6;
		
		
		/***************************************************************************
		*							protected properties							   *
		***************************************************************************/
		protected var g_idSource : Number;
		
		
		protected var m_cssFile : CSSImport;
		protected var m_loader : ResourceLoader;
		protected var m_imagePreloadingResource : ResourceLoader;
		protected var m_importQueue : Array;
		protected var m_cssSegments : IndexedArray;
		protected var m_declarationList : CSSDeclarationList;
		protected var m_cssVariables : Object;
		
		protected var m_baseURL : String;
		protected var m_runtimeParserRegistered : Boolean;
		
		protected var m_cleanupTime : Number;
		protected var m_parseTime : Number;
		protected var m_importsLoaded : Number;
		protected var m_importsTotal : Number;
		private var m_stylesheetURLs : Array;

		
		/***************************************************************************
		*							public methods								   *
		***************************************************************************/
		public function CSS(url : String = null)
		{
			m_id = g_idSource++;
			
			m_loader = new ResourceLoader();
			m_cssVariables = {};
			
			if (url)
			{
				m_url = url;
			}
			m_loader.addEventListener(Event.COMPLETE, loader_complete);
		}
		
		public override function execute(...rest) : void
		{
			if (m_url == null)
			{
				throw new Error('You didn\'t specify an URL for your ' + 
					'CSS resource! Make sure you do this before calling execute!');
				return;
			}
			
			if (!m_runtimeParserRegistered)
			{
				CSSDeclaration.registerPropertyCollection(RuntimeParser);
				m_runtimeParserRegistered = true;
			}
			
			m_didFinishLoading = false;
			m_isCancelled = false;
			m_parseTime = 0;
			m_cleanupTime = 0;
			m_importsLoaded = 0;
			m_importsTotal = 1;
			m_declarationList = new CSSDeclarationList();
			m_stylesheetURLs = [];
			m_importQueue = [];
			m_cssSegments = new IndexedArray();
			setURL(m_url);
			m_cssFile.setURL(CSSParsingHelper.resolvePathAgainstPath(url(), baseURL()));
			m_stylesheetURLs.push(m_cssFile.url());
			m_loader.addResource(m_cssFile);
			m_loader.execute();
		}
		
		public override function didSucceed():Boolean
		{
			// provisionally
			//TODO: return sane value
			return true;
		}
		
		public override function cancel() : void
		{
			log('w cancel for CSS is not implemented yet!');
			m_isCancelled = true;
			dispatchEvent(new ResourceEvent(Event.CANCEL));
		}
		
		public override function isExecuting():Boolean
		{
			// @FIXME
			return false;
		}
		
		public function getStyleForSelectorPath(sp : String) : CSSDeclaration
		{
			return getStyleForEscapedSelectorPath(escapeSelectorPath(sp));
		}
		reprise function getStyleForEscapedSelectorPath(sp : String) : CSSDeclaration
		{
			return m_declarationList.getStyleForSelectorsPath(sp);
		}
		
		public function stylesheetURLs() : Array
		{
			return m_stylesheetURLs;
		}

		/**
		 * Escapes a selectorPath and thus prepares it for being processed by the <commit_msg>- Bugfix: caught error condition that prevented document structures from working without an external CSS file being loaded<commit_after>////////////////////////////////////////////////////////////////////////////////
//
//  Fork unstable media GmbH
//  Copyright 2006-2008 Fork unstable media GmbH
//  All Rights Reserved.
//
//  NOTICE: Fork unstable media permits you to use, modify, and distribute this
//  file in accordance with the terms of the license agreement accompanying it.
//
////////////////////////////////////////////////////////////////////////////////

package reprise.css
{
	import reprise.core.reprise;
	import reprise.css.propertyparsers.RuntimeParser;
	import reprise.data.collection.IndexedArray;
	import reprise.events.CommandEvent;
	import reprise.events.ResourceEvent;
	import reprise.external.AbstractResource;
	import reprise.external.BitmapResource;
	import reprise.external.ResourceLoader;
	import reprise.utils.StringUtil;
	
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import flash.utils.getTimer;
	
	use namespace reprise;

	public class CSS extends AbstractResource
	{
		/***************************************************************************
		*							public properties							   *
		***************************************************************************/
		public static const PROPERTY_TYPE_STRING : uint = 1;
		public static const PROPERTY_TYPE_INT : uint = 2;
		public static const PROPERTY_TYPE_FLOAT : uint = 3;
		public static const PROPERTY_TYPE_BOOL : uint = 4;
		public static const PROPERTY_TYPE_URL : uint = 5;
		public static const PROPERTY_TYPE_COLOR : uint = 6;
		
		
		/***************************************************************************
		*							protected properties							   *
		***************************************************************************/
		protected var g_idSource : Number;
		
		
		protected var m_cssFile : CSSImport;
		protected var m_loader : ResourceLoader;
		protected var m_imagePreloadingResource : ResourceLoader;
		protected var m_importQueue : Array;
		protected var m_cssSegments : IndexedArray;
		protected var m_declarationList : CSSDeclarationList;
		protected var m_cssVariables : Object;
		
		protected var m_baseURL : String;
		protected var m_runtimeParserRegistered : Boolean;
		
		protected var m_cleanupTime : Number;
		protected var m_parseTime : Number;
		protected var m_importsLoaded : Number;
		protected var m_importsTotal : Number;
		private var m_stylesheetURLs : Array;

		
		/***************************************************************************
		*							public methods								   *
		***************************************************************************/
		public function CSS(url : String = null)
		{
			m_id = g_idSource++;
			
			m_loader = new ResourceLoader();
			m_cssVariables = {};
			
			if (url)
			{
				m_url = url;
			}
			m_loader.addEventListener(Event.COMPLETE, loader_complete);
		}
		
		public override function execute(...rest) : void
		{
			if (m_url == null)
			{
				throw new Error('You didn\'t specify an URL for your ' + 
					'CSS resource! Make sure you do this before calling execute!');
				return;
			}
			
			if (!m_runtimeParserRegistered)
			{
				CSSDeclaration.registerPropertyCollection(RuntimeParser);
				m_runtimeParserRegistered = true;
			}
			
			m_didFinishLoading = false;
			m_isCancelled = false;
			m_parseTime = 0;
			m_cleanupTime = 0;
			m_importsLoaded = 0;
			m_importsTotal = 1;
			m_declarationList = new CSSDeclarationList();
			m_stylesheetURLs = [];
			m_importQueue = [];
			m_cssSegments = new IndexedArray();
			setURL(m_url);
			m_cssFile.setURL(CSSParsingHelper.resolvePathAgainstPath(url(), baseURL()));
			m_stylesheetURLs.push(m_cssFile.url());
			m_loader.addResource(m_cssFile);
			m_loader.execute();
		}
		
		public override function didSucceed():Boolean
		{
			// provisionally
			//TODO: return sane value
			return true;
		}
		
		public override function cancel() : void
		{
			log('w cancel for CSS is not implemented yet!');
			m_isCancelled = true;
			dispatchEvent(new ResourceEvent(Event.CANCEL));
		}
		
		public override function isExecuting():Boolean
		{
			// @FIXME
			return false;
		}
		
		public function getStyleForSelectorPath(sp : String) : CSSDeclaration
		{
			return getStyleForEscapedSelectorPath(escapeSelectorPath(sp));
		}
		reprise function getStyleForEscapedSelectorPath(sp : String) : CSSDeclaration
		{
			return m_declarationList && m_declarationList.getStyleForSelectorsPath(sp) || 
				new CSSDeclaration();
		}

		public function stylesheetURLs() : Array
		{
			return m_stylesheetURLs;
		}

		/**
		 * Escapes a selectorPath and thus prepares it for being processed by the 
{'fraction_non_alphanumeric': 0.20135381970559793, 'fraction_numerical': 0.0038680563017083917, 'mean_word_length': 3.4051112162801704, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5157931', 'n_tokens_mistral': 3040, 'n_tokens_neox': 2447, 'n_words': 654}