//--------------------------------------
//               PowerUI
//
//        For documentation or 
//    if you have any issues, visit
//        powerUI.kulestar.com
//
//    Copyright  2013 Kulestar Ltd
//          www.kulestar.com
//--------------------------------------

using System;
using PowerUI;


namespace Css{
	
	/// <summary>
	/// Describes if this element is on the main UI. E.g. html:main-ui{}
	/// See also IsWorldUI.
	/// <summary>

	sealed class IsMainUI:CssKeyword{
		
		public override string Name{
			get{
				return "main-ui";
			}
		}
		
		public override SelectorMatcher GetSelectorMatcher(){
			return new MainUIMatcher();
		}
		
	}
	
	/// <summary>
	/// Handles the matching process for :main-ui.
	/// </summary>
	
	sealed class MainUIMatcher:LocalMatcher{
		
		public override bool TryMatch(Dom.Node node){
			
			if(node==null){
				return false;
			}
			
			HtmlDocument htmlDoc=(node.document as HtmlDocument);
			
			// Location must be 'resources://' only:
			if(htmlDoc==null || htmlDoc.location==null || htmlDoc.location.Protocol!="resources"){
				return false;
			}
			
			return (htmlDoc==UI.document);
			
		}
		
	}
	
}