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

using System;

namespace Css{
	
	/// <summary>
	///Describes if an element is the root of the document.
	/// <summary>

	sealed class IsRoot:CssKeyword{
		
		public override string Name{
			get{
				return "root";
			}
		}
		
		public override SelectorMatcher GetSelectorMatcher(){
			return new IsRootMatcher();
		}
		
	}
	
	/// <summary>
	/// Handles the matching process for :root.
	/// </summary>
	
	sealed class IsRootMatcher:LocalMatcher{
		
		public override bool TryMatch(Dom.Node node){
			
			if(node==null){
				return false;
			}
			
			return ( node==(node.document as ReflowDocument).documentElement);
			
		}
		
	}
	
}