libdom
Loading...
Searching...
No Matches
Macros | Functions
html_document.c File Reference
#include <assert.h>
#include <stdlib.h>
#include <dom/html/html_elements.h>
#include "html/html_document.h"
#include "html/html_element.h"
#include "html/html_collection.h"
#include "html/html_html_element.h"
#include "html/html_head_element.h"
#include "html/html_body_element.h"
#include "html/html_base_element.h"
#include "html/html_canvas_element.h"
#include "html/html_div_element.h"
#include "html/html_link_element.h"
#include "html/html_title_element.h"
#include "html/html_meta_element.h"
#include "html/html_form_element.h"
#include "html/html_button_element.h"
#include "html/html_input_element.h"
#include "html/html_text_area_element.h"
#include "html/html_opt_group_element.h"
#include "html/html_option_element.h"
#include "html/html_select_element.h"
#include "html/html_hr_element.h"
#include "html/html_dlist_element.h"
#include "html/html_directory_element.h"
#include "html/html_menu_element.h"
#include "html/html_fieldset_element.h"
#include "html/html_legend_element.h"
#include "html/html_paragraph_element.h"
#include "html/html_heading_element.h"
#include "html/html_quote_element.h"
#include "html/html_pre_element.h"
#include "html/html_br_element.h"
#include "html/html_label_element.h"
#include "html/html_ulist_element.h"
#include "html/html_olist_element.h"
#include "html/html_li_element.h"
#include "html/html_font_element.h"
#include "html/html_mod_element.h"
#include "html/html_anchor_element.h"
#include "html/html_basefont_element.h"
#include "html/html_image_element.h"
#include "html/html_object_element.h"
#include "html/html_param_element.h"
#include "html/html_applet_element.h"
#include "html/html_map_element.h"
#include "html/html_area_element.h"
#include "html/html_script_element.h"
#include "html/html_tablecaption_element.h"
#include "html/html_tablecell_element.h"
#include "html/html_tablecol_element.h"
#include "html/html_tablesection_element.h"
#include "html/html_table_element.h"
#include "html/html_tablerow_element.h"
#include "html/html_style_element.h"
#include "html/html_frameset_element.h"
#include "html/html_frame_element.h"
#include "html/html_iframe_element.h"
#include "html/html_isindex_element.h"
#include "core/attr.h"
#include "core/string.h"
#include "utils/namespace.h"
#include "utils/utils.h"
#include "html_document_strings.h"

Macros

#define HTML_DOCUMENT_STRINGS_ACTION(attr, str)
 
#define DOM_HTML_ELEMENT_STRINGS_ENTRY(tag)
 
#define RETURN_IF_MATCH(_x, _y)    if (dom_string_isequal(_x, html->elements[_y])) { return _y; }
 

Functions

dom_exception _dom_html_document_create (dom_events_default_action_fetcher daf, void *daf_ctx, dom_html_document **doc)
 
dom_exception _dom_html_document_initialise (dom_html_document *doc, dom_events_default_action_fetcher daf, void *daf_ctx)
 
bool _dom_html_document_finalise (dom_html_document *doc)
 
void _dom_html_document_destroy (dom_node_internal *node)
 
dom_exception _dom_html_document_copy (dom_node_internal *old, dom_node_internal **copy)
 
dom_exception _dom_html_document_create_element (dom_document *doc, dom_string *tag_name, dom_element **result)
 
dom_exception _dom_html_document_create_element_ns (dom_document *doc, dom_string *namespace, dom_string *qname, dom_element **result)
 
dom_exception _dom_html_document_create_attribute (dom_document *doc, dom_string *name, dom_attr **result)
 
dom_exception _dom_html_document_create_attribute_ns (dom_document *doc, dom_string *namespace, dom_string *qname, dom_attr **result)
 
dom_exception _dom_html_document_get_elements_by_tag_name (dom_document *doc, dom_string *tagname, dom_nodelist **result)
 
