libdom
Loading...
Searching...
No Matches
Macros | Functions | Variables
html_element.c File Reference
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "html/html_document.h"
#include "html/html_element.h"
#include "core/node.h"
#include "core/attr.h"
#include "core/document.h"
#include "utils/utils.h"

Macros

#define SIMPLE_GET_SET(fattr, attr)
 

Functions

dom_exception _dom_html_element_create (struct dom_html_element_create_params *params, struct dom_html_element **result)
 
dom_exception _dom_html_element_initialise (struct dom_html_element_create_params *params, struct dom_html_element *el)
 
void _dom_html_element_finalise (struct dom_html_element *ele)
 
void _dom_html_element_destroy (dom_node_internal *node)
 
dom_exception _dom_html_element_copy (dom_node_internal *old, dom_node_internal **copy)
 
dom_exception _dom_html_element_copy_internal (dom_html_element *old, dom_html_element *new)
 
dom_exception _dom_html_element_get_attribute (struct dom_element *element, dom_string *name, dom_string **value)
 
dom_exception _dom_html_element_set_attribute (struct dom_element *element, dom_string *name, dom_string *value)
 
dom_exception _dom_html_element_remove_attribute (struct dom_element *element, dom_string *name)
 
dom_exception _dom_html_element_has_attribute (struct dom_element *element, dom_string *name, bool *result)
 
dom_exception _dom_html_element_get_elements_by_tag_name (struct dom_element *element, dom_string *name, struct dom_nodelist **result)
 
dom_exception _dom_html_element_get_elements_by_tag_name_ns (struct dom_element *element, dom_string *namespace, dom_string *localname, struct dom_nodelist **result)
 
dom_exception _dom_html_element_get_tag_type (const struct dom_html_element *element, dom_html_element_type *type)
 
dom_exception dom_html_element_get_bool_property (dom_html_element *ele, const char *name, uint32_t len, bool *has)
 
dom_exception dom_html_element_set_bool_property (dom_html_element *ele, const char *name, uint32_t len, bool has)
 
dom_exception dom_html_element_get_int32_t_property (dom_html_element *ele, const char *name, uint32_t len, int32_t *value)
 
dom_exception dom_html_element_set_int32_t_property (dom_html_element *ele, const char *name, uint32_t len, uint32_t value)
 
dom_exception dom_html_element_get_dom_ulong_property (dom_html_element *ele, const char *name, uint32_t len, dom_ulong *value)
 
dom_exception dom_html_element_set_dom_ulong_property (dom_html_element *ele, const char *name, uint32_t len, dom_ulong value)
 

Variables

const struct dom_html_element_vtable _dom_html_element_vtable
 

Macro Definition Documentation

◆ SIMPLE_GET_SET

