summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrsk1994 <rsk1coder99@gmail.com>2014-06-05 15:36:09 (GMT)
committer Rupinder Singh Khokhar <rsk1coder99@gmail.com>2014-06-21 12:07:14 (GMT)
commit6bff7533b61a5d376d9f08a7a62d185a8e7155b3 (patch)
tree4d17ed4201bdc5ad8081d4bae545bd4000cbd8c4
parentdba6ae49a546cc8da44d7586cb2b84142d44850d (diff)
downloadlibdom-6bff7533b61a5d376d9f08a7a62d185a8e7155b3.tar.gz
libdom-6bff7533b61a5d376d9f08a7a62d185a8e7155b3.tar.bz2
FrameSet Element
-rw-r--r--Makefile1
-rw-r--r--include/dom/dom.h1
-rw-r--r--include/dom/html/html_frameset_element.h22
-rw-r--r--src/html/Makefile4
-rw-r--r--src/html/html_document.c4
-rw-r--r--src/html/html_document_strings.h2
-rw-r--r--src/html/html_frameset_element.c229
-rw-r--r--src/html/html_frameset_element.h46
-rw-r--r--test/testcases/tests/level1/html/HTMLFrameSetElement01.xml (renamed from test/testcases/tests/level1/html/HTMLFrameSetElement01.xml.kfail)0
-rw-r--r--test/testcases/tests/level1/html/HTMLFrameSetElement02.xml (renamed from test/testcases/tests/level1/html/HTMLFrameSetElement02.xml.kfail)0
10 files changed, 307 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 9b47c36..2de8d0c 100644
--- a/Makefile
+++ b/Makefile
@@ -131,6 +131,7 @@ INSTALL_ITEMS := $(INSTALL_ITEMS) $(I):$(Is)/html_table_element.h
INSTALL_ITEMS := $(INSTALL_ITEMS) $(I):$(Is)/html_tablerow_element.h
INSTALL_ITEMS := $(INSTALL_ITEMS) $(I):$(Is)/html_base_element.h
INSTALL_ITEMS := $(INSTALL_ITEMS) $(I):$(Is)/html_style_element.h
+INSTALL_ITEMS := $(INSTALL_ITEMS) $(I):$(Is)/html_frameset_element.h
INSTALL_ITEMS := $(INSTALL_ITEMS) /$(LIBDIR)/pkgconfig:lib$(COMPONENT).pc.in
INSTALL_ITEMS := $(INSTALL_ITEMS) /$(LIBDIR):$(OUTPUT)
diff --git a/include/dom/dom.h b/include/dom/dom.h
index 68ae227..376ef14 100644
--- a/include/dom/dom.h
+++ b/include/dom/dom.h
@@ -90,6 +90,7 @@
#include <dom/html/html_tablerow_element.h>
#include <dom/html/html_base_element.h>
#include <dom/html/html_style_element.h>
+#include <dom/html/html_frameset_element.h>
/* DOM Events header */
#include <dom/events/events.h>
diff --git a/include/dom/html/html_frameset_element.h b/include/dom/html/html_frameset_element.h
index 2e182d5..c0de3b4 100644
--- a/include/dom/html/html_frameset_element.h
+++ b/include/dom/html/html_frameset_element.h
@@ -3,5 +3,27 @@
* Licensed under the MIT License,
* http://www.opensource.org/licenses/mit-license.php
* Copyright 2009 Bo Yang <struggleyb.nku@gmail.com>
+ * Copyright 2014 Rupinder Singh Khokhar <rsk1coder99@gmail.com>
*/
+#ifndef dom_html_frame_set_element_h_
+#define dom_html_frame_set_element_h_
+#include <stdbool.h>
+#include <dom/core/exceptions.h>
+#include <dom/core/string.h>
+
+typedef struct dom_html_frame_set_element dom_html_frame_set_element;
+
+dom_exception dom_html_frame_set_element_get_rows(
+ dom_html_frame_set_element *element, dom_string **rows);
+
+dom_exception dom_html_frame_set_element_set_rows(
+ dom_html_frame_set_element *element, dom_string *rows);
+
+dom_exception dom_html_frame_set_element_set_cols(
+ dom_html_frame_set_element *ele, dom_string *cols);
+
+dom_exception dom_html_frame_set_element_get_cols(
+ dom_html_frame_set_element *ele, dom_string **cols);
+
+#endif
diff --git a/src/html/Makefile b/src/html/Makefile
index 2cb85d9..a9532cd 100644
--- a/src/html/Makefile
+++ b/src/html/Makefile
@@ -17,10 +17,10 @@ DIR_SOURCES := \
html_param_element.c html_applet_element.c html_area_element.c \
html_map_element.c html_script_element.c html_tablecaption_element.c \
html_tablecell_element.c html_tablecol_element.c html_tablesection_element.c \
- html_table_element.c html_tablerow_element.c
+ html_table_element.c html_tablerow_element.c html_frameset_element.c
UNINMPLEMENTED_SOURCES := \
- html_frameset_element.c html_isindex_element.c \
+ html_isindex_element.c \
html_frame_element.c html_iframe_element.c
include $(NSBUILD)/Makefile.subdir
diff --git a/src/html/html_document.c b/src/html/html_document.c
index 0e39f77..a4ba62b 100644
--- a/src/html/html_document.c
+++ b/src/html/html_document.c
@@ -57,6 +57,7 @@
#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 "core/attr.h"
#include "core/string.h"
@@ -365,6 +366,9 @@ _dom_html_document_create_element_internal(dom_html_document *html,
} else if (dom_string_caseless_isequal(tag_name, html->memoised[hds_STYLE])) {
exc = _dom_html_style_element_create(html,
(dom_html_style_element **) result);
+ } else if (dom_string_caseless_isequal(tag_name, html->memoised[hds_FRAMESET])) {
+ exc = _dom_html_frame_set_element_create(html, namespace, prefix,
+ (dom_html_frame_set_element **) result);
} else {
exc = _dom_html_element_create(html, tag_name, namespace,
prefix, result);
diff --git a/src/html/html_document_strings.h b/src/html/html_document_strings.h
index 5d5ddaf..10ec80d 100644
--- a/src/html/html_document_strings.h
+++ b/src/html/html_document_strings.h
@@ -106,6 +106,8 @@ HTML_DOCUMENT_STRINGS_ACTION1(frame)
HTML_DOCUMENT_STRINGS_ACTION1(rules)
HTML_DOCUMENT_STRINGS_ACTION1(summary)
HTML_DOCUMENT_STRINGS_ACTION1(prompt)
+HTML_DOCUMENT_STRINGS_ACTION1(rows)
+HTML_DOCUMENT_STRINGS_ACTION1(cols)
HTML_DOCUMENT_STRINGS_ACTION(tab_index,tabindex)
HTML_DOCUMENT_STRINGS_ACTION(html_for,for)
HTML_DOCUMENT_STRINGS_ACTION(date_time,datetime)
diff --git a/src/html/html_frameset_element.c b/src/html/html_frameset_element.c
index 2e182d5..b096156 100644
--- a/src/html/html_frameset_element.c
+++ b/src/html/html_frameset_element.c
@@ -3,5 +3,234 @@
* Licensed under the MIT License,
* http://www.opensource.org/licenses/mit-license.php
* Copyright 2009 Bo Yang <struggleyb.nku@gmail.com>
+ * Copyright 2014 Rupinder Singh Khokhar<rsk1coder99@gmail.com>
*/
+#include <assert.h>
+#include <stdlib.h>
+#include <dom/html/html_frameset_element.h>
+
+#include "html/html_document.h"
+#include "html/html_frameset_element.h"
+
+#include "core/node.h"
+#include "core/attr.h"
+#include "utils/utils.h"
+
+static struct dom_element_protected_vtable _protect_vtable = {
+ {
+ DOM_NODE_PROTECT_VTABLE_HTML_FRAME_SET_ELEMENT
+ },
+ DOM_HTML_FRAME_SET_ELEMENT_PROTECT_VTABLE
+};
+
+/**
+ * Create a dom_html_frame_set_element object
+ *
+ * \param doc The document object
+ * \param ele The returned element object
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception _dom_html_frame_set_element_create(struct dom_html_document *doc,
+ dom_string *namespace, dom_string *prefix,
+ struct dom_html_frame_set_element **ele)
+{
+ struct dom_node_internal *node;
+
+ *ele = malloc(sizeof(dom_html_frame_set_element));
+ if (*ele == NULL)
+ return DOM_NO_MEM_ERR;
+
+ /* Set up vtables */
+ node = (struct dom_node_internal *) *ele;
+ node->base.vtable = &_dom_html_element_vtable;
+ node->vtable = &_protect_vtable;
+
+ return _dom_html_frame_set_element_initialise(doc, namespace, prefix, *ele);
+}
+
+/**
+ * Initialise a dom_html_frame_set_element object
+ *
+ * \param doc The document object
+ * \param ele The dom_html_frame_set_element object
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception _dom_html_frame_set_element_initialise(struct dom_html_document *doc,
+ dom_string *namespace, dom_string *prefix,
+ struct dom_html_frame_set_element *ele)
+{
+ dom_string *cols_rows_default = NULL;
+ dom_exception err;
+ err = dom_string_create((const uint8_t *) "100%", SLEN("100%"), &cols_rows_default);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ err = _dom_html_element_initialise(doc, &ele->base,
+ doc->memoised[hds_FRAMESET],
+ namespace, prefix);
+ ele->cols_rows_default = cols_rows_default;
+ return err;
+}
+
+/**
+ * Finalise a dom_html_frame_set_element object
+ *
+ * \param ele The dom_html_frame_set_element object
+ */
+void _dom_html_frame_set_element_finalise(struct dom_html_frame_set_element *ele)
+{
+ _dom_html_element_finalise(&ele->base);
+}
+
+/**
+ * Destroy a dom_html_frame_set_element object
+ *
+ * \param ele The dom_html_frame_set_element object
+ */
+void _dom_html_frame_set_element_destroy(struct dom_html_frame_set_element *ele)
+{
+ _dom_html_frame_set_element_finalise(ele);
+ free(ele);
+}
+
+/*------------------------------------------------------------------------*/
+/* The protected virtual functions */
+
+/* The virtual function used to parse attribute value, see src/core/element.c
+ * for detail */
+dom_exception _dom_html_frame_set_element_parse_attribute(dom_element *ele,
+ dom_string *name, dom_string *value,
+ dom_string **parsed)
+{
+ UNUSED(ele);
+ UNUSED(name);
+
+ dom_string_ref(value);
+ *parsed = value;
+
+ return DOM_NO_ERR;
+}
+
+/* The virtual destroy function, see src/core/node.c for detail */
+void _dom_virtual_html_frame_set_element_destroy(dom_node_internal *node)
+{
+ _dom_html_frame_set_element_destroy((struct dom_html_frame_set_element *) node);
+}
+
+/* The virtual copy function, see src/core/node.c for detail */
+dom_exception _dom_html_frame_set_element_copy(dom_node_internal *old,
+ dom_node_internal **copy)
+{
+ return _dom_html_element_copy(old, copy);
+}
+
+/*-----------------------------------------------------------------------*/
+/* API functions */
+
+#define SIMPLE_GET(attr) \
+ dom_exception dom_html_frame_set_element_get_##attr( \
+ dom_html_frame_set_element *element, \
+ dom_string **attr) \
+ { \
+ dom_exception ret; \
+ 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, attr); \
+ \
+ return ret; \
+ }
+#define SIMPLE_SET(attr) \
+dom_exception dom_html_frame_set_element_set_##attr( \
+ dom_html_frame_set_element *element, \
+ dom_string *attr) \
+ { \
+ dom_exception ret; \
+ 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, attr); \
+ \
+ return ret; \
+ }
+
+#define SIMPLE_GET_SET(attr) SIMPLE_GET(attr) SIMPLE_SET(attr)
+
+SIMPLE_SET(rows);
+SIMPLE_SET(cols);
+
+/**
+ * Get the rows property
+ *
+ * \param ele The dom_html_frame_set_element object
+ * \param rows The returned status
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception dom_html_frame_set_element_get_rows(
+ dom_html_frame_set_element *ele,
+ dom_string **rows)
+{
+ dom_html_document *doc;
+ bool has_value = false;
+ dom_exception err;
+
+ doc = (dom_html_document *) ((dom_node_internal *) ele)->owner;
+
+ err = dom_element_has_attribute(ele,
+ doc->memoised[hds_rows], &has_value);
+ if(err !=DOM_NO_ERR)
+ return err;
+
+ if(has_value) {
+ return dom_element_get_attribute(ele,
+ doc->memoised[hds_rows], rows);
+ }
+
+ *rows = ele->cols_rows_default;
+ if (*rows != NULL)
+ dom_string_ref(*rows);
+
+ return DOM_NO_ERR;
+}
+
+/**
+ * Get the cols property
+ *
+ * \param ele The dom_html_frame_set_element object
+ * \param cols The returned status
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception dom_html_frame_set_element_get_cols(
+ dom_html_frame_set_element *ele,
+ dom_string **cols)
+{
+ dom_html_document *doc;
+ bool has_value = false;
+ dom_exception err;
+
+ doc = (dom_html_document *) ((dom_node_internal *) ele)->owner;
+
+ err = dom_element_has_attribute(ele,
+ doc->memoised[hds_cols], &has_value);
+ if(err !=DOM_NO_ERR)
+ return err;
+
+ if(has_value) {
+ return dom_element_get_attribute(ele,
+ doc->memoised[hds_cols], cols);
+ }
+
+ *cols = ele->cols_rows_default;
+ if (*cols != NULL)
+ dom_string_ref(*cols);
+ return DOM_NO_ERR;
+}
diff --git a/src/html/html_frameset_element.h b/src/html/html_frameset_element.h
index 2e182d5..fd1c255 100644
--- a/src/html/html_frameset_element.h
+++ b/src/html/html_frameset_element.h
@@ -3,5 +3,51 @@
* Licensed under the MIT License,
* http://www.opensource.org/licenses/mit-license.php
* Copyright 2009 Bo Yang <struggleyb.nku@gmail.com>
+ * Copyright 2014 Rupinder Singh Khokhar <rsk1coder99@gmail.com>
*/
+#ifndef dom_internal_html_frame_set_element_h_
+#define dom_internal_html_frame_set_element_h_
+
+#include <dom/html/html_frameset_element.h>
+#include "html/html_element.h"
+
+
+struct dom_html_frame_set_element {
+ struct dom_html_element base;
+ /**< The base class */
+ dom_string *cols_rows_default;
+};
+
+/* Create a dom_html_frame_set_element object */
+dom_exception _dom_html_frame_set_element_create(struct dom_html_document *doc,
+ dom_string *namespace, dom_string *prefix,
+ struct dom_html_frame_set_element **ele);
+
+/* Initialise a dom_html_frame_set_element object */
+dom_exception _dom_html_frame_set_element_initialise(struct dom_html_document *doc,
+ dom_string *namespace, dom_string *prefix,
+ struct dom_html_frame_set_element *ele);
+
+/* Finalise a dom_html_frame_set_element object */
+void _dom_html_frame_set_element_finalise(struct dom_html_frame_set_element *ele);
+
+/* Destroy a dom_html_frame_set_element object */
+void _dom_html_frame_set_element_destroy(struct dom_html_frame_set_element *ele);
+
+/* The protected virtual functions */
+dom_exception _dom_html_frame_set_element_parse_attribute(dom_element *ele,
+ dom_string *name, dom_string *value,
+ dom_string **parsed);
+void _dom_virtual_html_frame_set_element_destroy(dom_node_internal *node);
+dom_exception _dom_html_frame_set_element_copy(dom_node_internal *old,
+ dom_node_internal **copy);
+
+#define DOM_HTML_FRAME_SET_ELEMENT_PROTECT_VTABLE \
+ _dom_html_frame_set_element_parse_attribute
+
+#define DOM_NODE_PROTECT_VTABLE_HTML_FRAME_SET_ELEMENT \
+ _dom_virtual_html_frame_set_element_destroy, \
+ _dom_html_frame_set_element_copy
+
+#endif
diff --git a/test/testcases/tests/level1/html/HTMLFrameSetElement01.xml.kfail b/test/testcases/tests/level1/html/HTMLFrameSetElement01.xml
index 18e5ff5..18e5ff5 100644
--- a/test/testcases/tests/level1/html/HTMLFrameSetElement01.xml.kfail
+++ b/test/testcases/tests/level1/html/HTMLFrameSetElement01.xml
diff --git a/test/testcases/tests/level1/html/HTMLFrameSetElement02.xml.kfail b/test/testcases/tests/level1/html/HTMLFrameSetElement02.xml
index e598cef..e598cef 100644
--- a/test/testcases/tests/level1/html/HTMLFrameSetElement02.xml.kfail
+++ b/test/testcases/tests/level1/html/HTMLFrameSetElement02.xml