dom_exception _dom_html_document_get_elements_by_tag_name_ns (dom_document *doc, dom_string *namespace, dom_string *localname, dom_nodelist **result)
 
dom_exception _dom_html_document_get_title (dom_html_document *doc, dom_string **title)
 
dom_exception _dom_html_document_set_title (dom_html_document *doc, dom_string *title)
 
dom_exception _dom_html_document_get_referrer (dom_html_document *doc, dom_string **referrer)
 
dom_exception _dom_html_document_get_domain (dom_html_document *doc, dom_string **domain)
 
dom_exception _dom_html_document_get_url (dom_html_document *doc, dom_string **url)
 
dom_exception _dom_html_document_get_body (dom_html_document *doc, struct dom_html_element **body)
 
dom_exception _dom_html_document_set_body (dom_html_document *doc, struct dom_html_element *body)
 
bool images_callback (struct dom_node_internal *node, void *ctx)
 
dom_exception _dom_html_document_get_images (dom_html_document *doc, struct dom_html_collection **col)
 
bool applet_callback (struct dom_node_internal *node, void *ctx)
 
bool applets_callback (struct dom_node_internal *node, void *ctx)
 
dom_exception _dom_html_document_get_applets (dom_html_document *doc, struct dom_html_collection **col)
 
bool links_callback (struct dom_node_internal *node, void *ctx)
 
dom_exception _dom_html_document_get_links (dom_html_document *doc, struct dom_html_collection **col)
 
dom_exception _dom_html_document_get_forms (dom_html_document *doc, struct dom_html_collection **col)
 
bool anchors_callback (struct dom_node_internal *node, void *ctx)
 
dom_exception _dom_html_document_get_anchors (dom_html_document *doc, struct dom_html_collection **col)
 
dom_exception _dom_html_document_get_cookie (dom_html_document *doc, dom_string **cookie)
 
dom_exception _dom_html_document_set_cookie (dom_html_document *doc, dom_string *cookie)
 
dom_exception _dom_html_document_open (dom_html_document *doc)
 
dom_exception _dom_html_document_close (dom_html_document *doc)
 
dom_exception _dom_html_document_write (dom_html_document *doc, dom_string *text)
 
dom_exception _dom_html_document_writeln (dom_html_document *doc, dom_string *text)
 
dom_exception _dom_html_document_get_elements_by_name (dom_html_document *doc, dom_string *name, struct dom_nodelist **list)
 

Macro Definition Documentation

◆ DOM_HTML_ELEMENT_STRINGS_ENTRY