#define SIMPLE_GET_SET ( fattr,
attr )
Value:
dom_exception _dom_html_element_get_##fattr(dom_html_element *element, \
dom_string **fattr) \
{ \
dom_string *_memo_##attr; \
\
_memo_##attr = \
((struct dom_html_document *) \
((struct dom_node_internal *)element)->owner)->memoised[hds_##attr]; \
\
ret = dom_element_get_attribute(element, _memo_##attr, fattr); \
\
return ret; \
} \
\
dom_exception _dom_html_element_set_##fattr(dom_html_element *element, \
dom_string *fattr) \
{ \
dom_string *_memo_##attr; \
\
_memo_##attr = \
((struct dom_html_document *) \
((struct dom_node_internal *)element)->owner)->memoised[hds_##attr]; \
\
ret = dom_element_set_attribute(element, _memo_##attr, fattr); \
\
return ret; \
}
dom_exception
Definition exceptions.h:24
#define dom_element_get_attribute(e, n, v)
Definition element.h:117
#define dom_element_set_attribute(e, n, v)
Definition element.h:127
Definition html_document.h:19
Definition html_element.h:22
Definition node.h:54
Definition string.h:19

Function Documentation

◆ _dom_html_element_copy()

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

◆ _dom_html_element_copy_internal()

dom_exception _dom_html_element_copy_internal ( dom_html_element * old,
dom_html_element * new )

◆ _dom_html_element_create()

dom_exception _dom_html_element_create ( struct dom_html_element_create_params * params,
struct dom_html_element ** result )

◆ _dom_html_element_destroy()

void _dom_html_element_destroy ( dom_node_internal * node)

◆ _dom_html_element_finalise()

void _dom_html_element_finalise ( struct dom_html_element * ele)

◆ _dom_html_element_get_attribute()

dom_exception _dom_html_element_get_attribute ( struct dom_element * element,
dom_string * name,
dom_string ** value )

◆ _dom_html_element_get_elements_by_tag_name()

dom_exception _dom_html_element_get_elements_by_tag_name ( struct dom_element * element,
dom_string * name,
struct dom_nodelist ** result )

Retrieve a list of descendant elements of an element which match a given tag name (caselessly)

Parameters
elementThe root of the subtree to search
nameThe tag name to match (or "*" for all tags)
resultPointer to location to receive result
Returns
DOM_NO_ERR.

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

◆ _dom_html_element_get_elements_by_tag_name_ns()

dom_exception _dom_html_element_get_elements_by_tag_name_ns ( struct dom_element * element,
dom_string * namespace,
dom_string * localname,
struct dom_nodelist ** result )

Retrieve a list of descendant elements of an element which match a given namespace/localname pair, caselessly.

Parameters
elementThe root of the subtree to search
namespaceThe namespace URI to match (or "*" for all)
localnameThe local name to match (or "*" for all)
resultPointer to location to receive result
Returns
DOM_NO_ERR on success, DOM_NOT_SUPPORTED_ERR if the implementation does not support the feature "XML" and the language exposed through the Document does not support Namespaces.

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

Todo
ensure XML feature is supported

◆ _dom_html_element_get_tag_type()

dom_exception _dom_html_element_get_tag_type ( const struct dom_html_element * element,
dom_html_element_type * type )

Retrieve an HTML element's tag type.

Parameters
elementThe element to get the tag type of.
typeUpdated to the tag type of the element.
Returns
DOM_NO_ERR

Elements with non-standard tags will be DOM_HTML_ELEMENT_TYPE__UNKNOWN.

◆ _dom_html_element_has_attribute()

dom_exception _dom_html_element_has_attribute ( struct dom_element * element,
dom_string * name,
bool * result )

◆ _dom_html_element_initialise()

dom_exception _dom_html_element_initialise ( struct dom_html_element_create_params * params,
struct dom_html_element * el )

◆ _dom_html_element_remove_attribute()

dom_exception _dom_html_element_remove_attribute ( struct dom_element * element,
dom_string * name )

◆ _dom_html_element_set_attribute()

dom_exception _dom_html_element_set_attribute ( struct dom_element * element,
dom_string * name,
dom_string * value )

◆ dom_html_element_get_bool_property()

dom_exception dom_html_element_get_bool_property ( dom_html_element * ele,
const char * name,
uint32_t len,
bool * has )

Get the a bool property

Parameters
eleThe dom_html_element object
nameThe name of the attribute
lenThe length of ::name
hasThe returned status
Returns
DOM_NO_ERR on success, appropriate dom_exception on failure.

◆ dom_html_element_get_dom_ulong_property()

dom_exception dom_html_element_get_dom_ulong_property ( dom_html_element * ele,
const char * name,
uint32_t len,
dom_ulong * value )

Get the a dom_ulong property

Parameters
eleThe dom_html_element object
nameThe name of the attribute
lenThe length of ::name
valueThe returned value, or -1 if prop. not set
Returns
DOM_NO_ERR on success, appropriate dom_exception on failure.

◆ dom_html_element_get_int32_t_property()

dom_exception dom_html_element_get_int32_t_property ( dom_html_element * ele,
const char * name,
uint32_t len,
int32_t * value )

Get the a int32_t property

Parameters
eleThe dom_html_element object
nameThe name of the attribute
lenThe length of ::name
valueThe returned value, or -1 if prop. not set
Returns
DOM_NO_ERR on success, appropriate dom_exception on failure.

◆ dom_html_element_set_bool_property()

dom_exception dom_html_element_set_bool_property ( dom_html_element * ele,
const char * name,
uint32_t len,
bool has )

Set a bool property

Parameters
eleThe dom_html_element object
nameThe name of the attribute
lenThe length of ::name
hasThe status
Returns
DOM_NO_ERR on success, appropriate dom_exception on failure.

◆ dom_html_element_set_dom_ulong_property()

dom_exception dom_html_element_set_dom_ulong_property ( dom_html_element * ele,
const char * name,
uint32_t len,
dom_ulong value )

Set a dom_ulong property

Parameters
eleThe dom_html_element object
nameThe name of the attribute
lenThe length of ::name
valueThe value
Returns
DOM_NO_ERR on success, appropriate dom_exception on failure.

◆ dom_html_element_set_int32_t_property()

dom_exception dom_html_element_set_int32_t_property ( dom_html_element * ele,
const char * name,
uint32_t len,
uint32_t value )

Set a int32_t property

Parameters
eleThe dom_html_element object
nameThe name of the attribute
lenThe length of ::name
valueThe value
Returns
DOM_NO_ERR on success, appropriate dom_exception on failure.

Variable Documentation

◆ _dom_html_element_vtable

const struct dom_html_element_vtable _dom_html_element_vtable
Initial value:
= {
{
{
{
},
},
},
}
#define DOM_NODE_VTABLE_ELEMENT
Definition element.h:147
#define DOM_NODE_EVENT_TARGET_VTABLE
Definition node.h:188
#define DOM_ELEMENT_VTABLE_HTML_ELEMENT
Definition html_element.h:77
#define DOM_HTML_ELEMENT_VTABLE
Definition html_element.h:130