summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrsk1994 <rsk1coder99@gmail.com>2014-06-03 01:13:00 (GMT)
committer Rupinder Singh Khokhar <rsk1coder99@gmail.com>2014-06-21 12:07:14 (GMT)
commit9282d5bb95cab38da9ada16a6972168aea44e88a (patch)
tree10ad1f4ed004eec136bf059e097caf44e0a8bf31
parentc040eaea0342f2cd29e29573763d85ec5919ff00 (diff)
downloadlibdom-9282d5bb95cab38da9ada16a6972168aea44e88a.tar.gz
libdom-9282d5bb95cab38da9ada16a6972168aea44e88a.tar.bz2
Style Element
-rw-r--r--Makefile2
-rw-r--r--include/dom/dom.h1
-rw-r--r--include/dom/html/html_isindex_element.h5
-rw-r--r--include/dom/html/html_style_element.h13
-rw-r--r--src/html/TODO2
-rw-r--r--src/html/html_document.c4
-rw-r--r--src/html/html_document_strings.h1
-rw-r--r--src/html/html_style_element.c81
-rw-r--r--src/html/html_style_element.h2
-rw-r--r--test/testcases/tests/level1/html/HTMLBaseElement01.xml (copied from test/testcases/tests/level1/html/HTMLStyleElement01.xml.kfail)84
-rw-r--r--test/testcases/tests/level1/html/HTMLBaseElement02.xml (copied from test/testcases/tests/level1/html/HTMLStyleElement01.xml.kfail)24
-rw-r--r--test/testcases/tests/level1/html/HTMLStyleElement01.xml (renamed from test/testcases/tests/level1/html/HTMLStyleElement01.xml.kfail)0
-rw-r--r--test/testcases/tests/level1/html/HTMLStyleElement02.xml (renamed from test/testcases/tests/level1/html/HTMLStyleElement02.xml.kfail)0
-rw-r--r--test/testcases/tests/level1/html/HTMLStyleElement03.xml (renamed from test/testcases/tests/level1/html/HTMLStyleElement03.xml.kfail)0
14 files changed, 164 insertions, 55 deletions
diff --git a/Makefile b/Makefile
index adb8d59..9b47c36 100644
--- a/Makefile
+++ b/Makefile
@@ -129,6 +129,8 @@ INSTALL_ITEMS := $(INSTALL_ITEMS) $(I):$(Is)/html_tablecol_element.h
INSTALL_ITEMS := $(INSTALL_ITEMS) $(I):$(Is)/html_tablesection_element.h
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) /$(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 2c312f4..68ae227 100644
--- a/include/dom/dom.h
+++ b/include/dom/dom.h
@@ -89,6 +89,7 @@
#include <dom/html/html_table_element.h>
#include <dom/html/html_tablerow_element.h>
#include <dom/html/html_base_element.h>
+#include <dom/html/html_style_element.h>
/* DOM Events header */
#include <dom/events/events.h>
diff --git a/include/dom/html/html_isindex_element.h b/include/dom/html/html_isindex_element.h
index 4961ccc..966b2d2 100644
--- a/include/dom/html/html_isindex_element.h
+++ b/include/dom/html/html_isindex_element.h
@@ -22,5 +22,10 @@ typedef struct dom_html_isindex_element dom_html_isindex_element;
dom_exception dom_html_isindex_element_get_form(dom_html_isindex_element *ele,
struct dom_html_form_element **form);
+dom_exception dom_html_isindex_element_get_prompt(dom_html_isindex_element *ele,
+ dom_string **prompt);
+
+dom_exception dom_html_isindex_element_set_prompt(dom_html_isindex_element *ele,
+ dom_string *prompt);
#endif
diff --git a/include/dom/html/html_style_element.h b/include/dom/html/html_style_element.h
index 868a043..5b3cd41 100644
--- a/include/dom/html/html_style_element.h
+++ b/include/dom/html/html_style_element.h
@@ -10,6 +10,7 @@
#include <stdbool.h>
#include <dom/core/exceptions.h>
+#include <dom/core/string.h>
typedef struct dom_html_style_element dom_html_style_element;
@@ -19,5 +20,17 @@ dom_exception dom_html_style_element_get_disabled(dom_html_style_element *ele,
dom_exception dom_html_style_element_set_disabled(dom_html_style_element *ele,
bool disabled);
+dom_exception dom_html_style_element_get_media(dom_html_style_element *ele,
+ dom_string **media);
+
+dom_exception dom_html_style_element_set_media(dom_html_style_element *ele,
+ dom_string *media);
+
+dom_exception dom_html_style_element_get_type(dom_html_style_element *ele,
+ dom_string **type);
+
+dom_exception dom_html_style_element_set_type(dom_html_style_element *ele,
+ dom_string *type);
+
#endif
diff --git a/src/html/TODO b/src/html/TODO
index 97eab8e..d817e68 100644
--- a/src/html/TODO
+++ b/src/html/TODO
@@ -9,7 +9,7 @@ HTMLTitleElement html_title_element DONE
HTMLMetaElement html_meta_element DONE
HTMLBaseElement html_base_element DONE
HTMLIsIndexElement html_isindex_element MISSING
-HTMLStyleElement html_style_element MISSING
+HTMLStyleElement html_style_element DONE
HTMLBodyElement html_body_element MISSING
HTMLFormElement html_form_element DONE
HTMLSelectElement html_select_element MISSING
diff --git a/src/html/html_document.c b/src/html/html_document.c
index 25abca3..0e39f77 100644
--- a/src/html/html_document.c
+++ b/src/html/html_document.c
@@ -56,6 +56,7 @@
#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 "core/attr.h"
#include "core/string.h"
@@ -361,6 +362,9 @@ _dom_html_document_create_element_internal(dom_html_document *html,
} else if (dom_string_caseless_isequal(tag_name, html->memoised[hds_TD])) {
exc = _dom_html_table_row_element_create(html, namespace, prefix,
(dom_html_table_row_element **) result);
+ } 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 {
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 8ded892..5d5ddaf 100644
--- a/src/html/html_document_strings.h
+++ b/src/html/html_document_strings.h
@@ -105,6 +105,7 @@ HTML_DOCUMENT_STRINGS_ACTION1(scope)
HTML_DOCUMENT_STRINGS_ACTION1(frame)
HTML_DOCUMENT_STRINGS_ACTION1(rules)
HTML_DOCUMENT_STRINGS_ACTION1(summary)
+HTML_DOCUMENT_STRINGS_ACTION1(prompt)
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_style_element.c b/src/html/html_style_element.c
index 98eb79b..3b295f1 100644
--- a/src/html/html_style_element.c
+++ b/src/html/html_style_element.c
@@ -8,6 +8,7 @@
#include <stdlib.h>
#include "html/html_style_element.h"
+#include "html/html_document.h"
#include "core/node.h"
#include "utils/utils.h"
@@ -54,13 +55,20 @@ dom_exception _dom_html_style_element_initialise(struct dom_html_document *doc,
struct dom_html_style_element *ele)
{
dom_string *name = NULL;
+ dom_string *media_default = NULL;
dom_exception err;
err = dom_string_create((const uint8_t *) "STYLE", SLEN("STYLE"),
&name);
if (err != DOM_NO_ERR)
return err;
+
+ err = dom_string_create((const uint8_t *) "screen", SLEN("screen"),
+ &media_default);
+ if (err != DOM_NO_ERR)
+ return err;
+ ele->media = media_default;
err = _dom_html_element_initialise(doc, &ele->base, name, NULL, NULL);
dom_string_unref(name);
@@ -119,9 +127,49 @@ dom_exception _dom_html_style_element_copy(dom_node_internal *old,
return _dom_html_element_copy(old, copy);
}
+
/*-----------------------------------------------------------------------*/
/* Public APIs */
+#define SIMPLE_GET(attr) \
+ dom_exception dom_html_style_element_get_##attr( \
+ dom_html_style_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_style_element_set_##attr( \
+ dom_html_style_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_GET_SET(type);
+SIMPLE_SET(media);
+
/**
* Get the disabled property
*
@@ -150,3 +198,36 @@ dom_exception dom_html_style_element_set_disabled(dom_html_style_element *ele,
SLEN("disabled"), disabled);
}
+/**
+ * Get the media property
+ *
+ * \param ele The dom_html_style_element object
+ * \param media The returned status
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception dom_html_style_element_get_media(dom_html_style_element *ele,
+ dom_string **media)
+{
+ 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_media], &has_value);
+ if(err !=DOM_NO_ERR)
+ return err;
+
+ if(has_value) {
+ return dom_element_get_attribute(ele,
+ doc->memoised[hds_media], media);
+ }
+
+ *media = ele->media;
+ if (*media != NULL)
+ dom_string_ref(*media);
+ return DOM_NO_ERR;
+
+}
+
diff --git a/src/html/html_style_element.h b/src/html/html_style_element.h
index e7a47e5..285da94 100644
--- a/src/html/html_style_element.h
+++ b/src/html/html_style_element.h
@@ -15,6 +15,8 @@
struct dom_html_style_element {
struct dom_html_element base;
/**< The base class */
+ dom_string *media;
+ /**< The default string value for the media attribute*/
};
/* Create a dom_html_style_element object */
diff --git a/test/testcases/tests/level1/html/HTMLStyleElement01.xml.kfail b/test/testcases/tests/level1/html/HTMLBaseElement01.xml
index 60c2e57..fa6eacc 100644
--- a/test/testcases/tests/level1/html/HTMLStyleElement01.xml.kfail
+++ b/test/testcases/tests/level1/html/HTMLBaseElement01.xml
@@ -1,42 +1,42 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?xml-stylesheet href="test-to-html.xsl" type="text/xml"?>
-
-<!--
-
-Copyright (c) 2001 World Wide Web Consortium,
-(Massachusetts Institute of Technology, Institut National de
-Recherche en Informatique et en Automatique, Keio University). All
-Rights Reserved. This program is distributed under the W3C's Software
-Intellectual Property License. This program is distributed in the
-hope that it will be useful, but WITHOUT ANY WARRANTY; without even
-the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-PURPOSE.
-
-See W3C License http://www.w3.org/Consortium/Legal/ for more details.
-
--->
-<!DOCTYPE test SYSTEM "dom1.dtd">
-<test xmlns="http://www.w3.org/2001/DOM-Test-Suite/Level-1" name="HTMLStyleElement01">
-<metadata>
-<title>HTMLStyleElement01</title>
-<creator>NIST</creator>
-<description>
- The disabled attribute enables/disables the stylesheet.
-
- Retrieve the disabled attribute and examine its value.
-</description>
-<contributor>Mary Brady</contributor>
-<date qualifier="created">2002-02-22</date>
-<subject resource="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-51162010"/>
-</metadata>
-<var name="nodeList" type="NodeList"/>
-<var name="testNode" type="Node"/>
-<var name="vdisabled" type="boolean" />
-<var name="doc" type="Document"/>
-<load var="doc" href="style" willBeModified="false"/>
-<getElementsByTagName interface="Document" obj="doc" var="nodeList" tagname='"style"'/>
-<assertSize collection="nodeList" size="1" id="Asize"/>
-<item interface="NodeList" obj="nodeList" var="testNode" index="0"/>
-<disabled interface="HTMLStyleElement" obj="testNode" var="vdisabled"/>
-<assertFalse actual="vdisabled" id="disabledLink"/>
-</test>
+<?xml version="1.0" encoding="UTF-8"?>
+<?xml-stylesheet href="test-to-html.xsl" type="text/xml"?>
+
+<!--
+
+Copyright (c) 2001-2004 World Wide Web Consortium,
+(Massachusetts Institute of Technology, Institut National de
+Recherche en Informatique et en Automatique, Keio University). All
+Rights Reserved. This program is distributed under the W3C's Software
+Intellectual Property License. This program is distributed in the
+hope that it will be useful, but WITHOUT ANY WARRANTY; without even
+the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+PURPOSE.
+
+See W3C License http://www.w3.org/Consortium/Legal/ for more details.
+
+-->
+<!DOCTYPE test SYSTEM "dom1.dtd">
+<test xmlns="http://www.w3.org/2001/DOM-Test-Suite/Level-1" name="HTMLBaseElement01">
+<metadata>
+<title>HTMLBaseElement01</title>
+<creator>NIST</creator>
+<description>
+ The href attribute specifies the base URI.
+
+ Retrieve the href attribute and examine its value.
+</description>
+<contributor>Mary Brady</contributor>
+<date qualifier="created">2002-02-22</date>
+<subject resource="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-65382887"/>
+</metadata>
+<var name="nodeList" type="NodeList"/>
+<var name="testNode" type="Node"/>
+<var name="vhref" type="DOMString" />
+<var name="doc" type="Document"/>
+<load var="doc" href="base" willBeModified="false"/>
+<getElementsByTagName interface="Document" obj="doc" var="nodeList" tagname='"base"'/>
+<assertSize collection="nodeList" size="1" id="Asize"/>
+<item interface="NodeList" obj="nodeList" var="testNode" index="0"/>
+<href interface="HTMLBaseElement" obj="testNode" var="vhref"/>
+<assertEquals actual="vhref" expected='"about:blank"' id="hrefLink" ignoreCase="false"/>
+</test>
diff --git a/test/testcases/tests/level1/html/HTMLStyleElement01.xml.kfail b/test/testcases/tests/level1/html/HTMLBaseElement02.xml
index 60c2e57..d2a20a5 100644
--- a/test/testcases/tests/level1/html/HTMLStyleElement01.xml.kfail
+++ b/test/testcases/tests/level1/html/HTMLBaseElement02.xml
@@ -16,27 +16,27 @@ See W3C License http://www.w3.org/Consortium/Legal/ for more details.
-->
<!DOCTYPE test SYSTEM "dom1.dtd">
-<test xmlns="http://www.w3.org/2001/DOM-Test-Suite/Level-1" name="HTMLStyleElement01">
+<test xmlns="http://www.w3.org/2001/DOM-Test-Suite/Level-1" name="HTMLBaseElement02">
<metadata>
-<title>HTMLStyleElement01</title>
+<title>HTMLBaseElement02</title>
<creator>NIST</creator>
<description>
- The disabled attribute enables/disables the stylesheet.
+ The target attribute specifies the default target frame.
- Retrieve the disabled attribute and examine its value.
+ Retrieve the target attribute and examine its value.
</description>
-<contributor>Mary Brady</contributor>
-<date qualifier="created">2002-02-22</date>
-<subject resource="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-51162010"/>
+<contributor>Rick Rivello</contributor>
+<date qualifier="created">2002-07-18</date>
+<subject resource="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-73844298"/>
</metadata>
<var name="nodeList" type="NodeList"/>
<var name="testNode" type="Node"/>
-<var name="vdisabled" type="boolean" />
+<var name="vtarget" type="DOMString" />
<var name="doc" type="Document"/>
-<load var="doc" href="style" willBeModified="false"/>
-<getElementsByTagName interface="Document" obj="doc" var="nodeList" tagname='"style"'/>
+<load var="doc" href="base2" willBeModified="false"/>
+<getElementsByTagName interface="Document" obj="doc" var="nodeList" tagname='"base"'/>
<assertSize collection="nodeList" size="1" id="Asize"/>
<item interface="NodeList" obj="nodeList" var="testNode" index="0"/>
-<disabled interface="HTMLStyleElement" obj="testNode" var="vdisabled"/>
-<assertFalse actual="vdisabled" id="disabledLink"/>
+<target interface="HTMLBaseElement" obj="testNode" var="vtarget"/>
+<assertEquals actual="vtarget" expected='"Frame1"' id="targetLink" ignoreCase="false"/>
</test>
diff --git a/test/testcases/tests/level1/html/HTMLStyleElement01.xml.kfail b/test/testcases/tests/level1/html/HTMLStyleElement01.xml
index 60c2e57..60c2e57 100644
--- a/test/testcases/tests/level1/html/HTMLStyleElement01.xml.kfail
+++ b/test/testcases/tests/level1/html/HTMLStyleElement01.xml
diff --git a/test/testcases/tests/level1/html/HTMLStyleElement02.xml.kfail b/test/testcases/tests/level1/html/HTMLStyleElement02.xml
index 727df54..727df54 100644
--- a/test/testcases/tests/level1/html/HTMLStyleElement02.xml.kfail
+++ b/test/testcases/tests/level1/html/HTMLStyleElement02.xml
diff --git a/test/testcases/tests/level1/html/HTMLStyleElement03.xml.kfail b/test/testcases/tests/level1/html/HTMLStyleElement03.xml
index 54394e3..54394e3 100644
--- a/test/testcases/tests/level1/html/HTMLStyleElement03.xml.kfail
+++ b/test/testcases/tests/level1/html/HTMLStyleElement03.xml