#define DOM_HTML_ELEMENT_STRINGS_ENTRY ( tag)
Value:
error = dom_string_create_interned((const uint8_t *) #tag, \
SLEN(#tag), \
&doc->elements[DOM_HTML_ELEMENT_TYPE_##tag]); \
if (error != DOM_NO_ERR) { \
goto out; \
}
#define SLEN(s)
Definition utils.h:21
@ DOM_NO_ERR
Definition exceptions.h:25
dom_exception dom_string_create_interned(const uint8_t *ptr, size_t len, dom_string **str)
Definition string.c:139

◆ HTML_DOCUMENT_STRINGS_ACTION

#define HTML_DOCUMENT_STRINGS_ACTION ( attr,
str )
Value:
error = dom_string_create_interned((const uint8_t *) #str, \
SLEN(#str), &doc->memoised[hds_##attr]); \
if (error != DOM_NO_ERR) { \
goto out; \
}

◆ RETURN_IF_MATCH

#define RETURN_IF_MATCH ( _x,
_y )    if (dom_string_isequal(_x, html->elements[_y])) { return _y; }

Function Documentation

◆ _dom_html_document_close()

dom_exception _dom_html_document_close ( dom_html_document * doc)

◆ _dom_html_document_copy()

dom_exception _dom_html_document_copy ( dom_node_internal * old,
dom_node_internal ** copy )

◆ _dom_html_document_create()

dom_exception _dom_html_document_create ( dom_events_default_action_fetcher daf,
void * daf_ctx,
dom_html_document ** doc )

◆ _dom_html_document_create_attribute()

dom_exception _dom_html_document_create_attribute ( dom_document * doc,
dom_string * name,
dom_attr ** result )

Create an attribute

Parameters
docThe document owning the attribute
nameThe name of the attribute
resultPointer to location to receive result
Returns
DOM_NO_ERR on success,

The constructed attribute will always be classified as 'specified'.

The returned node will have its reference count increased. It is the responsibility of the caller to unref the node once it has finished with it.

◆ _dom_html_document_create_attribute_ns()

dom_exception _dom_html_document_create_attribute_ns ( dom_document * doc,
dom_string * namespace,
dom_string * qname,
dom_attr ** result )

Create an attribute from the qualified name and namespace URI

Parameters
docThe document owning the attribute
namespaceThe namespace URI to use
qnameThe qualified name of the attribute
resultPointer to location to receive result
Returns
DOM_NO_ERR on success, DOM_NAMESPACE_ERR if ::qname is malformed, or it has a prefix and ::namespace is NULL, or ::qname has a prefix "xml" and ::namespace is not "http://www.w3.org/XML/1998/namespace", or ::qname has a prefix "xmlns" and ::namespace is not "http://www.w3.org/2000/xmlns", or ::namespace is "http://www.w3.org/2000/xmlns" and ::qname is not (or is not prefixed by) "xmlns", DOM_NOT_SUPPORTED_ERR if ::doc does not support the "XML" feature.

The returned node will have its reference count increased. It is the responsibility of the caller to unref the node once it has finished with it.

◆ _dom_html_document_create_element()

dom_exception _dom_html_document_create_element ( dom_document * doc,
dom_string * tag_name,
dom_element ** result )

◆ _dom_html_document_create_element_ns()

dom_exception _dom_html_document_create_element_ns ( dom_document * doc,
dom_string * namespace,
dom_string * qname,
dom_element ** result )

◆ _dom_html_document_destroy()

void _dom_html_document_destroy ( dom_node_internal * node)

◆ _dom_html_document_finalise()

bool _dom_html_document_finalise ( dom_html_document * doc)

◆ _dom_html_document_get_anchors()

dom_exception _dom_html_document_get_anchors ( dom_html_document * doc,
struct dom_html_collection ** col )

◆ _dom_html_document_get_applets()

dom_exception _dom_html_document_get_applets ( dom_html_document * doc,
struct dom_html_collection ** col )

◆ _dom_html_document_get_body()

dom_exception _dom_html_document_get_body ( dom_html_document * doc,
struct dom_html_element ** body )

◆ _dom_html_document_get_cookie()

dom_exception _dom_html_document_get_cookie ( dom_html_document * doc,
dom_string ** cookie )

◆ _dom_html_document_get_domain()

dom_exception _dom_html_document_get_domain ( dom_html_document * doc,
dom_string ** domain )

◆ _dom_html_document_get_elements_by_name()

dom_exception _dom_html_document_get_elements_by_name ( dom_html_document * doc,
dom_string * name,
struct dom_nodelist ** list )

◆ _dom_html_document_get_elements_by_tag_name()

dom_exception _dom_html_document_get_elements_by_tag_name ( dom_document * doc,
dom_string * tagname,
dom_nodelist ** result )

Retrieve a list of all elements with a given tag name

Parameters
docThe document to search in
tagnameThe tag name to search for ("*" for all)
resultPointer to location to receive result
Returns
DOM_NO_ERR.

The returned list will have its reference count increased. It is the responsibility of the caller to unref the list once it has finished with it.

◆ _dom_html_document_get_elements_by_tag_name_ns()

dom_exception _dom_html_document_get_elements_by_tag_name_ns ( dom_document * doc,
dom_string * namespace,
dom_string * localname,
dom_nodelist ** result )

Retrieve a list of all elements with a given local name and namespace URI

Parameters
docThe document to search in
namespaceThe namespace URI
localnameThe local name
resultPointer to location to receive result
Returns
DOM_NO_ERR on success, appropriate dom_exception on failure.

The returned list will have its reference count increased. It is the responsibility of the caller to unref the list once it has finished with it.

◆ _dom_html_document_get_forms()

dom_exception _dom_html_document_get_forms ( dom_html_document * doc,
struct dom_html_collection ** col )

◆ _dom_html_document_get_images()

dom_exception _dom_html_document_get_images ( dom_html_document * doc,
struct dom_html_collection ** col )

◆ _dom_html_document_get_links()

dom_exception _dom_html_document_get_links ( dom_html_document * doc,
struct dom_html_collection ** col )

◆ _dom_html_document_get_referrer()

dom_exception _dom_html_document_get_referrer ( dom_html_document * doc,
dom_string ** referrer )

◆ _dom_html_document_get_title()

dom_exception _dom_html_document_get_title ( dom_html_document * doc,
dom_string ** title )

Get the title of this HTMLDocument

Parameters
docThe document object
titleThe reutrned title string
Returns
DOM_NO_ERR on success, appropriated dom_exception on failure.
Note
: this method find a title for the document as following:
  1. If there is a title in the document object set by dom_html_document_set_title, then use it;
  2. If there is no such one, find the <title> element and use its text as the returned title.

◆ _dom_html_document_get_url()

dom_exception _dom_html_document_get_url ( dom_html_document * doc,
dom_string ** url )

◆ _dom_html_document_initialise()

dom_exception _dom_html_document_initialise ( dom_html_document * doc,
dom_events_default_action_fetcher daf,
void * daf_ctx )

◆ _dom_html_document_open()

dom_exception _dom_html_document_open ( dom_html_document * doc)

◆ _dom_html_document_set_body()

dom_exception _dom_html_document_set_body ( dom_html_document * doc,
struct dom_html_element * body )

◆ _dom_html_document_set_cookie()

dom_exception _dom_html_document_set_cookie ( dom_html_document * doc,
dom_string * cookie )

◆ _dom_html_document_set_title()

dom_exception _dom_html_document_set_title ( dom_html_document * doc,
dom_string * title )

◆ _dom_html_document_write()

dom_exception _dom_html_document_write ( dom_html_document * doc,
dom_string * text )

◆ _dom_html_document_writeln()

dom_exception _dom_html_document_writeln ( dom_html_document * doc,
dom_string * text )

◆ anchors_callback()

bool anchors_callback ( struct dom_node_internal * node,
void * ctx )

Callback for creating the anchors collection

Parameters
nodeThe dom_node_internal object
ctxThe dom_html_document object (void *)
Returns
DOM_NO_ERR on success, appropriate dom_exception on failure.

◆ applet_callback()

bool applet_callback ( struct dom_node_internal * node,
void * ctx )

◆ applets_callback()

bool applets_callback ( struct dom_node_internal * node,
void * ctx )

Callback for creating the applets collection

Parameters
nodeThe dom_node_internal object
ctxThe dom_html_document object (void *)
Returns
true if node is an applet object

◆ images_callback()

bool images_callback ( struct dom_node_internal * node,
void * ctx )

Callback for creating the images collection

Parameters
nodeThe dom_node_internal object
ctxThe dom_html_document object (void *)
Returns
DOM_NO_ERR on success, appropriate dom_exception on failure.

◆ links_callback()

bool links_callback ( struct dom_node_internal * node,
void * ctx )

Callback for creating the links collection

Parameters
nodeThe dom_node_internal object
ctxThe dom_html_document object (void *)
Returns
DOM_NO_ERR on success, appropriate dom_exception on failure.