/// <summary>Creates a new document which will be rendered with the given renderer.</summary>
        /// <param name="renderer">The renderer to use when rendering this document.</param>
        /// <param name="parentWindow">The window that will become the parent window. Used in e.g. iframes.</param>
        /// <param name="aot">True if this is a Nitro AOT document (used in the Editor only).</param>
        public Document(Renderman renderer, Window parentWindow, bool aot) : base()
        {
            AotDocument = aot;

            if (!aot && DefaultStyleSheet == null)
            {
                // No default styles loaded yet. Load them now.
                string styleText = ((TextAsset)Resources.Load("style")).text;
                // Have they applied any overrides?
                TextAsset extraStyle = Resources.Load("customStyle") as TextAsset;
                if (extraStyle != null && extraStyle.text != null)
                {
                    styleText += "\n\n" + extraStyle.text;
                }
                DefaultStyleSheet = new Css.StyleSheet(this);
                DefaultStyleSheet.ParseCss(styleText);
            }

                        #if !NoNitroRuntime
            // Get the default security domain:
            SecurityDomain = UI.DefaultSecurityDomain;
                        #endif

            Renderer = renderer;

            window          = new Window();
            window.document = this;
            window.parent   = parentWindow;
            if (parentWindow != null)
            {
                window.top = parentWindow.top;
            }
            else
            {
                window.top = window;
            }

            ActiveFonts = new Dictionary <string, DynamicFont>();
            Style       = new Css.StyleSheet(this);
            html        = new Element(this, null);
            html.SetTag("html");
            string ddbox = "";

            if (parentWindow == null)
            {
                // Dropdown box belongs to the top window only:
                ddbox = "<ddbox></ddbox>";
            }

            html.innerHTML = "<body></body>" + ddbox;
        }
		/// <summary>Creates a new document which will be rendered with the given renderer.</summary>
		/// <param name="renderer">The renderer to use when rendering this document.</param>
		/// <param name="parentWindow">The window that will become the parent window. Used in e.g. iframes.</param>
		/// <param name="aot">True if this is a Nitro AOT document (used in the Editor only).</param>
		public Document(Renderman renderer,Window parentWindow,bool aot):base(){
			AotDocument=aot;
			
			if(!aot && DefaultStyleSheet==null){
				// No default styles loaded yet. Load them now.
				string styleText=((TextAsset)Resources.Load("style")).text;
				// Have they applied any overrides?
				TextAsset extraStyle=Resources.Load("customStyle") as TextAsset;
				if(extraStyle!=null && extraStyle.text!=null){
					styleText+="\n\n"+extraStyle.text;
				}
				DefaultStyleSheet=new Css.StyleSheet(this);
				DefaultStyleSheet.ParseCss(styleText);
			}
			
			#if !NoNitroRuntime
			// Get the default security domain:
			SecurityDomain=UI.DefaultSecurityDomain;
			#endif
			
			Renderer=renderer;
			
			window=new Window();
			window.document=this;
			window.parent=parentWindow;
			if(parentWindow!=null){
				window.top=parentWindow.top;
			}else{
				window.top=window;
			}
			
			ActiveFonts=new Dictionary<string,DynamicFont>();
			Style=new Css.StyleSheet(this);
			html=new Element(this,null);
			html.SetTag("html");
			string ddbox="";
			
			if(parentWindow==null){
				// Dropdown box belongs to the top window only:
				ddbox="<ddbox></ddbox>";
			}
			
			html.innerHTML="<body></body>"+ddbox;
		}