namespace Cef3 { using System; using System.Collections.Generic; using System.Diagnostics; using System.Runtime.InteropServices; using Cef3.Interop; /// /// Class used to represent a DOM document. The methods of this class should only /// be called on the render process main thread thread. /// public sealed unsafe partial class CefDomDocument { /// /// Returns the document type. /// public CefDomDocumentType DocumentType { get { return cef_domdocument_t.get_type(_self); } } /// /// Returns the root document node. /// public CefDomNode Root { get { return CefDomNode.FromNative( cef_domdocument_t.get_document(_self) ); } } /// /// Returns the BODY node of an HTML document. /// public CefDomNode Body { get { return CefDomNode.FromNative( cef_domdocument_t.get_body(_self) ); } } /// /// Returns the HEAD node of an HTML document. /// public CefDomNode Head { get { return CefDomNode.FromNative( cef_domdocument_t.get_head(_self) ); } } /// /// Returns the title of an HTML document. /// public string Title { get { var n_result = cef_domdocument_t.get_title(_self); return cef_string_userfree.ToString(n_result); } } /// /// Returns the document element with the specified ID value. /// public CefDomNode GetElementById(string id) { fixed (char* id_str = id) { var n_id = new cef_string_t(id_str, id.Length); return CefDomNode.FromNativeOrNull( cef_domdocument_t.get_element_by_id(_self, &n_id) ); } } /// /// Returns the node that currently has keyboard focus. /// public CefDomNode FocusedNode { get { return CefDomNode.FromNativeOrNull( cef_domdocument_t.get_focused_node(_self) ); } } /// /// Returns true if a portion of the document is selected. /// public bool HasSelection { get { return cef_domdocument_t.has_selection(_self) != 0; } } /// /// Returns the selection offset within the start node. /// public int SelectionStartOffset { get { return cef_domdocument_t.get_selection_start_offset(_self); } } /// /// Returns the selection offset within the end node. /// public int GetSelectionEndOffset { get { return cef_domdocument_t.get_selection_end_offset(_self); } } /// /// Returns the contents of this selection as markup. /// public string SelectionAsMarkup { get { var n_result = cef_domdocument_t.get_selection_as_markup(_self); return cef_string_userfree.ToString(n_result); } } /// /// Returns the contents of this selection as text. /// public string GetSelectionAsText { get { var n_result = cef_domdocument_t.get_selection_as_text(_self); return cef_string_userfree.ToString(n_result); } } /// /// Returns the base URL for the document. /// public string BaseUrl { get { var n_result = cef_domdocument_t.get_base_url(_self); return cef_string_userfree.ToString(n_result); } } /// /// Returns a complete URL based on the document base URL and the specified /// partial URL. /// public string GetCompleteUrl(string partialUrl) { fixed (char* partialUrl_str = partialUrl) { var n_partialUrl = new cef_string_t(partialUrl_str, partialUrl.Length); var n_result = cef_domdocument_t.get_complete_url(_self, &n_partialUrl); return cef_string_userfree.ToString(n_result); } } } }