diff options
author | John Mark Bell <jmb@netsurf-browser.org> | 2010-08-30 13:06:19 +0000 |
---|---|---|
committer | John Mark Bell <jmb@netsurf-browser.org> | 2010-08-30 13:06:19 +0000 |
commit | b657c277f517f4ab0a4da21e4f8c4cb6f8f53013 (patch) | |
tree | 4ce25caee01c0a2a2ebbe052999b5eb8a2fbe2e3 /include/dom/core | |
parent | 229af12d7ab2c071a6888eb8ffc49bb0bbeb9ddd (diff) | |
download | libdom-b657c277f517f4ab0a4da21e4f8c4cb6f8f53013.tar.gz libdom-b657c277f517f4ab0a4da21e4f8c4cb6f8f53013.tar.bz2 |
Merge branches/struggleyb/libdom-html to trunk.
A few additional fixes to reduce the number of regressions to single figures.
svn path=/trunk/dom/; revision=10724
Diffstat (limited to 'include/dom/core')
-rw-r--r-- | include/dom/core/attr.h | 46 | ||||
-rw-r--r-- | include/dom/core/exceptions.h | 3 |
2 files changed, 48 insertions, 1 deletions
diff --git a/include/dom/core/attr.h b/include/dom/core/attr.h index 7ac3956..f5105f7 100644 --- a/include/dom/core/attr.h +++ b/include/dom/core/attr.h @@ -21,6 +21,17 @@ struct dom_string; typedef struct dom_attr dom_attr; +/** + * The attribute type + */ +typedef enum { + DOM_ATTR_UNSET = 0, + DOM_ATTR_STRING, + DOM_ATTR_BOOL, + DOM_ATTR_SHORT, + DOM_ATTR_INTEGER +} dom_attr_type; + /* DOM Attr vtable */ typedef struct dom_attr_vtable { struct dom_node_vtable base; @@ -102,4 +113,39 @@ static inline dom_exception dom_attr_is_id(struct dom_attr *attr, bool *result) #define dom_attr_is_id(a, r) dom_attr_is_id((struct dom_attr *) (a), \ (bool *) (r)) +/*-----------------------------------------------------------------------*/ +/** + * Following are our implementation specific APIs. + * + * These APIs are defined for the purpose that there are some attributes in + * HTML and other DOM module whose type is not DOMString, but unsigned long or + * boolean, for those types of attributes, clients should call one of the + * following APIs to set it. + * + * When an Attr node is created, its type is unset and it can be turned into + * any of the four types. Once the type is fixed by calling any of the four + * APIs: + * dom_attr_set_value + * dom_attr_set_integer + * dom_attr_set_short + * dom_attr_set_bool + * it can't be modified in future. + * + * For integer/short/bool type of attributes, we provide no string + * repensentation of them, so when you call dom_attr_get_value on these + * three type of attribute nodes, you will always get a empty dom_string. + * If you want to do something with Attr node, you must know its type + * firstly by calling dom_attr_get_type before you decide to call other + * dom_attr_get_* functions. + */ +dom_attr_type dom_attr_get_type(dom_attr *a); +dom_exception dom_attr_get_integer(dom_attr *a, unsigned long *value); +dom_exception dom_attr_set_integer(dom_attr *a, unsigned long value); +dom_exception dom_attr_get_short(dom_attr *a, unsigned short *value); +dom_exception dom_attr_set_short(dom_attr *a, unsigned short value); +dom_exception dom_attr_get_bool(dom_attr *a, bool *value); +dom_exception dom_attr_set_bool(dom_attr *a, bool value); +/* Make a attribute node readonly */ +void dom_attr_mark_readonly(dom_attr *a); + #endif diff --git a/include/dom/core/exceptions.h b/include/dom/core/exceptions.h index e128016..04c7f18 100644 --- a/include/dom/core/exceptions.h +++ b/include/dom/core/exceptions.h @@ -44,7 +44,8 @@ typedef enum { DOM_UNSPECIFIED_EVENT_TYPE_ERR = DOM_EXCEPTION_CLASS_EVENT + 0, DOM_DISPATCH_REQUEST_ERR = DOM_EXCEPTION_CLASS_EVENT + 1, - DOM_NO_MEM_ERR = DOM_EXCEPTION_CLASS_INTERNAL + 0 + DOM_NO_MEM_ERR = DOM_EXCEPTION_CLASS_INTERNAL + 0, + DOM_ATTR_WRONG_TYPE_ERR = DOM_EXCEPTION_CLASS_INTERNAL + 1 /* our own internal error */ } dom_exception; |