Example #1
0
        /// <summary> Creates new <sse cref="HtmlDocument"/> instance. </summary>
        internal Document(string namespaceUri, string qualifiedNameStr, DocType docType, IWindow window) : base(null)
        {
            Implementation = new DomImplementation();

            StyleSheets = new StyleSheetsList();
            NodeType    = DOCUMENT_NODE;

            if (docType != null)
            {
                AppendChild(docType);
            }

            var root = CreateElementNs(namespaceUri, qualifiedNameStr);

            AppendChild(root);

            Initialize();

            Scripts = new HtmlCollection(() => GetElementsByTagName(TagsNames.Script));
            Forms   = new HtmlCollection(() => GetElementsByTagName(TagsNames.Form));
            Images  = new HtmlCollection(() => GetElementsByTagName(TagsNames.Img));
            Links   = new HtmlCollection(() =>
                                         GetElementsByTagName(TagsNames.A).Where(x => !string.IsNullOrEmpty(((HtmlAnchorElement)x).Href))
                                         .Concat(GetElementsByTagName(TagsNames.Textarea).Where(x => !string.IsNullOrEmpty(((HtmlAreaElement)x).Href))));
            Embeds = new HtmlCollection(() => GetElementsByTagName(TagsNames.Embed));

            DefaultView = window;

            ReadyState = DocumentReadyStates.Loading;
        }
Example #2
0
		/// <summary>
		/// Creates new <sse cref="Document"/> instance.
		/// </summary>
		/// <param name="window">The Window object ot be associated with the document. Can be null.</param>
		internal Document(string namespaceUri, string qualifiedNameStr, DocType docType, IWindow window) : base(null)
		{
			Implementation = new DomImplementation();

			StyleSheets = new StyleSheetsList();
			NodeType = DOCUMENT_NODE;

			if(docType != null)
				AppendChild(docType);

			var root = CreateElementNs(namespaceUri, qualifiedNameStr);
			AppendChild(root);
			root.AppendChild(Head = (Head)CreateElement(TagsNames.Head));
			root.AppendChild(Body = (HtmlBodyElement)CreateElement(TagsNames.Body));

			DefaultView = window;

			ReadyState = DocumentReadyStates.Loading;
		}