netsurf: branch master updated. release/3.1-270-g4488c8a
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/4488c8a2e40f27d25e675...
...commit http://git.netsurf-browser.org/netsurf.git/commit/4488c8a2e40f27d25e67542...
...tree http://git.netsurf-browser.org/netsurf.git/tree/4488c8a2e40f27d25e675429b...
The branch, master has been updated
via 4488c8a2e40f27d25e675429ba3ea89b367d5144 (commit)
from 8e29e517d59f0d04dd2d09c6b8760aa1236a1abf (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=4488c8a2e40f27d25e6...
commit 4488c8a2e40f27d25e675429ba3ea89b367d5144
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
fallback to old url creation behaviour if the IDNA host parse fails
diff --git a/test/Makefile b/test/Makefile
index acf9d4e..cf0f897 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -22,7 +22,7 @@ urldbtest_SRCS := content/urldb.c utils/url.c utils/utils.c utils/log.c \
urldbtest_CFLAGS := $(shell pkg-config --cflags libwapcaplet libdom) -O2
urldbtest_LDFLAGS := $(shell pkg-config --libs libwapcaplet libdom)
-nsurl_SRCS := utils/corestrings.c utils/log.c utils/nsurl.c test/nsurl.c
+nsurl_SRCS := utils/corestrings.c utils/log.c utils/nsurl.c utils/idna.c utils/utf8proc.c test/nsurl.c
nsurl_CFLAGS := $(shell pkg-config --cflags libwapcaplet libdom)
nsurl_LDFLAGS := $(shell pkg-config --libs libwapcaplet libdom)
diff --git a/test/nsurl.c b/test/nsurl.c
index 3e859d9..20774c4 100644
--- a/test/nsurl.c
+++ b/test/nsurl.c
@@ -141,6 +141,7 @@ static const struct test_pairs join_tests[] = {
{ " / ", "http://a/" },
{ " ? ", "http://a/b/c/d;p?" },
{ " h ", "http://a/b/c/h" },
+ { "http://<!--#echo var=", "http://<!--/#echo%20var="},
/* [1] Extra slash beyond rfc3986 5.4.1 example, since we're
* testing normalisation in addition to joining */
/* [2] Using the strict parsers option */
diff --git a/utils/nsurl.c b/utils/nsurl.c
index 7e8792c..eeb411d 100644
--- a/utils/nsurl.c
+++ b/utils/nsurl.c
@@ -685,6 +685,7 @@ static nserror nsurl__create_from_section(const char * const url_s,
char *pos_norm,
struct nsurl_components *url)
{
+ nserror ret;
int ascii_offset;
int start = 0;
int end = 0;
@@ -961,14 +962,20 @@ static nserror nsurl__create_from_section(const char * const url_s,
/* host */
/* Encode host according to IDNA2008 */
- if (idna_encode(norm_start, length, &host, &host_len) == NSERROR_OK) {
+ ret = idna_encode(norm_start, length, &host, &host_len);
+ if (ret == NSERROR_OK) {
+ /* valid idna encoding */
if (lwc_intern_string(host, host_len,
&url->host) != lwc_error_ok) {
return NSERROR_NOMEM;
}
free(host);
} else {
- return NSERROR_BAD_URL;
+ /* fall back to straight interning */
+ if (lwc_intern_string(norm_start, length,
+ &url->host) != lwc_error_ok) {
+ return NSERROR_NOMEM;
+ }
}
}
@@ -1736,6 +1743,8 @@ nserror nsurl_join(const nsurl *base, const char *rel, nsurl **joined)
assert(base != NULL);
assert(rel != NULL);
+ LOG(("base \"%s\" rel \"%s\"", nsurl_access(base), rel));
+
/* Peg out the URL sections */
nsurl__get_string_markers(rel, &m, true);
@@ -1743,11 +1752,13 @@ nserror nsurl_join(const nsurl *base, const char *rel, nsurl **joined)
length = nsurl__get_longest_section(&m);
/* Initially assume that the joined URL can be formed entierly from
- * the relative URL. */
+ * the relative URL.
+ */
joined_parts = NSURL_F_REL;
/* Update joined_compnents to indicate any required parts from the
- * base URL. */
+ * base URL.
+ */
if (m.scheme_end - m.start <= 0) {
/* The relative url has no scheme.
* Use base URL's scheme. */
@@ -1777,7 +1788,8 @@ nserror nsurl_join(const nsurl *base, const char *rel, nsurl **joined)
}
/* Allocate enough memory to url escape the longest section, plus
- * space for path merging (if required). */
+ * space for path merging (if required).
+ */
if (joined_parts & NSURL_F_MERGED_PATH) {
/* Need to merge paths */
length += (base->components.path != NULL) ?
@@ -1789,8 +1801,9 @@ nserror nsurl_join(const nsurl *base, const char *rel, nsurl **joined)
lwc_string_length(base->components.path) : 0);
buff = malloc(length + 5);
- if (buff == NULL)
+ if (buff == NULL) {
return NSERROR_NOMEM;
+ }
buff_pos = buff;
@@ -1803,8 +1816,11 @@ nserror nsurl_join(const nsurl *base, const char *rel, nsurl **joined)
} else {
c.scheme_type = m.scheme_type;
- error |= nsurl__create_from_section(rel, URL_SCHEME, &m,
- buff, &c);
+ error = nsurl__create_from_section(rel, URL_SCHEME, &m, buff, &c);
+ if (error != NSERROR_OK) {
+ free(buff);
+ return error;
+ }
}
if (joined_parts & NSURL_F_BASE_AUTHORITY) {
@@ -1813,10 +1829,16 @@ nserror nsurl_join(const nsurl *base, const char *rel, nsurl **joined)
c.host = nsurl__component_copy(base->components.host);
c.port = nsurl__component_copy(base->components.port);
} else {
- error |= nsurl__create_from_section(rel, URL_CREDENTIALS, &m,
- buff, &c);
- error |= nsurl__create_from_section(rel, URL_HOST, &m,
- buff, &c);
+ error = nsurl__create_from_section(rel, URL_CREDENTIALS, &m,
+ buff, &c);
+ if (error == NSERROR_OK) {
+ error = nsurl__create_from_section(rel, URL_HOST, &m,
+ buff, &c);
+ }
+ if (error != NSERROR_OK) {
+ free(buff);
+ return error;
+ }
}
if (joined_parts & NSURL_F_BASE_PATH) {
@@ -1866,8 +1888,12 @@ nserror nsurl_join(const nsurl *base, const char *rel, nsurl **joined)
m_path.query = new_length;
buff_start = buff_pos + new_length;
- error |= nsurl__create_from_section(buff_pos, URL_PATH, &m_path,
+ error = nsurl__create_from_section(buff_pos, URL_PATH, &m_path,
buff_start, &c);
+ if (error != NSERROR_OK) {
+ free(buff);
+ return error;
+ }
} else {
struct url_markers m_path;
@@ -1883,24 +1909,34 @@ nserror nsurl_join(const nsurl *base, const char *rel, nsurl **joined)
m_path.query = new_length;
buff_start = buff_pos + new_length;
- error |= nsurl__create_from_section(buff_pos, URL_PATH, &m_path,
+
+ error = nsurl__create_from_section(buff_pos, URL_PATH, &m_path,
buff_start, &c);
+ if (error != NSERROR_OK) {
+ free(buff);
+ return error;
+ }
}
- if (joined_parts & NSURL_F_BASE_QUERY)
+ if (joined_parts & NSURL_F_BASE_QUERY) {
c.query = nsurl__component_copy(base->components.query);
- else
- error |= nsurl__create_from_section(rel, URL_QUERY, &m,
+ } else {
+ error = nsurl__create_from_section(rel, URL_QUERY, &m,
buff, &c);
+ if (error != NSERROR_OK) {
+ free(buff);
+ return error;
+ }
+ }
- error |= nsurl__create_from_section(rel, URL_FRAGMENT, &m,
- buff, &c);
+ error = nsurl__create_from_section(rel, URL_FRAGMENT, &m, buff, &c);
/* Free temporary buffer */
free(buff);
- if (error != NSERROR_OK)
- return NSERROR_NOMEM;
+ if (error != NSERROR_OK) {
+ return error;
+ }
/* Get the string length and find which parts of url are present */
nsurl__get_string_data(&c, NSURL_WITH_FRAGMENT, &length,
@@ -1908,8 +1944,9 @@ nserror nsurl_join(const nsurl *base, const char *rel, nsurl **joined)
/* Create NetSurf URL object */
*joined = malloc(sizeof(nsurl) + length + 1); /* Add 1 for \0 */
- if (*joined == NULL)
+ if (*joined == NULL) {
return NSERROR_NOMEM;
+ }
(*joined)->components = c;
(*joined)->length = length;
-----------------------------------------------------------------------
Summary of changes:
test/Makefile | 2 +-
test/nsurl.c | 1 +
utils/nsurl.c | 81 +++++++++++++++++++++++++++++++++++++++++---------------
3 files changed, 61 insertions(+), 23 deletions(-)
diff --git a/test/Makefile b/test/Makefile
index acf9d4e..cf0f897 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -22,7 +22,7 @@ urldbtest_SRCS := content/urldb.c utils/url.c utils/utils.c utils/log.c \
urldbtest_CFLAGS := $(shell pkg-config --cflags libwapcaplet libdom) -O2
urldbtest_LDFLAGS := $(shell pkg-config --libs libwapcaplet libdom)
-nsurl_SRCS := utils/corestrings.c utils/log.c utils/nsurl.c test/nsurl.c
+nsurl_SRCS := utils/corestrings.c utils/log.c utils/nsurl.c utils/idna.c utils/utf8proc.c test/nsurl.c
nsurl_CFLAGS := $(shell pkg-config --cflags libwapcaplet libdom)
nsurl_LDFLAGS := $(shell pkg-config --libs libwapcaplet libdom)
diff --git a/test/nsurl.c b/test/nsurl.c
index 3e859d9..20774c4 100644
--- a/test/nsurl.c
+++ b/test/nsurl.c
@@ -141,6 +141,7 @@ static const struct test_pairs join_tests[] = {
{ " / ", "http://a/" },
{ " ? ", "http://a/b/c/d;p?" },
{ " h ", "http://a/b/c/h" },
+ { "http://<!--#echo var=", "http://<!--/#echo%20var="},
/* [1] Extra slash beyond rfc3986 5.4.1 example, since we're
* testing normalisation in addition to joining */
/* [2] Using the strict parsers option */
diff --git a/utils/nsurl.c b/utils/nsurl.c
index 7e8792c..eeb411d 100644
--- a/utils/nsurl.c
+++ b/utils/nsurl.c
@@ -685,6 +685,7 @@ static nserror nsurl__create_from_section(const char * const url_s,
char *pos_norm,
struct nsurl_components *url)
{
+ nserror ret;
int ascii_offset;
int start = 0;
int end = 0;
@@ -961,14 +962,20 @@ static nserror nsurl__create_from_section(const char * const url_s,
/* host */
/* Encode host according to IDNA2008 */
- if (idna_encode(norm_start, length, &host, &host_len) == NSERROR_OK) {
+ ret = idna_encode(norm_start, length, &host, &host_len);
+ if (ret == NSERROR_OK) {
+ /* valid idna encoding */
if (lwc_intern_string(host, host_len,
&url->host) != lwc_error_ok) {
return NSERROR_NOMEM;
}
free(host);
} else {
- return NSERROR_BAD_URL;
+ /* fall back to straight interning */
+ if (lwc_intern_string(norm_start, length,
+ &url->host) != lwc_error_ok) {
+ return NSERROR_NOMEM;
+ }
}
}
@@ -1736,6 +1743,8 @@ nserror nsurl_join(const nsurl *base, const char *rel, nsurl **joined)
assert(base != NULL);
assert(rel != NULL);
+ LOG(("base \"%s\" rel \"%s\"", nsurl_access(base), rel));
+
/* Peg out the URL sections */
nsurl__get_string_markers(rel, &m, true);
@@ -1743,11 +1752,13 @@ nserror nsurl_join(const nsurl *base, const char *rel, nsurl **joined)
length = nsurl__get_longest_section(&m);
/* Initially assume that the joined URL can be formed entierly from
- * the relative URL. */
+ * the relative URL.
+ */
joined_parts = NSURL_F_REL;
/* Update joined_compnents to indicate any required parts from the
- * base URL. */
+ * base URL.
+ */
if (m.scheme_end - m.start <= 0) {
/* The relative url has no scheme.
* Use base URL's scheme. */
@@ -1777,7 +1788,8 @@ nserror nsurl_join(const nsurl *base, const char *rel, nsurl **joined)
}
/* Allocate enough memory to url escape the longest section, plus
- * space for path merging (if required). */
+ * space for path merging (if required).
+ */
if (joined_parts & NSURL_F_MERGED_PATH) {
/* Need to merge paths */
length += (base->components.path != NULL) ?
@@ -1789,8 +1801,9 @@ nserror nsurl_join(const nsurl *base, const char *rel, nsurl **joined)
lwc_string_length(base->components.path) : 0);
buff = malloc(length + 5);
- if (buff == NULL)
+ if (buff == NULL) {
return NSERROR_NOMEM;
+ }
buff_pos = buff;
@@ -1803,8 +1816,11 @@ nserror nsurl_join(const nsurl *base, const char *rel, nsurl **joined)
} else {
c.scheme_type = m.scheme_type;
- error |= nsurl__create_from_section(rel, URL_SCHEME, &m,
- buff, &c);
+ error = nsurl__create_from_section(rel, URL_SCHEME, &m, buff, &c);
+ if (error != NSERROR_OK) {
+ free(buff);
+ return error;
+ }
}
if (joined_parts & NSURL_F_BASE_AUTHORITY) {
@@ -1813,10 +1829,16 @@ nserror nsurl_join(const nsurl *base, const char *rel, nsurl **joined)
c.host = nsurl__component_copy(base->components.host);
c.port = nsurl__component_copy(base->components.port);
} else {
- error |= nsurl__create_from_section(rel, URL_CREDENTIALS, &m,
- buff, &c);
- error |= nsurl__create_from_section(rel, URL_HOST, &m,
- buff, &c);
+ error = nsurl__create_from_section(rel, URL_CREDENTIALS, &m,
+ buff, &c);
+ if (error == NSERROR_OK) {
+ error = nsurl__create_from_section(rel, URL_HOST, &m,
+ buff, &c);
+ }
+ if (error != NSERROR_OK) {
+ free(buff);
+ return error;
+ }
}
if (joined_parts & NSURL_F_BASE_PATH) {
@@ -1866,8 +1888,12 @@ nserror nsurl_join(const nsurl *base, const char *rel, nsurl **joined)
m_path.query = new_length;
buff_start = buff_pos + new_length;
- error |= nsurl__create_from_section(buff_pos, URL_PATH, &m_path,
+ error = nsurl__create_from_section(buff_pos, URL_PATH, &m_path,
buff_start, &c);
+ if (error != NSERROR_OK) {
+ free(buff);
+ return error;
+ }
} else {
struct url_markers m_path;
@@ -1883,24 +1909,34 @@ nserror nsurl_join(const nsurl *base, const char *rel, nsurl **joined)
m_path.query = new_length;
buff_start = buff_pos + new_length;
- error |= nsurl__create_from_section(buff_pos, URL_PATH, &m_path,
+
+ error = nsurl__create_from_section(buff_pos, URL_PATH, &m_path,
buff_start, &c);
+ if (error != NSERROR_OK) {
+ free(buff);
+ return error;
+ }
}
- if (joined_parts & NSURL_F_BASE_QUERY)
+ if (joined_parts & NSURL_F_BASE_QUERY) {
c.query = nsurl__component_copy(base->components.query);
- else
- error |= nsurl__create_from_section(rel, URL_QUERY, &m,
+ } else {
+ error = nsurl__create_from_section(rel, URL_QUERY, &m,
buff, &c);
+ if (error != NSERROR_OK) {
+ free(buff);
+ return error;
+ }
+ }
- error |= nsurl__create_from_section(rel, URL_FRAGMENT, &m,
- buff, &c);
+ error = nsurl__create_from_section(rel, URL_FRAGMENT, &m, buff, &c);
/* Free temporary buffer */
free(buff);
- if (error != NSERROR_OK)
- return NSERROR_NOMEM;
+ if (error != NSERROR_OK) {
+ return error;
+ }
/* Get the string length and find which parts of url are present */
nsurl__get_string_data(&c, NSURL_WITH_FRAGMENT, &length,
@@ -1908,8 +1944,9 @@ nserror nsurl_join(const nsurl *base, const char *rel, nsurl **joined)
/* Create NetSurf URL object */
*joined = malloc(sizeof(nsurl) + length + 1); /* Add 1 for \0 */
- if (*joined == NULL)
+ if (*joined == NULL) {
return NSERROR_NOMEM;
+ }
(*joined)->components = c;
(*joined)->length = length;
--
NetSurf Browser
9 years, 5 months
libdom: branch rupindersingh/libdom updated. release/0.1.0-50-g36ad8c8
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/libdom.git/shortlog/36ad8c8d82d066c52ca38b...
...commit http://git.netsurf-browser.org/libdom.git/commit/36ad8c8d82d066c52ca38bcd...
...tree http://git.netsurf-browser.org/libdom.git/tree/36ad8c8d82d066c52ca38bcd13...
The branch, rupindersingh/libdom has been updated
via 36ad8c8d82d066c52ca38bcd1325470f9c824b3c (commit)
from 4a373b5330d9111dec851fa4c72e6bc1f779168f (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/libdom.git/commit/?id=36ad8c8d82d066c52ca3...
commit 36ad8c8d82d066c52ca38bcd1325470f9c824b3c
Author: Rupinder Singh Khokhar <rsk1coder99(a)gmail.com>
Commit: Rupinder Singh Khokhar <rsk1coder99(a)gmail.com>
Input Element checked on clicking fix and also fixed bubbling and cancelability
diff --git a/src/html/TODO b/src/html/TODO
index 83ff515..b55a6d7 100644
--- a/src/html/TODO
+++ b/src/html/TODO
@@ -15,9 +15,9 @@ HTMLFormElement html_form_element DONE
HTMLSelectElement html_select_element DONE
HTMLOptGroupElement html_optgroup_element DONE
HTMLOptionElement html_option_element DONE
-HTMLInputElement html_input_element MISSING
+HTMLInputElement html_input_element DONE
HTMLTextAreaElement html_textarea_element DONE
-HTMLButtonElement html_button_element MISSING
+HTMLButtonElement html_button_element DONE
HTMLLabelElement html_label_element DONE
HTMLFieldSetElement html_fieldset_element DONE
HTMLLegendElement html_legend_element DONE
diff --git a/src/html/html_input_element.c b/src/html/html_input_element.c
index c4cfc05..84079f7 100644
--- a/src/html/html_input_element.c
+++ b/src/html/html_input_element.c
@@ -65,6 +65,8 @@ dom_exception _dom_html_input_element_initialise(struct dom_html_document *doc,
ele->default_checked_set = false;
ele->default_value = NULL;
ele->default_value_set = false;
+ ele->checked = false;
+ ele->checked_set = false;
return _dom_html_element_initialise(doc, &ele->base,
doc->memoised[hds_INPUT],
@@ -166,6 +168,11 @@ dom_exception dom_html_input_element_set_read_only(dom_html_input_element *ele,
dom_exception dom_html_input_element_get_checked(dom_html_input_element *ele,
bool *checked)
{
+ if(ele->checked_set) {
+ *checked = ele->checked;
+ return DOM_NO_ERR;
+ }
+
return dom_html_element_get_bool_property(&ele->base, "checked",
SLEN("checked"), checked);
}
@@ -447,11 +454,11 @@ dom_exception dom_html_input_element_focus(dom_html_input_element *ele)
bool success = false;
assert(doc != NULL);
- /** \todo Is this event (a) default (b) bubbling and (c) cancelable? */
+ /** \this event doesnt bubble and is non-cancelable src:wikipedia*/
return _dom_dispatch_generic_event((dom_document *)doc,
(dom_event_target *) ele,
- doc->memoised[hds_focus], true,
- true, &success);
+ doc->memoised[hds_focus], false,
+ false, &success);
}
/**
@@ -467,11 +474,11 @@ dom_exception dom_html_input_element_select(dom_html_input_element *ele)
bool success = false;
assert(doc != NULL);
- /** \todo Is this event (a) default (b) bubbling and (c) cancelable? */
+ /** \this event bubbles and non-cancelable src:wikipedia*/
return _dom_dispatch_generic_event((dom_document *)doc,
(dom_event_target *) ele,
doc->memoised[hds_select], true,
- true, &success);
+ false, &success);
}
/**
@@ -485,13 +492,21 @@ dom_exception dom_html_input_element_click(dom_html_input_element *ele)
struct dom_html_document *doc =
(dom_html_document *) dom_node_get_owner(ele);
bool success = false;
+ dom_exception err;
assert(doc != NULL);
- /** \todo Is this is meant to check/uncheck boxes, radios etc */
- /** \todo Is this event (a) default (b) bubbling and (c) cancelable? */
- return _dom_dispatch_generic_event((dom_document *)doc,
+
+ /** \This event bubbles & is cancelable src:Wikipedia*/
+ err = _dom_dispatch_generic_event((dom_document *)doc,
(dom_event_target *) ele,
doc->memoised[hds_click], true,
true, &success);
+ if(err != DOM_NO_ERR)
+ return err;
+
+ ele->checked = true;
+ ele->checked_set = true;
+
+ return DOM_NO_ERR;
}
diff --git a/src/html/html_input_element.h b/src/html/html_input_element.h
index 72c7d51..b818b2e 100644
--- a/src/html/html_input_element.h
+++ b/src/html/html_input_element.h
@@ -21,6 +21,8 @@ struct dom_html_input_element {
bool default_checked_set; /**< Whether default_checked has been set */
dom_string *default_value; /**< Initial value */
bool default_value_set; /**< Whether default_value has been set */
+ bool checked; /**< Whether the element has been checked by a click */
+ bool checked_set;
};
/* Create a dom_html_input_element object */
diff --git a/test/testcases/tests/level1/html/HTMLInputElement21.xml b/test/testcases/tests/level1/html/HTMLInputElement21.xml
new file mode 100644
index 0000000..57fbc76
--- /dev/null
+++ b/test/testcases/tests/level1/html/HTMLInputElement21.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?xml-stylesheet href="test-to-html.xsl" type="text/xml"?>
+
+<!--
+
+Copyright (c) 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="HTMLInputElement21">
+<metadata>
+<title>HTMLInputElement21</title>
+<creator>Curt Arnold</creator>
+<description>
+HTMLInputElement.click should change the state of checked on a radio button.
+</description>
+<date qualifier="created">2004-03-18</date>
+<subject resource="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-2651361"/>
+</metadata>
+<var name="nodeList" type="NodeList"/>
+<var name="testNode" type="Node"/>
+<var name="doc" type="Document"/>
+<var name="checked" type="boolean"/>
+<load var="doc" href="input" willBeModified="true"/>
+<getElementsByTagName interface="Document" obj="doc" var="nodeList" tagname='"input"'/>
+<assertSize collection="nodeList" size="9" id="Asize"/>
+<item interface="NodeList" obj="nodeList" var="testNode" index="1"/>
+<checked var="checked" obj="testNode"/>
+<assertFalse actual="checked" id="notCheckedBeforeClick"/>
+<click interface="HTMLInputElement" obj="testNode"/>
+<checked var="checked" obj="testNode"/>
+<assertTrue actual="checked" id="checkedAfterClick"/>
+</test>
diff --git a/test/testcases/tests/level1/html/HTMLInputElement21.xml.kfail b/test/testcases/tests/level1/html/HTMLInputElement21.xml.kfail
deleted file mode 100644
index 57fbc76..0000000
--- a/test/testcases/tests/level1/html/HTMLInputElement21.xml.kfail
+++ /dev/null
@@ -1,42 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?xml-stylesheet href="test-to-html.xsl" type="text/xml"?>
-
-<!--
-
-Copyright (c) 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="HTMLInputElement21">
-<metadata>
-<title>HTMLInputElement21</title>
-<creator>Curt Arnold</creator>
-<description>
-HTMLInputElement.click should change the state of checked on a radio button.
-</description>
-<date qualifier="created">2004-03-18</date>
-<subject resource="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-2651361"/>
-</metadata>
-<var name="nodeList" type="NodeList"/>
-<var name="testNode" type="Node"/>
-<var name="doc" type="Document"/>
-<var name="checked" type="boolean"/>
-<load var="doc" href="input" willBeModified="true"/>
-<getElementsByTagName interface="Document" obj="doc" var="nodeList" tagname='"input"'/>
-<assertSize collection="nodeList" size="9" id="Asize"/>
-<item interface="NodeList" obj="nodeList" var="testNode" index="1"/>
-<checked var="checked" obj="testNode"/>
-<assertFalse actual="checked" id="notCheckedBeforeClick"/>
-<click interface="HTMLInputElement" obj="testNode"/>
-<checked var="checked" obj="testNode"/>
-<assertTrue actual="checked" id="checkedAfterClick"/>
-</test>
-----------------------------------------------------------------------
Summary of changes:
src/html/TODO | 4 +-
src/html/html_input_element.c | 31 ++++++++++++++-----
src/html/html_input_element.h | 2 +
...tElement21.xml.kfail => HTMLInputElement21.xml} | 0
4 files changed, 27 insertions(+), 10 deletions(-)
rename test/testcases/tests/level1/html/{HTMLInputElement21.xml.kfail => HTMLInputElement21.xml} (100%)
diff --git a/src/html/TODO b/src/html/TODO
index 83ff515..b55a6d7 100644
--- a/src/html/TODO
+++ b/src/html/TODO
@@ -15,9 +15,9 @@ HTMLFormElement html_form_element DONE
HTMLSelectElement html_select_element DONE
HTMLOptGroupElement html_optgroup_element DONE
HTMLOptionElement html_option_element DONE
-HTMLInputElement html_input_element MISSING
+HTMLInputElement html_input_element DONE
HTMLTextAreaElement html_textarea_element DONE
-HTMLButtonElement html_button_element MISSING
+HTMLButtonElement html_button_element DONE
HTMLLabelElement html_label_element DONE
HTMLFieldSetElement html_fieldset_element DONE
HTMLLegendElement html_legend_element DONE
diff --git a/src/html/html_input_element.c b/src/html/html_input_element.c
index c4cfc05..84079f7 100644
--- a/src/html/html_input_element.c
+++ b/src/html/html_input_element.c
@@ -65,6 +65,8 @@ dom_exception _dom_html_input_element_initialise(struct dom_html_document *doc,
ele->default_checked_set = false;
ele->default_value = NULL;
ele->default_value_set = false;
+ ele->checked = false;
+ ele->checked_set = false;
return _dom_html_element_initialise(doc, &ele->base,
doc->memoised[hds_INPUT],
@@ -166,6 +168,11 @@ dom_exception dom_html_input_element_set_read_only(dom_html_input_element *ele,
dom_exception dom_html_input_element_get_checked(dom_html_input_element *ele,
bool *checked)
{
+ if(ele->checked_set) {
+ *checked = ele->checked;
+ return DOM_NO_ERR;
+ }
+
return dom_html_element_get_bool_property(&ele->base, "checked",
SLEN("checked"), checked);
}
@@ -447,11 +454,11 @@ dom_exception dom_html_input_element_focus(dom_html_input_element *ele)
bool success = false;
assert(doc != NULL);
- /** \todo Is this event (a) default (b) bubbling and (c) cancelable? */
+ /** \this event doesnt bubble and is non-cancelable src:wikipedia*/
return _dom_dispatch_generic_event((dom_document *)doc,
(dom_event_target *) ele,
- doc->memoised[hds_focus], true,
- true, &success);
+ doc->memoised[hds_focus], false,
+ false, &success);
}
/**
@@ -467,11 +474,11 @@ dom_exception dom_html_input_element_select(dom_html_input_element *ele)
bool success = false;
assert(doc != NULL);
- /** \todo Is this event (a) default (b) bubbling and (c) cancelable? */
+ /** \this event bubbles and non-cancelable src:wikipedia*/
return _dom_dispatch_generic_event((dom_document *)doc,
(dom_event_target *) ele,
doc->memoised[hds_select], true,
- true, &success);
+ false, &success);
}
/**
@@ -485,13 +492,21 @@ dom_exception dom_html_input_element_click(dom_html_input_element *ele)
struct dom_html_document *doc =
(dom_html_document *) dom_node_get_owner(ele);
bool success = false;
+ dom_exception err;
assert(doc != NULL);
- /** \todo Is this is meant to check/uncheck boxes, radios etc */
- /** \todo Is this event (a) default (b) bubbling and (c) cancelable? */
- return _dom_dispatch_generic_event((dom_document *)doc,
+
+ /** \This event bubbles & is cancelable src:Wikipedia*/
+ err = _dom_dispatch_generic_event((dom_document *)doc,
(dom_event_target *) ele,
doc->memoised[hds_click], true,
true, &success);
+ if(err != DOM_NO_ERR)
+ return err;
+
+ ele->checked = true;
+ ele->checked_set = true;
+
+ return DOM_NO_ERR;
}
diff --git a/src/html/html_input_element.h b/src/html/html_input_element.h
index 72c7d51..b818b2e 100644
--- a/src/html/html_input_element.h
+++ b/src/html/html_input_element.h
@@ -21,6 +21,8 @@ struct dom_html_input_element {
bool default_checked_set; /**< Whether default_checked has been set */
dom_string *default_value; /**< Initial value */
bool default_value_set; /**< Whether default_value has been set */
+ bool checked; /**< Whether the element has been checked by a click */
+ bool checked_set;
};
/* Create a dom_html_input_element object */
diff --git a/test/testcases/tests/level1/html/HTMLInputElement21.xml.kfail b/test/testcases/tests/level1/html/HTMLInputElement21.xml
similarity index 100%
rename from test/testcases/tests/level1/html/HTMLInputElement21.xml.kfail
rename to test/testcases/tests/level1/html/HTMLInputElement21.xml
--
Document Object Model library
9 years, 5 months
libdom: branch rupindersingh/libdom updated. release/0.1.0-49-g4a373b5
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/libdom.git/shortlog/4a373b5330d9111dec851f...
...commit http://git.netsurf-browser.org/libdom.git/commit/4a373b5330d9111dec851fa4...
...tree http://git.netsurf-browser.org/libdom.git/tree/4a373b5330d9111dec851fa4c7...
The branch, rupindersingh/libdom has been updated
via 4a373b5330d9111dec851fa4c72e6bc1f779168f (commit)
from 5b7066201cc3b1150b1f8ae2772e6f38b3762492 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/libdom.git/commit/?id=4a373b5330d9111dec85...
commit 4a373b5330d9111dec851fa4c72e6bc1f779168f
Author: Rupinder Singh Khokhar <rsk1coder99(a)gmail.com>
Commit: Rupinder Singh Khokhar <rsk1coder99(a)gmail.com>
Slight change in interface file & copying a few test files
diff --git a/src/html/TODO b/src/html/TODO
index 183f10d..83ff515 100644
--- a/src/html/TODO
+++ b/src/html/TODO
@@ -10,7 +10,7 @@ HTMLMetaElement html_meta_element DONE
HTMLBaseElement html_base_element DONE
HTMLIsIndexElement html_isindex_element MISSING
HTMLStyleElement html_style_element DONE
-HTMLBodyElement html_body_element MISSING
+HTMLBodyElement html_body_element DONE
HTMLFormElement html_form_element DONE
HTMLSelectElement html_select_element DONE
HTMLOptGroupElement html_optgroup_element DONE
diff --git a/test/dom1-interfaces.xml b/test/dom1-interfaces.xml
index 240f2b9..a0d11c7 100644
--- a/test/dom1-interfaces.xml
+++ b/test/dom1-interfaces.xml
@@ -720,7 +720,31 @@ See W3C License http://www.w3.org/Consortium/Legal/ for more details.
</returns>
<raises/>
</method>
+<method name="isSupported" id="notknown">
+<descr>
+<p/>
+</descr>
+<parameters>
+<param name="feature" type="DOMString" attr="in">
+<descr>
+<p/>
+</descr>
+</param>
+<param name="version" type="DOMString" attr="in">
+<descr>
+<p/>
+</descr>
+</param>
+</parameters>
+<returns type="bool">
+<descr>
+<p/>
+</descr>
+</returns>
+<raises/>
+</method>
</interface>
+
<interface name="NodeList" id="ID-536297177">
<descr>
<p>The<code>NodeList</code>interface provides the abstraction of an ordered collection of nodes, without defining or constraining how this collection is implemented.</p>
diff --git a/test/testcases/tests/level2/html/files/document.html b/test/testcases/tests/level2/html/files/document.html
new file mode 100644
index 0000000..9cd9c8a
--- /dev/null
+++ b/test/testcases/tests/level2/html/files/document.html
@@ -0,0 +1,36 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<HTML>
+<HEAD>
+<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=utf-8">
+<TITLE>NIST DOM HTML Test - DOCUMENT</TITLE>
+</HEAD>
+<BODY onload="parent.loadComplete()" ID="TEST-BODY">
+<FORM ID="form1" ACCEPT-CHARSET="US-ASCII" ACTION="./files/getData.pl" ENCTYPE="application/x-www-form-urlencoded" METHOD="post">
+<P>
+<TEXTAREA NAME="text1" COLS="20" ROWS="7"></TEXTAREA>
+<INPUT TYPE="submit" NAME="submit" VALUE="Submit" />
+<INPUT TYPE="reset" NAME="reset" VALUE="Reset" />
+</P>
+</FORM>
+<P>
+<MAP NAME="mapid" ID="mapid">
+<AREA TABINDEX="10" ACCESSKEY="a" SHAPE="rect" ALT="Domain" COORDS="0,2,45,45" HREF="./files/dletter.html" TITLE="Domain1">
+<AREA TABINDEX="10" ACCESSKEY="a" SHAPE="rect" ALT="Domain" COORDS="0,2,45,45" HREF="./files/dletter.html" TITLE="Domain2">
+</MAP>
+</P>
+<P>
+<IMG ID="IMAGE-1" NAME="IMAGE-1" SRC="./pix/dts.gif" ALT="DTS IMAGE LOGO" LONGDESC="./files/desc.html" USEMAP="#DTS-MAP" WIDTH="115"/>
+</P>
+<P>
+<OBJECT DATA="./pix/line.gif" CODETYPE="image/gif" HEIGHT="10">
+<APPLET ALT="Applet Number 1" CODE="applet1.class"></APPLET>
+</OBJECT>
+<OBJECT DATA="./pix/logo.gif" type="image/gif">
+<APPLET ALT="Applet Number 2" CODE="applet2.class"></APPLET>
+</OBJECT>
+</P>
+<P>
+<A ID="Anchor" DIR="LTR" HREF="./pix/submit.gif" ACCESSKEY="g" TYPE="image/gif" COORDS="0,0,100,100" SHAPE="rect" REL="GLOSSARY" REV="STYLESHEET" HREFLANG="en" CHARSET="US-ASCII" TABINDEX="22" NAME="Anchor">View Submit Button</A>
+</P>
+</BODY>
+</HTML>
diff --git a/test/testcases/tests/level2/html/files/document.xhtml b/test/testcases/tests/level2/html/files/document.xhtml
new file mode 100644
index 0000000..3cc6ccf
--- /dev/null
+++ b/test/testcases/tests/level2/html/files/document.xhtml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "xhtml1-transitional.dtd">
+<html xmlns='http://www.w3.org/1999/xhtml'>
+<head>
+<title>NIST DOM HTML Test - DOCUMENT</title>
+</head>
+<body onload="parent.loadComplete()" id="TEST-BODY">
+<form id="form1" accept-charset="US-ASCII" action="./files/getData.pl" enctype="application/x-www-form-urlencoded" method="post">
+<p>
+<textarea name="text1" cols="20" rows="7"></textarea>
+<input type="submit" name="submit1" value="Submit" />
+<input type="reset" name="submit2" value="Reset" />
+</p>
+</form>
+<p>
+<map name="mapid" id="mapid">
+<area tabindex="10" accesskey="a" shape="rect" alt="Domain" coords="0,2,45,45" href="./files/dletter.html" title="Domain1" />
+<area tabindex="10" accesskey="a" shape="rect" alt="Domain" coords="0,2,45,45" href="./files/dletter.html" title="Domain2" />
+</map>
+</p>
+<p>
+<img id="IMAGE-1" src="./pix/dts.gif" alt="DTS IMAGE LOGO" longdesc="./files/desc.html" usemap="#DTS-MAP" width="115"/>
+</p>
+<p>
+<object data="./pix/line.gif" codetype="image/gif" height="10">
+<applet alt="Applet Number 1" code="applet1.class" width="10" height="10"></applet>
+</object>
+<object data="./pix/logo.gif" type="image/gif">
+<applet alt="Applet Number 2" code="applet2.class" width="10" height="10"></applet>
+</object>
+</p>
+<p>
+<a id="Anchor" dir="ltr" href="./pix/submit.gif" accesskey="g" type="image/gif" coords="0,0,100,100" shape="rect" rel="GLOSSARY" rev="STYLESHEET" hreflang="en" charset="US-ASCII" tabindex="22" name="Anchor">View Submit Button</a>
+</p>
+</body>
+</html>
+
diff --git a/test/testcases/tests/level2/html/files/document.xml b/test/testcases/tests/level2/html/files/document.xml
new file mode 100644
index 0000000..3cc6ccf
--- /dev/null
+++ b/test/testcases/tests/level2/html/files/document.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "xhtml1-transitional.dtd">
+<html xmlns='http://www.w3.org/1999/xhtml'>
+<head>
+<title>NIST DOM HTML Test - DOCUMENT</title>
+</head>
+<body onload="parent.loadComplete()" id="TEST-BODY">
+<form id="form1" accept-charset="US-ASCII" action="./files/getData.pl" enctype="application/x-www-form-urlencoded" method="post">
+<p>
+<textarea name="text1" cols="20" rows="7"></textarea>
+<input type="submit" name="submit1" value="Submit" />
+<input type="reset" name="submit2" value="Reset" />
+</p>
+</form>
+<p>
+<map name="mapid" id="mapid">
+<area tabindex="10" accesskey="a" shape="rect" alt="Domain" coords="0,2,45,45" href="./files/dletter.html" title="Domain1" />
+<area tabindex="10" accesskey="a" shape="rect" alt="Domain" coords="0,2,45,45" href="./files/dletter.html" title="Domain2" />
+</map>
+</p>
+<p>
+<img id="IMAGE-1" src="./pix/dts.gif" alt="DTS IMAGE LOGO" longdesc="./files/desc.html" usemap="#DTS-MAP" width="115"/>
+</p>
+<p>
+<object data="./pix/line.gif" codetype="image/gif" height="10">
+<applet alt="Applet Number 1" code="applet1.class" width="10" height="10"></applet>
+</object>
+<object data="./pix/logo.gif" type="image/gif">
+<applet alt="Applet Number 2" code="applet2.class" width="10" height="10"></applet>
+</object>
+</p>
+<p>
+<a id="Anchor" dir="ltr" href="./pix/submit.gif" accesskey="g" type="image/gif" coords="0,0,100,100" shape="rect" rel="GLOSSARY" rev="STYLESHEET" hreflang="en" charset="US-ASCII" tabindex="22" name="Anchor">View Submit Button</a>
+</p>
+</body>
+</html>
+
-----------------------------------------------------------------------
Summary of changes:
src/html/TODO | 2 +-
test/dom1-interfaces.xml | 24 ++++++++++++++++++++
.../{level1 => level2}/html/files/document.html | 0
.../{level1 => level2}/html/files/document.xhtml | 0
.../{level1 => level2}/html/files/document.xml | 0
5 files changed, 25 insertions(+), 1 deletions(-)
copy test/testcases/tests/{level1 => level2}/html/files/document.html (100%)
copy test/testcases/tests/{level1 => level2}/html/files/document.xhtml (100%)
copy test/testcases/tests/{level1 => level2}/html/files/document.xml (100%)
diff --git a/src/html/TODO b/src/html/TODO
index 183f10d..83ff515 100644
--- a/src/html/TODO
+++ b/src/html/TODO
@@ -10,7 +10,7 @@ HTMLMetaElement html_meta_element DONE
HTMLBaseElement html_base_element DONE
HTMLIsIndexElement html_isindex_element MISSING
HTMLStyleElement html_style_element DONE
-HTMLBodyElement html_body_element MISSING
+HTMLBodyElement html_body_element DONE
HTMLFormElement html_form_element DONE
HTMLSelectElement html_select_element DONE
HTMLOptGroupElement html_optgroup_element DONE
diff --git a/test/dom1-interfaces.xml b/test/dom1-interfaces.xml
index 240f2b9..a0d11c7 100644
--- a/test/dom1-interfaces.xml
+++ b/test/dom1-interfaces.xml
@@ -720,7 +720,31 @@ See W3C License http://www.w3.org/Consortium/Legal/ for more details.
</returns>
<raises/>
</method>
+<method name="isSupported" id="notknown">
+<descr>
+<p/>
+</descr>
+<parameters>
+<param name="feature" type="DOMString" attr="in">
+<descr>
+<p/>
+</descr>
+</param>
+<param name="version" type="DOMString" attr="in">
+<descr>
+<p/>
+</descr>
+</param>
+</parameters>
+<returns type="bool">
+<descr>
+<p/>
+</descr>
+</returns>
+<raises/>
+</method>
</interface>
+
<interface name="NodeList" id="ID-536297177">
<descr>
<p>The<code>NodeList</code>interface provides the abstraction of an ordered collection of nodes, without defining or constraining how this collection is implemented.</p>
diff --git a/test/testcases/tests/level1/html/files/document.html b/test/testcases/tests/level2/html/files/document.html
similarity index 100%
copy from test/testcases/tests/level1/html/files/document.html
copy to test/testcases/tests/level2/html/files/document.html
diff --git a/test/testcases/tests/level1/html/files/document.xhtml b/test/testcases/tests/level2/html/files/document.xhtml
similarity index 100%
copy from test/testcases/tests/level1/html/files/document.xhtml
copy to test/testcases/tests/level2/html/files/document.xhtml
diff --git a/test/testcases/tests/level1/html/files/document.xml b/test/testcases/tests/level2/html/files/document.xml
similarity index 100%
copy from test/testcases/tests/level1/html/files/document.xml
copy to test/testcases/tests/level2/html/files/document.xml
--
Document Object Model library
9 years, 5 months
netsurf: branch master updated. release/3.1-269-g8e29e51
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/8e29e517d59f0d04dd2d0...
...commit http://git.netsurf-browser.org/netsurf.git/commit/8e29e517d59f0d04dd2d09c...
...tree http://git.netsurf-browser.org/netsurf.git/tree/8e29e517d59f0d04dd2d09c6b...
The branch, master has been updated
via 8e29e517d59f0d04dd2d09c6b8760aa1236a1abf (commit)
from e687a359c702e13a7f3e7bb5ba8e7b76d32283b1 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=8e29e517d59f0d04dd2...
commit 8e29e517d59f0d04dd2d09c6b8760aa1236a1abf
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
fix disc cache size option to be unsigned
diff --git a/amiga/gui_options.c b/amiga/gui_options.c
index 0b01a93..3a6451b 100755
--- a/amiga/gui_options.c
+++ b/amiga/gui_options.c
@@ -1157,7 +1157,7 @@ void ami_gui_opts_open(void)
LAYOUT_AddChild, gow->objects[GID_OPTS_CACHE_DISC] = IntegerObject,
GA_ID, GID_OPTS_CACHE_DISC,
GA_RelVerify, TRUE,
- INTEGER_Number, nsoption_int(disc_cache_size) / 1048576,
+ INTEGER_Number, nsoption_uint(disc_cache_size) / 1048576,
INTEGER_Minimum, 0,
INTEGER_Maximum, 4096,
INTEGER_Arrows, TRUE,
@@ -1750,8 +1750,8 @@ void ami_gui_opts_use(bool save)
GetAttr(INTEGER_Number,gow->objects[GID_OPTS_CACHE_MEM],(ULONG *)&nsoption_int(memory_cache_size));
nsoption_set_int(memory_cache_size, nsoption_int(memory_cache_size) * 1048576);
- GetAttr(INTEGER_Number,gow->objects[GID_OPTS_CACHE_DISC],(ULONG *)&nsoption_int(disc_cache_size));
- nsoption_set_int(disc_cache_size, nsoption_int(disc_cache_size) * 1048576);
+ GetAttr(INTEGER_Number,gow->objects[GID_OPTS_CACHE_DISC],(ULONG *)&nsoption_uint(disc_cache_size));
+ nsoption_set_uint(disc_cache_size, nsoption_uint(disc_cache_size) * 1048576);
GetAttr(GA_Selected,gow->objects[GID_OPTS_OVERWRITE],(ULONG *)&data);
if (data) {
diff --git a/desktop/netsurf.c b/desktop/netsurf.c
index 1538107..a1bc42b 100644
--- a/desktop/netsurf.c
+++ b/desktop/netsurf.c
@@ -191,7 +191,7 @@ nserror netsurf_init(const char *messages, const char *store_path)
hlcache_parameters.llcache.limit -= image_cache_parameters.limit;
/* set backing store target limit */
- hlcache_parameters.llcache.store.limit = nsoption_int(disc_cache_size);
+ hlcache_parameters.llcache.store.limit = nsoption_uint(disc_cache_size);
/* set backing store hysterissi to 20% */
hlcache_parameters.llcache.store.hysteresis = (hlcache_parameters.llcache.store.limit * 20) / 100;;
diff --git a/desktop/options.h b/desktop/options.h
index 391dfbc..33ecb75 100644
--- a/desktop/options.h
+++ b/desktop/options.h
@@ -89,7 +89,7 @@ NSOPTION_STRING(accept_charset, NULL)
NSOPTION_INTEGER(memory_cache_size, 12 * 1024 * 1024)
/** Preferred expiry size of disc cache / bytes. */
-NSOPTION_INTEGER(disc_cache_size, 1024 * 1024 * 1024)
+NSOPTION_UINT(disc_cache_size, 1024 * 1024 * 1024)
/** Preferred expiry age of disc cache / days. */
NSOPTION_INTEGER(disc_cache_age, 28)
diff --git a/gtk/dialogs/preferences.c b/gtk/dialogs/preferences.c
index f80500d..58bb8b4 100644
--- a/gtk/dialogs/preferences.c
+++ b/gtk/dialogs/preferences.c
@@ -108,6 +108,27 @@ nsgtk_preferences_##WIDGET##_realize(GtkWidget *widget, struct ppref *priv) \
((gdouble)nsoption_int(OPTION)) / MULTIPLIER); \
}
+#define SPINBUTTON_UINT_SIGNALS(WIDGET, OPTION, MULTIPLIER) \
+G_MODULE_EXPORT void \
+nsgtk_preferences_##WIDGET##_valuechanged(GtkSpinButton *spinbutton, \
+ struct ppref *priv); \
+G_MODULE_EXPORT void \
+nsgtk_preferences_##WIDGET##_valuechanged(GtkSpinButton *spinbutton, \
+ struct ppref *priv) \
+{ \
+ nsoption_set_uint(OPTION, \
+ round(gtk_spin_button_get_value(spinbutton) * MULTIPLIER)); \
+} \
+ \
+G_MODULE_EXPORT void \
+nsgtk_preferences_##WIDGET##_realize(GtkWidget *widget, struct ppref *priv); \
+G_MODULE_EXPORT void \
+nsgtk_preferences_##WIDGET##_realize(GtkWidget *widget, struct ppref *priv) \
+{ \
+ gtk_spin_button_set_value(GTK_SPIN_BUTTON(widget), \
+ ((gdouble)nsoption_uint(OPTION)) / MULTIPLIER); \
+}
+
#define ENTRY_SIGNALS(WIDGET, OPTION) \
G_MODULE_EXPORT void \
nsgtk_preferences_##WIDGET##_changed(GtkEditable *editable, struct ppref *priv); \
@@ -372,7 +393,7 @@ SPINBUTTON_SIGNALS(spinHistoryAge, history_age, 1.0)
SPINBUTTON_SIGNALS(spinMemoryCacheSize, memory_cache_size, (1024*1024))
/* disc cache size */
-SPINBUTTON_SIGNALS(spinDiscCacheSize, disc_cache_size, (1024*1024))
+SPINBUTTON_UINT_SIGNALS(spinDiscCacheSize, disc_cache_size, (1024*1024))
/* disc cache age */
diff --git a/gtk/res/options.gtk2.ui b/gtk/res/options.gtk2.ui
index ebe7b91..b0d45bb 100644
--- a/gtk/res/options.gtk2.ui
+++ b/gtk/res/options.gtk2.ui
@@ -2653,10 +2653,10 @@
<property name="page_increment">16</property>
</object>
<object class="GtkAdjustment" id="adjustment_cache_disc_size">
- <property name="value">16</property>
- <property name="upper">2048</property>
- <property name="step_increment">4</property>
- <property name="page_increment">16</property>
+ <property name="value">1024</property>
+ <property name="upper">4096</property>
+ <property name="step_increment">32</property>
+ <property name="page_increment">256</property>
</object>
<object class="GtkAdjustment" id="adjustment_disc_cache_age">
<property name="value">28</property>
diff --git a/gtk/res/options.gtk3.ui b/gtk/res/options.gtk3.ui
index a795c2b..02e4df4 100644
--- a/gtk/res/options.gtk3.ui
+++ b/gtk/res/options.gtk3.ui
@@ -9,13 +9,13 @@
<property name="page_increment">1</property>
</object>
<object class="GtkAdjustment" id="adjustment_cache_disc_size">
- <property name="upper">2048</property>
- <property name="value">16</property>
+ <property name="upper">4096</property>
+ <property name="value">1024</property>
<property name="step_increment">4</property>
<property name="page_increment">16</property>
</object>
<object class="GtkAdjustment" id="adjustment_cache_memory_size">
- <property name="upper">2048</property>
+ <property name="upper">1024</property>
<property name="value">16</property>
<property name="step_increment">4</property>
<property name="page_increment">16</property>
diff --git a/utils/nsoption.h b/utils/nsoption.h
index d111729..134223a 100644
--- a/utils/nsoption.h
+++ b/utils/nsoption.h
@@ -308,6 +308,9 @@ int nsoption_snoptionf(char *string, size_t size, enum nsoption_e option, const
/** set an integer option in the default table */
#define nsoption_set_int(OPTION, VALUE) nsoptions[NSOPTION_##OPTION].value.i = VALUE
+/** set an unsigned integer option in the default table */
+#define nsoption_set_uint(OPTION, VALUE) nsoptions[NSOPTION_##OPTION].value.u = VALUE
+
/** set a colour option in the default table */
#define nsoption_set_colour(OPTION, VALUE) nsoptions[NSOPTION_##OPTION].value.c = VALUE
-----------------------------------------------------------------------
Summary of changes:
amiga/gui_options.c | 6 +++---
desktop/netsurf.c | 2 +-
desktop/options.h | 2 +-
gtk/dialogs/preferences.c | 23 ++++++++++++++++++++++-
gtk/res/options.gtk2.ui | 8 ++++----
gtk/res/options.gtk3.ui | 6 +++---
utils/nsoption.h | 3 +++
7 files changed, 37 insertions(+), 13 deletions(-)
diff --git a/amiga/gui_options.c b/amiga/gui_options.c
index 0b01a93..3a6451b 100755
--- a/amiga/gui_options.c
+++ b/amiga/gui_options.c
@@ -1157,7 +1157,7 @@ void ami_gui_opts_open(void)
LAYOUT_AddChild, gow->objects[GID_OPTS_CACHE_DISC] = IntegerObject,
GA_ID, GID_OPTS_CACHE_DISC,
GA_RelVerify, TRUE,
- INTEGER_Number, nsoption_int(disc_cache_size) / 1048576,
+ INTEGER_Number, nsoption_uint(disc_cache_size) / 1048576,
INTEGER_Minimum, 0,
INTEGER_Maximum, 4096,
INTEGER_Arrows, TRUE,
@@ -1750,8 +1750,8 @@ void ami_gui_opts_use(bool save)
GetAttr(INTEGER_Number,gow->objects[GID_OPTS_CACHE_MEM],(ULONG *)&nsoption_int(memory_cache_size));
nsoption_set_int(memory_cache_size, nsoption_int(memory_cache_size) * 1048576);
- GetAttr(INTEGER_Number,gow->objects[GID_OPTS_CACHE_DISC],(ULONG *)&nsoption_int(disc_cache_size));
- nsoption_set_int(disc_cache_size, nsoption_int(disc_cache_size) * 1048576);
+ GetAttr(INTEGER_Number,gow->objects[GID_OPTS_CACHE_DISC],(ULONG *)&nsoption_uint(disc_cache_size));
+ nsoption_set_uint(disc_cache_size, nsoption_uint(disc_cache_size) * 1048576);
GetAttr(GA_Selected,gow->objects[GID_OPTS_OVERWRITE],(ULONG *)&data);
if (data) {
diff --git a/desktop/netsurf.c b/desktop/netsurf.c
index 1538107..a1bc42b 100644
--- a/desktop/netsurf.c
+++ b/desktop/netsurf.c
@@ -191,7 +191,7 @@ nserror netsurf_init(const char *messages, const char *store_path)
hlcache_parameters.llcache.limit -= image_cache_parameters.limit;
/* set backing store target limit */
- hlcache_parameters.llcache.store.limit = nsoption_int(disc_cache_size);
+ hlcache_parameters.llcache.store.limit = nsoption_uint(disc_cache_size);
/* set backing store hysterissi to 20% */
hlcache_parameters.llcache.store.hysteresis = (hlcache_parameters.llcache.store.limit * 20) / 100;;
diff --git a/desktop/options.h b/desktop/options.h
index 391dfbc..33ecb75 100644
--- a/desktop/options.h
+++ b/desktop/options.h
@@ -89,7 +89,7 @@ NSOPTION_STRING(accept_charset, NULL)
NSOPTION_INTEGER(memory_cache_size, 12 * 1024 * 1024)
/** Preferred expiry size of disc cache / bytes. */
-NSOPTION_INTEGER(disc_cache_size, 1024 * 1024 * 1024)
+NSOPTION_UINT(disc_cache_size, 1024 * 1024 * 1024)
/** Preferred expiry age of disc cache / days. */
NSOPTION_INTEGER(disc_cache_age, 28)
diff --git a/gtk/dialogs/preferences.c b/gtk/dialogs/preferences.c
index f80500d..58bb8b4 100644
--- a/gtk/dialogs/preferences.c
+++ b/gtk/dialogs/preferences.c
@@ -108,6 +108,27 @@ nsgtk_preferences_##WIDGET##_realize(GtkWidget *widget, struct ppref *priv) \
((gdouble)nsoption_int(OPTION)) / MULTIPLIER); \
}
+#define SPINBUTTON_UINT_SIGNALS(WIDGET, OPTION, MULTIPLIER) \
+G_MODULE_EXPORT void \
+nsgtk_preferences_##WIDGET##_valuechanged(GtkSpinButton *spinbutton, \
+ struct ppref *priv); \
+G_MODULE_EXPORT void \
+nsgtk_preferences_##WIDGET##_valuechanged(GtkSpinButton *spinbutton, \
+ struct ppref *priv) \
+{ \
+ nsoption_set_uint(OPTION, \
+ round(gtk_spin_button_get_value(spinbutton) * MULTIPLIER)); \
+} \
+ \
+G_MODULE_EXPORT void \
+nsgtk_preferences_##WIDGET##_realize(GtkWidget *widget, struct ppref *priv); \
+G_MODULE_EXPORT void \
+nsgtk_preferences_##WIDGET##_realize(GtkWidget *widget, struct ppref *priv) \
+{ \
+ gtk_spin_button_set_value(GTK_SPIN_BUTTON(widget), \
+ ((gdouble)nsoption_uint(OPTION)) / MULTIPLIER); \
+}
+
#define ENTRY_SIGNALS(WIDGET, OPTION) \
G_MODULE_EXPORT void \
nsgtk_preferences_##WIDGET##_changed(GtkEditable *editable, struct ppref *priv); \
@@ -372,7 +393,7 @@ SPINBUTTON_SIGNALS(spinHistoryAge, history_age, 1.0)
SPINBUTTON_SIGNALS(spinMemoryCacheSize, memory_cache_size, (1024*1024))
/* disc cache size */
-SPINBUTTON_SIGNALS(spinDiscCacheSize, disc_cache_size, (1024*1024))
+SPINBUTTON_UINT_SIGNALS(spinDiscCacheSize, disc_cache_size, (1024*1024))
/* disc cache age */
diff --git a/gtk/res/options.gtk2.ui b/gtk/res/options.gtk2.ui
index ebe7b91..b0d45bb 100644
--- a/gtk/res/options.gtk2.ui
+++ b/gtk/res/options.gtk2.ui
@@ -2653,10 +2653,10 @@
<property name="page_increment">16</property>
</object>
<object class="GtkAdjustment" id="adjustment_cache_disc_size">
- <property name="value">16</property>
- <property name="upper">2048</property>
- <property name="step_increment">4</property>
- <property name="page_increment">16</property>
+ <property name="value">1024</property>
+ <property name="upper">4096</property>
+ <property name="step_increment">32</property>
+ <property name="page_increment">256</property>
</object>
<object class="GtkAdjustment" id="adjustment_disc_cache_age">
<property name="value">28</property>
diff --git a/gtk/res/options.gtk3.ui b/gtk/res/options.gtk3.ui
index a795c2b..02e4df4 100644
--- a/gtk/res/options.gtk3.ui
+++ b/gtk/res/options.gtk3.ui
@@ -9,13 +9,13 @@
<property name="page_increment">1</property>
</object>
<object class="GtkAdjustment" id="adjustment_cache_disc_size">
- <property name="upper">2048</property>
- <property name="value">16</property>
+ <property name="upper">4096</property>
+ <property name="value">1024</property>
<property name="step_increment">4</property>
<property name="page_increment">16</property>
</object>
<object class="GtkAdjustment" id="adjustment_cache_memory_size">
- <property name="upper">2048</property>
+ <property name="upper">1024</property>
<property name="value">16</property>
<property name="step_increment">4</property>
<property name="page_increment">16</property>
diff --git a/utils/nsoption.h b/utils/nsoption.h
index d111729..134223a 100644
--- a/utils/nsoption.h
+++ b/utils/nsoption.h
@@ -308,6 +308,9 @@ int nsoption_snoptionf(char *string, size_t size, enum nsoption_e option, const
/** set an integer option in the default table */
#define nsoption_set_int(OPTION, VALUE) nsoptions[NSOPTION_##OPTION].value.i = VALUE
+/** set an unsigned integer option in the default table */
+#define nsoption_set_uint(OPTION, VALUE) nsoptions[NSOPTION_##OPTION].value.u = VALUE
+
/** set a colour option in the default table */
#define nsoption_set_colour(OPTION, VALUE) nsoptions[NSOPTION_##OPTION].value.c = VALUE
--
NetSurf Browser
9 years, 5 months
libdom: branch rupindersingh/libdom updated. release/0.1.0-48-g5b70662
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/libdom.git/shortlog/5b7066201cc3b1150b1f8a...
...commit http://git.netsurf-browser.org/libdom.git/commit/5b7066201cc3b1150b1f8ae2...
...tree http://git.netsurf-browser.org/libdom.git/tree/5b7066201cc3b1150b1f8ae277...
The branch, rupindersingh/libdom has been updated
via 5b7066201cc3b1150b1f8ae2772e6f38b3762492 (commit)
from d1ca3ce434f91036c56cb4d4e7a2875e8d6ecd7b (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/libdom.git/commit/?id=5b7066201cc3b1150b1f...
commit 5b7066201cc3b1150b1f8ae2772e6f38b3762492
Author: Rupinder Singh Khokhar <rsk1coder99(a)gmail.com>
Commit: Rupinder Singh Khokhar <rsk1coder99(a)gmail.com>
[HTMLCollection && DOMTSHandler && dtd interface] fixes
diff --git a/src/html/html_options_collection.c b/src/html/html_options_collection.c
index 85001ad..3e06915 100644
--- a/src/html/html_options_collection.c
+++ b/src/html/html_options_collection.c
@@ -190,13 +190,13 @@ dom_exception dom_html_options_collection_named_item(dom_html_options_collection
/* No children and siblings */
struct dom_node_internal *parent = n->parent;
- while (parent != col->base.root &&
+ while (n != col->base.root &&
n == parent->last_child) {
n = parent;
parent = parent->parent;
}
- if (parent == col->base.root)
+ if (n == col->base.root)
n = NULL;
else
n = n->next;
diff --git a/test/DOMTSHandler.pm b/test/DOMTSHandler.pm
index fa71365..fec9bcb 100644
--- a/test/DOMTSHandler.pm
+++ b/test/DOMTSHandler.pm
@@ -48,6 +48,7 @@ our %special_type = (
HTMLTableSectionElement => "dom_html_table_section_element *",
HTMLTableElement => "dom_html_table_element *",
HTMLTableRowElement => "dom_html_table_row_element *",
+ HTMLOptionsCollection => "dom_html_options_collection *",
);
our %special_prefix = (
DOMString => "dom_string",
@@ -1491,7 +1492,7 @@ sub to_get_attribute_cast {
sub get_get_attribute_prefix {
my $type = shift;
my $interface = shift;
- if ((($interface eq "HTMLCollection") or ($interface eq "HTMLSelectElement")) and ($type eq "length")) {
+ if ($type eq "length") {
$prefix = "uint32_t ";
} elsif (exists $special_prefix{$type}) {
$prefix = $special_prefix{$type};
diff --git a/test/dom1-interfaces.xml b/test/dom1-interfaces.xml
index fc88b80..240f2b9 100644
--- a/test/dom1-interfaces.xml
+++ b/test/dom1-interfaces.xml
@@ -3674,4 +3674,51 @@ See W3C License http://www.w3.org/Consortium/Legal/ for more details.
</attribute>
</interface>
+<interface name="HTMLOptionsCollection" id="ID-75708506">
+<descr>
+<p>An<code>HTMLOptionsCollection</code>is a list of nodes. An individual node may be accessed by either ordinal index or the node's<code>name</code>or<code>id</code>attributes.<emph>Note:</emph>Collections in the HTML DOM are assumed to be<emph>live</emph>meaning that they are automatically updated when the underlying document is changed.</p>
+</descr>
+<attribute readonly="yes" type="unsigned long" name="length" id="ID-40057551">
+<descr>
+<p>This attribute specifies the length or<emph>size</emph>of the list.</p>
+</descr>
+</attribute>
+<method name="item" id="ID-33262535">
+<descr>
+<p>This method retrieves a node specified by ordinal index. Nodes are numbered in tree order (depth-first traversal order).</p>
+</descr>
+<parameters>
+<param id="ID-3496656" name="index" type="unsigned long" attr="in">
+<descr>
+<p>The index of the node to be fetched. The index origin is 0.</p>
+</descr>
+</param>
+</parameters>
+<returns type="Node">
+<descr>
+<p>The<code>Node</code>at the corresponding position upon success. A value of<code>null</code>is returned if the index is out of range.</p>
+</descr>
+</returns>
+<raises/>
+</method>
+<method name="namedItem" id="ID-21069976">
+<descr>
+<p>This method retrieves a<code>Node</code>using a name. It first searches for a<code>Node</code>with a matching<code>id</code>attribute. If it doesn't find one, it then searches for a<code>Node</code>with a matching<code>name</code>attribute, but only on those elements that are allowed a name attribute.</p>
+</descr>
+<parameters>
+<param id="ID-76682631" name="name" type="DOMString" attr="in">
+<descr>
+<p>The name of the<code>Node</code>to be fetched.</p>
+</descr>
+</param>
+</parameters>
+<returns type="Node">
+<descr>
+<p>The<code>Node</code>with a<code>name</code>or<code>id</code>attribute whose value corresponds to the specified string. Upon failure (e.g., no node with this name exists), returns<code>null</code>.</p>
+</descr>
+</returns>
+<raises/>
+</method>
+</interface>
+
</library>
diff --git a/test/testcases/tests/level2/html/HTMLOptionsCollection01.xml b/test/testcases/tests/level2/html/HTMLOptionsCollection01.xml
new file mode 100644
index 0000000..80df1a3
--- /dev/null
+++ b/test/testcases/tests/level2/html/HTMLOptionsCollection01.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+
+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 "dom2.dtd">
+<test xmlns="http://www.w3.org/2001/DOM-Test-Suite/Level-2" name="HTMLOptionsCollection01">
+<metadata>
+<title>HTMLOptionsCollection01</title>
+<creator>NIST</creator>
+<description>
+ An HTMLOptionsCollection is a list of nodes representing HTML option
+ element.
+ The length attribute specifies the length or size of the list.
+
+ Retrieve the first SELECT element and create a HTMLOptionsCollection
+ of the OPTION elements. Check the size of the length of OPTION elements.
+</description>
+<contributor>Rick Rivello</contributor>
+<date qualifier="created">2002-08-01</date>
+<subject resource="http://www.w3.org/TR/DOM-Level-2-HTML/html#HTMLOptionsCollection-length"/>
+</metadata>
+<var name="nodeList" type="NodeList"/>
+<var name="testNode" type="Node"/>
+<var name="optionsList" type="HTMLOptionsCollection"/>
+<var name="vlength" type="int"/>
+<var name="doc" type="Document"/>
+<load var="doc" href="optionscollection" willBeModified="false"/>
+<getElementsByTagName interface="Document" obj="doc" var="nodeList" tagname='"select"'/>
+<assertSize collection="nodeList" size="2" id="Asize"/>
+<item interface="NodeList" obj="nodeList" var="testNode" index="0"/>
+<options interface="HTMLSelectElement" obj="testNode" var="optionsList"/>
+<length interface="HTMLOptionsCollection" obj="optionsList" var="vlength"/>
+<assertEquals actual="vlength" expected="5" id="lengthLink" ignoreCase="false"/>
+</test>
diff --git a/test/testcases/tests/level2/html/HTMLOptionsCollection01.xml.kfail b/test/testcases/tests/level2/html/HTMLOptionsCollection01.xml.kfail
deleted file mode 100644
index 80df1a3..0000000
--- a/test/testcases/tests/level2/html/HTMLOptionsCollection01.xml.kfail
+++ /dev/null
@@ -1,46 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
-
-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 "dom2.dtd">
-<test xmlns="http://www.w3.org/2001/DOM-Test-Suite/Level-2" name="HTMLOptionsCollection01">
-<metadata>
-<title>HTMLOptionsCollection01</title>
-<creator>NIST</creator>
-<description>
- An HTMLOptionsCollection is a list of nodes representing HTML option
- element.
- The length attribute specifies the length or size of the list.
-
- Retrieve the first SELECT element and create a HTMLOptionsCollection
- of the OPTION elements. Check the size of the length of OPTION elements.
-</description>
-<contributor>Rick Rivello</contributor>
-<date qualifier="created">2002-08-01</date>
-<subject resource="http://www.w3.org/TR/DOM-Level-2-HTML/html#HTMLOptionsCollection-length"/>
-</metadata>
-<var name="nodeList" type="NodeList"/>
-<var name="testNode" type="Node"/>
-<var name="optionsList" type="HTMLOptionsCollection"/>
-<var name="vlength" type="int"/>
-<var name="doc" type="Document"/>
-<load var="doc" href="optionscollection" willBeModified="false"/>
-<getElementsByTagName interface="Document" obj="doc" var="nodeList" tagname='"select"'/>
-<assertSize collection="nodeList" size="2" id="Asize"/>
-<item interface="NodeList" obj="nodeList" var="testNode" index="0"/>
-<options interface="HTMLSelectElement" obj="testNode" var="optionsList"/>
-<length interface="HTMLOptionsCollection" obj="optionsList" var="vlength"/>
-<assertEquals actual="vlength" expected="5" id="lengthLink" ignoreCase="false"/>
-</test>
diff --git a/test/testcases/tests/level2/html/HTMLOptionsCollection02.xml b/test/testcases/tests/level2/html/HTMLOptionsCollection02.xml
new file mode 100644
index 0000000..44b5431
--- /dev/null
+++ b/test/testcases/tests/level2/html/HTMLOptionsCollection02.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+
+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 "dom2.dtd">
+<test xmlns="http://www.w3.org/2001/DOM-Test-Suite/Level-2" name="HTMLOptionsCollection02">
+<metadata>
+<title>HTMLOptionsCollection02</title>
+<creator>NIST</creator>
+<description>
+ An HTMLOptionsCollection is a list of nodes representing HTML option
+ element.
+ An individual node may be accessed by either ordinal index, the node's
+ name or id attributes. (Test ordinal index=3).
+ The item() method retrieves a node specified by ordinal index.
+ Nodes are numbered in tree order. The index origin is 0.
+
+ Retrieve the first SELECT element. Create a HTMLOptionsCollection.
+ Retrieve the fourth item in the list and examine its firstChild's
+ nodeValue.
+</description>
+<contributor>Rick Rivello</contributor>
+<date qualifier="created">2002-08-01</date>
+<subject resource="http://www.w3.org/TR/DOM-Level-2-HTML/html#HTMLOptionsCollection-item"/>
+</metadata>
+<var name="nodeList" type="NodeList"/>
+<var name="testNode" type="Node"/>
+<var name="optionsNode" type="Node"/>
+<var name="optionsValueNode" type="Node"/>
+<var name="optionsList" type="HTMLOptionsCollection"/>
+<var name="vvalue" type="DOMString"/>
+<var name="doc" type="Document"/>
+<load var="doc" href="optionscollection" willBeModified="false"/>
+<getElementsByTagName interface="Document" obj="doc" var="nodeList" tagname='"select"'/>
+<assertSize collection="nodeList" size="2" id="Asize"/>
+<item interface="NodeList" obj="nodeList" var="testNode" index="0"/>
+<options interface="HTMLSelectElement" obj="testNode" var="optionsList"/>
+<item interface="HTMLOptionsCollection" obj="optionsList" var="optionsNode" index="3"/>
+<firstChild interface="Node" obj="optionsNode" var="optionsValueNode"/>
+<nodeValue obj="optionsValueNode" var="vvalue"/>
+<assertEquals actual="vvalue" expected='"EMP10004"' id="valueIndexLink" ignoreCase="false"/>
+</test>
diff --git a/test/testcases/tests/level2/html/HTMLOptionsCollection02.xml.kfail b/test/testcases/tests/level2/html/HTMLOptionsCollection02.xml.kfail
deleted file mode 100644
index 44b5431..0000000
--- a/test/testcases/tests/level2/html/HTMLOptionsCollection02.xml.kfail
+++ /dev/null
@@ -1,54 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
-
-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 "dom2.dtd">
-<test xmlns="http://www.w3.org/2001/DOM-Test-Suite/Level-2" name="HTMLOptionsCollection02">
-<metadata>
-<title>HTMLOptionsCollection02</title>
-<creator>NIST</creator>
-<description>
- An HTMLOptionsCollection is a list of nodes representing HTML option
- element.
- An individual node may be accessed by either ordinal index, the node's
- name or id attributes. (Test ordinal index=3).
- The item() method retrieves a node specified by ordinal index.
- Nodes are numbered in tree order. The index origin is 0.
-
- Retrieve the first SELECT element. Create a HTMLOptionsCollection.
- Retrieve the fourth item in the list and examine its firstChild's
- nodeValue.
-</description>
-<contributor>Rick Rivello</contributor>
-<date qualifier="created">2002-08-01</date>
-<subject resource="http://www.w3.org/TR/DOM-Level-2-HTML/html#HTMLOptionsCollection-item"/>
-</metadata>
-<var name="nodeList" type="NodeList"/>
-<var name="testNode" type="Node"/>
-<var name="optionsNode" type="Node"/>
-<var name="optionsValueNode" type="Node"/>
-<var name="optionsList" type="HTMLOptionsCollection"/>
-<var name="vvalue" type="DOMString"/>
-<var name="doc" type="Document"/>
-<load var="doc" href="optionscollection" willBeModified="false"/>
-<getElementsByTagName interface="Document" obj="doc" var="nodeList" tagname='"select"'/>
-<assertSize collection="nodeList" size="2" id="Asize"/>
-<item interface="NodeList" obj="nodeList" var="testNode" index="0"/>
-<options interface="HTMLSelectElement" obj="testNode" var="optionsList"/>
-<item interface="HTMLOptionsCollection" obj="optionsList" var="optionsNode" index="3"/>
-<firstChild interface="Node" obj="optionsNode" var="optionsValueNode"/>
-<nodeValue obj="optionsValueNode" var="vvalue"/>
-<assertEquals actual="vvalue" expected='"EMP10004"' id="valueIndexLink" ignoreCase="false"/>
-</test>
diff --git a/test/testcases/tests/level2/html/HTMLOptionsCollection03.xml b/test/testcases/tests/level2/html/HTMLOptionsCollection03.xml
new file mode 100644
index 0000000..280b2bf
--- /dev/null
+++ b/test/testcases/tests/level2/html/HTMLOptionsCollection03.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+
+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 "dom2.dtd">
+<test xmlns="http://www.w3.org/2001/DOM-Test-Suite/Level-2" name="HTMLOptionsCollection03">
+<metadata>
+<title>HTMLOptionsCollection03</title>
+<creator>NIST</creator>
+<description>
+ An HTMLOptionsCollection is a list of nodes representing HTML option
+ element.
+ An individual node may be accessed by either ordinal index, the node's
+ name or id attributes. (Test node name).
+ The namedItem method retrieves a Node using a name. It first searches
+ for a node with a matching id attribute. If it doesn't find one, it
+ then searches for a Node with a matching name attribute, but only
+ those elements that are allowed a name attribute.
+
+ Retrieve the first FORM element. Create a HTMLCollection of the elements.
+ Search for an element that has select1 as the value for the name attribute.
+ Get the nodeName of that element.
+</description>
+<contributor>Rick Rivello</contributor>
+<date qualifier="created">2002-08-01</date>
+<subject resource="http://www.w3.org/TR/DOM-Level-2-HTML/html#HTMLOptionsCollection-namedItem"/>
+</metadata>
+<var name="nodeList" type="NodeList"/>
+<var name="testNode" type="Node"/>
+<var name="optionsNode" type="Node"/>
+<var name="formsnodeList" type="HTMLCollection"/>
+<var name="vname" type="DOMString"/>
+<var name="doc" type="Document"/>
+<load var="doc" href="optionscollection" willBeModified="false"/>
+<getElementsByTagName interface="Document" obj="doc" var="nodeList" tagname='"form"'/>
+<assertSize collection="nodeList" size="1" id="Asize"/>
+<item interface="NodeList" obj="nodeList" var="testNode" index="0"/>
+<elements interface="HTMLFormElement" obj="testNode" var="formsnodeList"/>
+<namedItem interface="HTMLOptionsCollection" obj="formsnodeList" var="optionsNode" name='"select1"'/>
+<nodeName obj="optionsNode" var="vname"/>
+<assertEquals actual="vname" expected='"select"' id="nameIndexLink" ignoreCase="auto"/>
+</test>
diff --git a/test/testcases/tests/level2/html/HTMLOptionsCollection03.xml.kfail b/test/testcases/tests/level2/html/HTMLOptionsCollection03.xml.kfail
deleted file mode 100644
index 280b2bf..0000000
--- a/test/testcases/tests/level2/html/HTMLOptionsCollection03.xml.kfail
+++ /dev/null
@@ -1,54 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
-
-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 "dom2.dtd">
-<test xmlns="http://www.w3.org/2001/DOM-Test-Suite/Level-2" name="HTMLOptionsCollection03">
-<metadata>
-<title>HTMLOptionsCollection03</title>
-<creator>NIST</creator>
-<description>
- An HTMLOptionsCollection is a list of nodes representing HTML option
- element.
- An individual node may be accessed by either ordinal index, the node's
- name or id attributes. (Test node name).
- The namedItem method retrieves a Node using a name. It first searches
- for a node with a matching id attribute. If it doesn't find one, it
- then searches for a Node with a matching name attribute, but only
- those elements that are allowed a name attribute.
-
- Retrieve the first FORM element. Create a HTMLCollection of the elements.
- Search for an element that has select1 as the value for the name attribute.
- Get the nodeName of that element.
-</description>
-<contributor>Rick Rivello</contributor>
-<date qualifier="created">2002-08-01</date>
-<subject resource="http://www.w3.org/TR/DOM-Level-2-HTML/html#HTMLOptionsCollection-namedItem"/>
-</metadata>
-<var name="nodeList" type="NodeList"/>
-<var name="testNode" type="Node"/>
-<var name="optionsNode" type="Node"/>
-<var name="formsnodeList" type="HTMLCollection"/>
-<var name="vname" type="DOMString"/>
-<var name="doc" type="Document"/>
-<load var="doc" href="optionscollection" willBeModified="false"/>
-<getElementsByTagName interface="Document" obj="doc" var="nodeList" tagname='"form"'/>
-<assertSize collection="nodeList" size="1" id="Asize"/>
-<item interface="NodeList" obj="nodeList" var="testNode" index="0"/>
-<elements interface="HTMLFormElement" obj="testNode" var="formsnodeList"/>
-<namedItem interface="HTMLOptionsCollection" obj="formsnodeList" var="optionsNode" name='"select1"'/>
-<nodeName obj="optionsNode" var="vname"/>
-<assertEquals actual="vname" expected='"select"' id="nameIndexLink" ignoreCase="auto"/>
-</test>
diff --git a/test/testcases/tests/level2/html/HTMLOptionsCollection04.xml b/test/testcases/tests/level2/html/HTMLOptionsCollection04.xml
new file mode 100644
index 0000000..83e59d3
--- /dev/null
+++ b/test/testcases/tests/level2/html/HTMLOptionsCollection04.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+
+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 "dom2.dtd">
+<test xmlns="http://www.w3.org/2001/DOM-Test-Suite/Level-2" name="HTMLOptionsCollection04">
+<metadata>
+<title>HTMLOptionsCollection04</title>
+<creator>NIST</creator>
+<description>
+ An HTMLOptionsCollection is a list of nodes representing HTML option
+ element.
+ An individual node may be accessed by either ordinal index, the node's
+ name or id attributes. (Test node name).
+ The namedItem method retrieves a Node using a name. It first searches
+ for a node with a matching id attribute. If it doesn't find one, it
+ then searches for a Node with a matching name attribute, but only
+ those elements that are allowed a name attribute.
+
+ Retrieve the first FORM element. Create a HTMLCollection of the elements.
+ Search for an element that has selectId as the value for the id attribute.
+ Get the nodeName of that element.
+</description>
+<contributor>Rick Rivello</contributor>
+<date qualifier="created">2002-08-01</date>
+<subject resource="http://www.w3.org/TR/DOM-Level-2-HTML/html#HTMLOptionsCollection-namedItem"/>
+</metadata>
+<var name="nodeList" type="NodeList"/>
+<var name="testNode" type="Node"/>
+<var name="optionsNode" type="Node"/>
+<var name="formsnodeList" type="HTMLCollection"/>
+<var name="vname" type="DOMString"/>
+<var name="doc" type="Document"/>
+<load var="doc" href="optionscollection" willBeModified="false"/>
+<getElementsByTagName interface="Document" obj="doc" var="nodeList" tagname='"form"'/>
+<assertSize collection="nodeList" size="1" id="Asize"/>
+<item interface="NodeList" obj="nodeList" var="testNode" index="0"/>
+<elements interface="HTMLFormElement" obj="testNode" var="formsnodeList"/>
+<namedItem interface="HTMLOptionsCollection" obj="formsnodeList" var="optionsNode" name='"selectId"'/>
+<nodeName obj="optionsNode" var="vname"/>
+<assertEquals actual="vname" expected='"select"' id="nameIndexLink" ignoreCase="auto"/>
+</test>
diff --git a/test/testcases/tests/level2/html/HTMLOptionsCollection04.xml.kfail b/test/testcases/tests/level2/html/HTMLOptionsCollection04.xml.kfail
deleted file mode 100644
index 83e59d3..0000000
--- a/test/testcases/tests/level2/html/HTMLOptionsCollection04.xml.kfail
+++ /dev/null
@@ -1,54 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
-
-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 "dom2.dtd">
-<test xmlns="http://www.w3.org/2001/DOM-Test-Suite/Level-2" name="HTMLOptionsCollection04">
-<metadata>
-<title>HTMLOptionsCollection04</title>
-<creator>NIST</creator>
-<description>
- An HTMLOptionsCollection is a list of nodes representing HTML option
- element.
- An individual node may be accessed by either ordinal index, the node's
- name or id attributes. (Test node name).
- The namedItem method retrieves a Node using a name. It first searches
- for a node with a matching id attribute. If it doesn't find one, it
- then searches for a Node with a matching name attribute, but only
- those elements that are allowed a name attribute.
-
- Retrieve the first FORM element. Create a HTMLCollection of the elements.
- Search for an element that has selectId as the value for the id attribute.
- Get the nodeName of that element.
-</description>
-<contributor>Rick Rivello</contributor>
-<date qualifier="created">2002-08-01</date>
-<subject resource="http://www.w3.org/TR/DOM-Level-2-HTML/html#HTMLOptionsCollection-namedItem"/>
-</metadata>
-<var name="nodeList" type="NodeList"/>
-<var name="testNode" type="Node"/>
-<var name="optionsNode" type="Node"/>
-<var name="formsnodeList" type="HTMLCollection"/>
-<var name="vname" type="DOMString"/>
-<var name="doc" type="Document"/>
-<load var="doc" href="optionscollection" willBeModified="false"/>
-<getElementsByTagName interface="Document" obj="doc" var="nodeList" tagname='"form"'/>
-<assertSize collection="nodeList" size="1" id="Asize"/>
-<item interface="NodeList" obj="nodeList" var="testNode" index="0"/>
-<elements interface="HTMLFormElement" obj="testNode" var="formsnodeList"/>
-<namedItem interface="HTMLOptionsCollection" obj="formsnodeList" var="optionsNode" name='"selectId"'/>
-<nodeName obj="optionsNode" var="vname"/>
-<assertEquals actual="vname" expected='"select"' id="nameIndexLink" ignoreCase="auto"/>
-</test>
diff --git a/test/testcases/tests/level2/html/HTMLOptionsCollection05.xml b/test/testcases/tests/level2/html/HTMLOptionsCollection05.xml
new file mode 100644
index 0000000..d2f44d7
--- /dev/null
+++ b/test/testcases/tests/level2/html/HTMLOptionsCollection05.xml
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+
+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 "dom2.dtd">
+<test xmlns="http://www.w3.org/2001/DOM-Test-Suite/Level-2" name="HTMLOptionsCollection05">
+<metadata>
+<title>HTMLOptionsCollection05</title>
+<creator>NIST</creator>
+<description>
+ An HTMLOptionsCollection is a list of nodes representing HTML option
+ element.
+ An individual node may be accessed by either ordinal index, the node's
+ name or id attributes. (Test node name).
+ The namedItem method retrieves a Node using a name. It first searches
+ for a node with a matching id attribute. If it doesn't find one, it
+ then searches for a Node with a matching name attribute, but only
+ those elements that are allowed a name attribute. Upon failure(e.q., no
+ node with this name exists), returns null.
+
+ Retrieve the first FORM element. Create a HTMLCollection of the elements.
+ Search for an element that has select9 as the value for the name attribute.
+ Null should be returned since there is not any name or id attribute with
+ select9 as a value.
+</description>
+<contributor>Rick Rivello</contributor>
+<date qualifier="created">2002-08-01</date>
+<subject resource="http://www.w3.org/TR/DOM-Level-2-HTML/html#HTMLOptionsCollection-namedItem"/>
+</metadata>
+<var name="nodeList" type="NodeList"/>
+<var name="testNode" type="Node"/>
+<var name="optionsNode" type="Node"/>
+<var name="formsnodeList" type="HTMLCollection"/>
+<var name="vname" type="DOMString"/>
+<var name="doc" type="Document"/>
+<load var="doc" href="optionscollection" willBeModified="false"/>
+<getElementsByTagName interface="Document" obj="doc" var="nodeList" tagname='"form"'/>
+<assertSize collection="nodeList" size="1" id="Asize"/>
+<item interface="NodeList" obj="nodeList" var="testNode" index="0"/>
+<elements interface="HTMLFormElement" obj="testNode" var="formsnodeList"/>
+<namedItem interface="HTMLOptionsCollection" obj="formsnodeList" var="optionsNode" name='"select9"'/>
+<assertNull actual="optionsNode" id="nameIndexLink"/>
+</test>
diff --git a/test/testcases/tests/level2/html/HTMLOptionsCollection05.xml.kfail b/test/testcases/tests/level2/html/HTMLOptionsCollection05.xml.kfail
deleted file mode 100644
index d2f44d7..0000000
--- a/test/testcases/tests/level2/html/HTMLOptionsCollection05.xml.kfail
+++ /dev/null
@@ -1,55 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
-
-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 "dom2.dtd">
-<test xmlns="http://www.w3.org/2001/DOM-Test-Suite/Level-2" name="HTMLOptionsCollection05">
-<metadata>
-<title>HTMLOptionsCollection05</title>
-<creator>NIST</creator>
-<description>
- An HTMLOptionsCollection is a list of nodes representing HTML option
- element.
- An individual node may be accessed by either ordinal index, the node's
- name or id attributes. (Test node name).
- The namedItem method retrieves a Node using a name. It first searches
- for a node with a matching id attribute. If it doesn't find one, it
- then searches for a Node with a matching name attribute, but only
- those elements that are allowed a name attribute. Upon failure(e.q., no
- node with this name exists), returns null.
-
- Retrieve the first FORM element. Create a HTMLCollection of the elements.
- Search for an element that has select9 as the value for the name attribute.
- Null should be returned since there is not any name or id attribute with
- select9 as a value.
-</description>
-<contributor>Rick Rivello</contributor>
-<date qualifier="created">2002-08-01</date>
-<subject resource="http://www.w3.org/TR/DOM-Level-2-HTML/html#HTMLOptionsCollection-namedItem"/>
-</metadata>
-<var name="nodeList" type="NodeList"/>
-<var name="testNode" type="Node"/>
-<var name="optionsNode" type="Node"/>
-<var name="formsnodeList" type="HTMLCollection"/>
-<var name="vname" type="DOMString"/>
-<var name="doc" type="Document"/>
-<load var="doc" href="optionscollection" willBeModified="false"/>
-<getElementsByTagName interface="Document" obj="doc" var="nodeList" tagname='"form"'/>
-<assertSize collection="nodeList" size="1" id="Asize"/>
-<item interface="NodeList" obj="nodeList" var="testNode" index="0"/>
-<elements interface="HTMLFormElement" obj="testNode" var="formsnodeList"/>
-<namedItem interface="HTMLOptionsCollection" obj="formsnodeList" var="optionsNode" name='"select9"'/>
-<assertNull actual="optionsNode" id="nameIndexLink"/>
-</test>
diff --git a/test/testcases/tests/level2/html/HTMLOptionsCollection06.xml b/test/testcases/tests/level2/html/HTMLOptionsCollection06.xml
new file mode 100644
index 0000000..fbde429
--- /dev/null
+++ b/test/testcases/tests/level2/html/HTMLOptionsCollection06.xml
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+
+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 "dom2.dtd">
+<test xmlns="http://www.w3.org/2001/DOM-Test-Suite/Level-2" name="HTMLOptionsCollection06">
+<metadata>
+<title>HTMLOptionsCollection06</title>
+<creator>NIST</creator>
+<description>
+ An HTMLOptionsCollection is a list of nodes representing HTML option
+ element.
+ An individual node may be accessed by either ordinal index, the node's
+ name or id attributes. (Test ordinal index).
+ The item() method retrieves a node specified by ordinal index.
+ A value of null is returned if the index is out of range.
+
+ Retrieve the first SELECT element. Create a HTMLOptionsCollection.
+ Retrieve the tenth item in the list - null should be returned since
+ there are not 10 items in the list.
+</description>
+<contributor>Rick Rivello</contributor>
+<date qualifier="created">2002-08-01</date>
+<subject resource="http://www.w3.org/TR/DOM-Level-2-HTML/html#HTMLOptionsCollection-item"/>
+</metadata>
+<var name="nodeList" type="NodeList"/>
+<var name="testNode" type="Node"/>
+<var name="optionsNode" type="Node"/>
+<var name="optionsValueNode" type="Node"/>
+<var name="optionsList" type="HTMLOptionsCollection"/>
+<var name="vvalue" type="DOMString"/>
+<var name="doc" type="Document"/>
+<load var="doc" href="optionscollection" willBeModified="false"/>
+<getElementsByTagName interface="Document" obj="doc" var="nodeList" tagname='"select"'/>
+<assertSize collection="nodeList" size="2" id="Asize"/>
+<item interface="NodeList" obj="nodeList" var="testNode" index="0"/>
+<options interface="HTMLSelectElement" obj="testNode" var="optionsList"/>
+<item interface="HTMLOptionsCollection" obj="optionsList" var="optionsNode" index="10"/>
+<assertNull actual="optionsNode" id="optionsIndexLink"/>
+</test>
diff --git a/test/testcases/tests/level2/html/HTMLOptionsCollection06.xml.kfail b/test/testcases/tests/level2/html/HTMLOptionsCollection06.xml.kfail
deleted file mode 100644
index fbde429..0000000
--- a/test/testcases/tests/level2/html/HTMLOptionsCollection06.xml.kfail
+++ /dev/null
@@ -1,52 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
-
-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 "dom2.dtd">
-<test xmlns="http://www.w3.org/2001/DOM-Test-Suite/Level-2" name="HTMLOptionsCollection06">
-<metadata>
-<title>HTMLOptionsCollection06</title>
-<creator>NIST</creator>
-<description>
- An HTMLOptionsCollection is a list of nodes representing HTML option
- element.
- An individual node may be accessed by either ordinal index, the node's
- name or id attributes. (Test ordinal index).
- The item() method retrieves a node specified by ordinal index.
- A value of null is returned if the index is out of range.
-
- Retrieve the first SELECT element. Create a HTMLOptionsCollection.
- Retrieve the tenth item in the list - null should be returned since
- there are not 10 items in the list.
-</description>
-<contributor>Rick Rivello</contributor>
-<date qualifier="created">2002-08-01</date>
-<subject resource="http://www.w3.org/TR/DOM-Level-2-HTML/html#HTMLOptionsCollection-item"/>
-</metadata>
-<var name="nodeList" type="NodeList"/>
-<var name="testNode" type="Node"/>
-<var name="optionsNode" type="Node"/>
-<var name="optionsValueNode" type="Node"/>
-<var name="optionsList" type="HTMLOptionsCollection"/>
-<var name="vvalue" type="DOMString"/>
-<var name="doc" type="Document"/>
-<load var="doc" href="optionscollection" willBeModified="false"/>
-<getElementsByTagName interface="Document" obj="doc" var="nodeList" tagname='"select"'/>
-<assertSize collection="nodeList" size="2" id="Asize"/>
-<item interface="NodeList" obj="nodeList" var="testNode" index="0"/>
-<options interface="HTMLSelectElement" obj="testNode" var="optionsList"/>
-<item interface="HTMLOptionsCollection" obj="optionsList" var="optionsNode" index="10"/>
-<assertNull actual="optionsNode" id="optionsIndexLink"/>
-</test>
diff --git a/test/testcases/tests/level2/html/HTMLOptionsCollection07.xml b/test/testcases/tests/level2/html/HTMLOptionsCollection07.xml
new file mode 100644
index 0000000..a2731e5
--- /dev/null
+++ b/test/testcases/tests/level2/html/HTMLOptionsCollection07.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+
+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 "dom2.dtd">
+<test xmlns="http://www.w3.org/2001/DOM-Test-Suite/Level-2" name="HTMLOptionsCollection07">
+<metadata>
+<title>HTMLOptionsCollection07</title>
+<creator>NIST</creator>
+<description>
+ An HTMLOptionsCollection is a list of nodes representing HTML option
+ element.
+ An individual node may be accessed by either ordinal index, the node's
+ name or id attributes. (Test ordinal index=0).
+ The item() method retrieves a node specified by ordinal index. Nodes
+ are numbered in tree order. The index origin is 0.
+
+ Retrieve the first SELECT element. Create a HTMLOptionsCollection.
+ Retrieve the first item in the list and examine its firstChild's
+ nodeValue.
+</description>
+<contributor>Rick Rivello</contributor>
+<date qualifier="created">2002-08-01</date>
+<subject resource="http://www.w3.org/TR/DOM-Level-2-HTML/html#HTMLOptionsCollection-item"/>
+</metadata>
+<var name="nodeList" type="NodeList"/>
+<var name="testNode" type="Node"/>
+<var name="optionsNode" type="Node"/>
+<var name="optionsValueNode" type="Node"/>
+<var name="optionsList" type="HTMLOptionsCollection"/>
+<var name="vvalue" type="DOMString"/>
+<var name="doc" type="Document"/>
+<load var="doc" href="optionscollection" willBeModified="false"/>
+<getElementsByTagName interface="Document" obj="doc" var="nodeList" tagname='"select"'/>
+<assertSize collection="nodeList" size="2" id="Asize"/>
+<item interface="NodeList" obj="nodeList" var="testNode" index="0"/>
+<options interface="HTMLSelectElement" obj="testNode" var="optionsList"/>
+<item interface="HTMLOptionsCollection" obj="optionsList" var="optionsNode" index="0"/>
+<firstChild interface="Node" obj="optionsNode" var="optionsValueNode"/>
+<nodeValue obj="optionsValueNode" var="vvalue"/>
+<assertEquals actual="vvalue" expected='"EMP10001"' id="valueIndexLink" ignoreCase="false"/>
+</test>
diff --git a/test/testcases/tests/level2/html/HTMLOptionsCollection07.xml.kfail b/test/testcases/tests/level2/html/HTMLOptionsCollection07.xml.kfail
deleted file mode 100644
index a2731e5..0000000
--- a/test/testcases/tests/level2/html/HTMLOptionsCollection07.xml.kfail
+++ /dev/null
@@ -1,54 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
-
-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 "dom2.dtd">
-<test xmlns="http://www.w3.org/2001/DOM-Test-Suite/Level-2" name="HTMLOptionsCollection07">
-<metadata>
-<title>HTMLOptionsCollection07</title>
-<creator>NIST</creator>
-<description>
- An HTMLOptionsCollection is a list of nodes representing HTML option
- element.
- An individual node may be accessed by either ordinal index, the node's
- name or id attributes. (Test ordinal index=0).
- The item() method retrieves a node specified by ordinal index. Nodes
- are numbered in tree order. The index origin is 0.
-
- Retrieve the first SELECT element. Create a HTMLOptionsCollection.
- Retrieve the first item in the list and examine its firstChild's
- nodeValue.
-</description>
-<contributor>Rick Rivello</contributor>
-<date qualifier="created">2002-08-01</date>
-<subject resource="http://www.w3.org/TR/DOM-Level-2-HTML/html#HTMLOptionsCollection-item"/>
-</metadata>
-<var name="nodeList" type="NodeList"/>
-<var name="testNode" type="Node"/>
-<var name="optionsNode" type="Node"/>
-<var name="optionsValueNode" type="Node"/>
-<var name="optionsList" type="HTMLOptionsCollection"/>
-<var name="vvalue" type="DOMString"/>
-<var name="doc" type="Document"/>
-<load var="doc" href="optionscollection" willBeModified="false"/>
-<getElementsByTagName interface="Document" obj="doc" var="nodeList" tagname='"select"'/>
-<assertSize collection="nodeList" size="2" id="Asize"/>
-<item interface="NodeList" obj="nodeList" var="testNode" index="0"/>
-<options interface="HTMLSelectElement" obj="testNode" var="optionsList"/>
-<item interface="HTMLOptionsCollection" obj="optionsList" var="optionsNode" index="0"/>
-<firstChild interface="Node" obj="optionsNode" var="optionsValueNode"/>
-<nodeValue obj="optionsValueNode" var="vvalue"/>
-<assertEquals actual="vvalue" expected='"EMP10001"' id="valueIndexLink" ignoreCase="false"/>
-</test>
-----------------------------------------------------------------------
Summary of changes:
src/html/html_options_collection.c | 4 +-
test/DOMTSHandler.pm | 3 +-
test/dom1-interfaces.xml | 47 ++++++++++++++++++++
...ion01.xml.kfail => HTMLOptionsCollection01.xml} | 0
...ion02.xml.kfail => HTMLOptionsCollection02.xml} | 0
...ion03.xml.kfail => HTMLOptionsCollection03.xml} | 0
...ion04.xml.kfail => HTMLOptionsCollection04.xml} | 0
...ion05.xml.kfail => HTMLOptionsCollection05.xml} | 0
...ion06.xml.kfail => HTMLOptionsCollection06.xml} | 0
...ion07.xml.kfail => HTMLOptionsCollection07.xml} | 0
10 files changed, 51 insertions(+), 3 deletions(-)
rename test/testcases/tests/level2/html/{HTMLOptionsCollection01.xml.kfail => HTMLOptionsCollection01.xml} (100%)
rename test/testcases/tests/level2/html/{HTMLOptionsCollection02.xml.kfail => HTMLOptionsCollection02.xml} (100%)
rename test/testcases/tests/level2/html/{HTMLOptionsCollection03.xml.kfail => HTMLOptionsCollection03.xml} (100%)
rename test/testcases/tests/level2/html/{HTMLOptionsCollection04.xml.kfail => HTMLOptionsCollection04.xml} (100%)
rename test/testcases/tests/level2/html/{HTMLOptionsCollection05.xml.kfail => HTMLOptionsCollection05.xml} (100%)
rename test/testcases/tests/level2/html/{HTMLOptionsCollection06.xml.kfail => HTMLOptionsCollection06.xml} (100%)
rename test/testcases/tests/level2/html/{HTMLOptionsCollection07.xml.kfail => HTMLOptionsCollection07.xml} (100%)
diff --git a/src/html/html_options_collection.c b/src/html/html_options_collection.c
index 85001ad..3e06915 100644
--- a/src/html/html_options_collection.c
+++ b/src/html/html_options_collection.c
@@ -190,13 +190,13 @@ dom_exception dom_html_options_collection_named_item(dom_html_options_collection
/* No children and siblings */
struct dom_node_internal *parent = n->parent;
- while (parent != col->base.root &&
+ while (n != col->base.root &&
n == parent->last_child) {
n = parent;
parent = parent->parent;
}
- if (parent == col->base.root)
+ if (n == col->base.root)
n = NULL;
else
n = n->next;
diff --git a/test/DOMTSHandler.pm b/test/DOMTSHandler.pm
index fa71365..fec9bcb 100644
--- a/test/DOMTSHandler.pm
+++ b/test/DOMTSHandler.pm
@@ -48,6 +48,7 @@ our %special_type = (
HTMLTableSectionElement => "dom_html_table_section_element *",
HTMLTableElement => "dom_html_table_element *",
HTMLTableRowElement => "dom_html_table_row_element *",
+ HTMLOptionsCollection => "dom_html_options_collection *",
);
our %special_prefix = (
DOMString => "dom_string",
@@ -1491,7 +1492,7 @@ sub to_get_attribute_cast {
sub get_get_attribute_prefix {
my $type = shift;
my $interface = shift;
- if ((($interface eq "HTMLCollection") or ($interface eq "HTMLSelectElement")) and ($type eq "length")) {
+ if ($type eq "length") {
$prefix = "uint32_t ";
} elsif (exists $special_prefix{$type}) {
$prefix = $special_prefix{$type};
diff --git a/test/dom1-interfaces.xml b/test/dom1-interfaces.xml
index fc88b80..240f2b9 100644
--- a/test/dom1-interfaces.xml
+++ b/test/dom1-interfaces.xml
@@ -3674,4 +3674,51 @@ See W3C License http://www.w3.org/Consortium/Legal/ for more details.
</attribute>
</interface>
+<interface name="HTMLOptionsCollection" id="ID-75708506">
+<descr>
+<p>An<code>HTMLOptionsCollection</code>is a list of nodes. An individual node may be accessed by either ordinal index or the node's<code>name</code>or<code>id</code>attributes.<emph>Note:</emph>Collections in the HTML DOM are assumed to be<emph>live</emph>meaning that they are automatically updated when the underlying document is changed.</p>
+</descr>
+<attribute readonly="yes" type="unsigned long" name="length" id="ID-40057551">
+<descr>
+<p>This attribute specifies the length or<emph>size</emph>of the list.</p>
+</descr>
+</attribute>
+<method name="item" id="ID-33262535">
+<descr>
+<p>This method retrieves a node specified by ordinal index. Nodes are numbered in tree order (depth-first traversal order).</p>
+</descr>
+<parameters>
+<param id="ID-3496656" name="index" type="unsigned long" attr="in">
+<descr>
+<p>The index of the node to be fetched. The index origin is 0.</p>
+</descr>
+</param>
+</parameters>
+<returns type="Node">
+<descr>
+<p>The<code>Node</code>at the corresponding position upon success. A value of<code>null</code>is returned if the index is out of range.</p>
+</descr>
+</returns>
+<raises/>
+</method>
+<method name="namedItem" id="ID-21069976">
+<descr>
+<p>This method retrieves a<code>Node</code>using a name. It first searches for a<code>Node</code>with a matching<code>id</code>attribute. If it doesn't find one, it then searches for a<code>Node</code>with a matching<code>name</code>attribute, but only on those elements that are allowed a name attribute.</p>
+</descr>
+<parameters>
+<param id="ID-76682631" name="name" type="DOMString" attr="in">
+<descr>
+<p>The name of the<code>Node</code>to be fetched.</p>
+</descr>
+</param>
+</parameters>
+<returns type="Node">
+<descr>
+<p>The<code>Node</code>with a<code>name</code>or<code>id</code>attribute whose value corresponds to the specified string. Upon failure (e.g., no node with this name exists), returns<code>null</code>.</p>
+</descr>
+</returns>
+<raises/>
+</method>
+</interface>
+
</library>
diff --git a/test/testcases/tests/level2/html/HTMLOptionsCollection01.xml.kfail b/test/testcases/tests/level2/html/HTMLOptionsCollection01.xml
similarity index 100%
rename from test/testcases/tests/level2/html/HTMLOptionsCollection01.xml.kfail
rename to test/testcases/tests/level2/html/HTMLOptionsCollection01.xml
diff --git a/test/testcases/tests/level2/html/HTMLOptionsCollection02.xml.kfail b/test/testcases/tests/level2/html/HTMLOptionsCollection02.xml
similarity index 100%
rename from test/testcases/tests/level2/html/HTMLOptionsCollection02.xml.kfail
rename to test/testcases/tests/level2/html/HTMLOptionsCollection02.xml
diff --git a/test/testcases/tests/level2/html/HTMLOptionsCollection03.xml.kfail b/test/testcases/tests/level2/html/HTMLOptionsCollection03.xml
similarity index 100%
rename from test/testcases/tests/level2/html/HTMLOptionsCollection03.xml.kfail
rename to test/testcases/tests/level2/html/HTMLOptionsCollection03.xml
diff --git a/test/testcases/tests/level2/html/HTMLOptionsCollection04.xml.kfail b/test/testcases/tests/level2/html/HTMLOptionsCollection04.xml
similarity index 100%
rename from test/testcases/tests/level2/html/HTMLOptionsCollection04.xml.kfail
rename to test/testcases/tests/level2/html/HTMLOptionsCollection04.xml
diff --git a/test/testcases/tests/level2/html/HTMLOptionsCollection05.xml.kfail b/test/testcases/tests/level2/html/HTMLOptionsCollection05.xml
similarity index 100%
rename from test/testcases/tests/level2/html/HTMLOptionsCollection05.xml.kfail
rename to test/testcases/tests/level2/html/HTMLOptionsCollection05.xml
diff --git a/test/testcases/tests/level2/html/HTMLOptionsCollection06.xml.kfail b/test/testcases/tests/level2/html/HTMLOptionsCollection06.xml
similarity index 100%
rename from test/testcases/tests/level2/html/HTMLOptionsCollection06.xml.kfail
rename to test/testcases/tests/level2/html/HTMLOptionsCollection06.xml
diff --git a/test/testcases/tests/level2/html/HTMLOptionsCollection07.xml.kfail b/test/testcases/tests/level2/html/HTMLOptionsCollection07.xml
similarity index 100%
rename from test/testcases/tests/level2/html/HTMLOptionsCollection07.xml.kfail
rename to test/testcases/tests/level2/html/HTMLOptionsCollection07.xml
--
Document Object Model library
9 years, 5 months
alphagen: branch master updated. 630dfaac914df94311641e5994a1798eaa0be031
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/alphagen.git/shortlog/630dfaac914df9431164...
...commit http://git.netsurf-browser.org/alphagen.git/commit/630dfaac914df94311641e...
...tree http://git.netsurf-browser.org/alphagen.git/tree/630dfaac914df94311641e59...
The branch, master has been updated
via 630dfaac914df94311641e5994a1798eaa0be031 (commit)
via 8798e2cb4467ac762c302775e52610d1f37d38f0 (commit)
from 0976a623848f537887d43e35f60ebad1ea230821 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/alphagen.git/commit/?id=630dfaac914df94311...
commit 630dfaac914df94311641e5994a1798eaa0be031
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Add support for input images with redundant alpha channels.
Some PNG exporters are daft.
diff --git a/src/alphagen.c b/src/alphagen.c
index 6ced487..a8461c7 100644
--- a/src/alphagen.c
+++ b/src/alphagen.c
@@ -266,10 +266,9 @@ bool image_read_png(char *file_name, struct image *img)
png_structp png_ptr;
png_infop info_ptr;
unsigned int sig_read = 0;
- unsigned int row_data_width;
png_uint_32 width, height;
int bit_depth, color_type;
- int i;
+ int y;
FILE *fp;
if ((fp = fopen(file_name, "rb")) == NULL)
@@ -317,17 +316,36 @@ bool image_read_png(char *file_name, struct image *img)
bit_depth = png_get_bit_depth(png_ptr, info_ptr);
color_type = png_get_color_type(png_ptr, info_ptr);
- if (color_type != PNG_COLOR_TYPE_RGB || bit_depth != 8)
+ if (color_type != PNG_COLOR_TYPE_RGB &&
+ color_type != PNG_COLOR_TYPE_RGB_ALPHA) {
+ printf("Unsupported colour format: %d\n", color_type);
+ return false;
+ }
+
+ if (bit_depth != 8) {
+ printf("Unsupported bit depth: %d\n", bit_depth);
return false;
+ }
if (!image_init(img, width, height, 3))
return false;
png_bytepp row_pointers = png_get_rows(png_ptr, info_ptr);
- row_data_width = img->width * img->channels;
- for (i = 0; i < img->height; i++) {
- memcpy(img->d[i], row_pointers[i], row_data_width);
+ if (color_type == PNG_COLOR_TYPE_RGB) {
+ unsigned int row_data_width = img->width * img->channels;
+ for (y = 0; y < img->height; y++) {
+ memcpy(img->d[y], row_pointers[y], row_data_width);
+ }
+ } else {
+ int x;
+ for (y = 0; y < img->height; y++) {
+ for (x = 0; x < img->width; x++) {
+ img->d[y][3*x + 0] = row_pointers[y][4*x + 0];
+ img->d[y][3*x + 1] = row_pointers[y][4*x + 1];
+ img->d[y][3*x + 2] = row_pointers[y][4*x + 2];
+ }
+ }
}
/* clean up after the read, and free any memory allocated */
commitdiff http://git.netsurf-browser.org/alphagen.git/commit/?id=8798e2cb4467ac762c...
commit 8798e2cb4467ac762c302775e52610d1f37d38f0
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Fix bug in detection of unsupported input colour formats.
diff --git a/src/alphagen.c b/src/alphagen.c
index 384e70b..6ced487 100644
--- a/src/alphagen.c
+++ b/src/alphagen.c
@@ -317,7 +317,7 @@ bool image_read_png(char *file_name, struct image *img)
bit_depth = png_get_bit_depth(png_ptr, info_ptr);
color_type = png_get_color_type(png_ptr, info_ptr);
- if (color_type != PNG_COLOR_TYPE_RGB && bit_depth != 8)
+ if (color_type != PNG_COLOR_TYPE_RGB || bit_depth != 8)
return false;
if (!image_init(img, width, height, 3))
-----------------------------------------------------------------------
Summary of changes:
src/alphagen.c | 30 ++++++++++++++++++++++++------
1 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/src/alphagen.c b/src/alphagen.c
index 384e70b..a8461c7 100644
--- a/src/alphagen.c
+++ b/src/alphagen.c
@@ -266,10 +266,9 @@ bool image_read_png(char *file_name, struct image *img)
png_structp png_ptr;
png_infop info_ptr;
unsigned int sig_read = 0;
- unsigned int row_data_width;
png_uint_32 width, height;
int bit_depth, color_type;
- int i;
+ int y;
FILE *fp;
if ((fp = fopen(file_name, "rb")) == NULL)
@@ -317,17 +316,36 @@ bool image_read_png(char *file_name, struct image *img)
bit_depth = png_get_bit_depth(png_ptr, info_ptr);
color_type = png_get_color_type(png_ptr, info_ptr);
- if (color_type != PNG_COLOR_TYPE_RGB && bit_depth != 8)
+ if (color_type != PNG_COLOR_TYPE_RGB &&
+ color_type != PNG_COLOR_TYPE_RGB_ALPHA) {
+ printf("Unsupported colour format: %d\n", color_type);
+ return false;
+ }
+
+ if (bit_depth != 8) {
+ printf("Unsupported bit depth: %d\n", bit_depth);
return false;
+ }
if (!image_init(img, width, height, 3))
return false;
png_bytepp row_pointers = png_get_rows(png_ptr, info_ptr);
- row_data_width = img->width * img->channels;
- for (i = 0; i < img->height; i++) {
- memcpy(img->d[i], row_pointers[i], row_data_width);
+ if (color_type == PNG_COLOR_TYPE_RGB) {
+ unsigned int row_data_width = img->width * img->channels;
+ for (y = 0; y < img->height; y++) {
+ memcpy(img->d[y], row_pointers[y], row_data_width);
+ }
+ } else {
+ int x;
+ for (y = 0; y < img->height; y++) {
+ for (x = 0; x < img->width; x++) {
+ img->d[y][3*x + 0] = row_pointers[y][4*x + 0];
+ img->d[y][3*x + 1] = row_pointers[y][4*x + 1];
+ img->d[y][3*x + 2] = row_pointers[y][4*x + 2];
+ }
+ }
}
/* clean up after the read, and free any memory allocated */
--
Bitmap alpha-channel generator
9 years, 5 months
alphagen: branch master updated. 0976a623848f537887d43e35f60ebad1ea230821
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/alphagen.git/shortlog/0976a623848f537887d4...
...commit http://git.netsurf-browser.org/alphagen.git/commit/0976a623848f537887d43e...
...tree http://git.netsurf-browser.org/alphagen.git/tree/0976a623848f537887d43e35...
The branch, master has been updated
via 0976a623848f537887d43e35f60ebad1ea230821 (commit)
via c8179e660a44083bc49f98c53b012e5e787b4515 (commit)
via 9e7a64a05995f9b9f376d03bb624279ee66834f6 (commit)
via 9484b1df333a60b72bcb8eb02c934998b82bcfda (commit)
via d8af6b79ab624a323319cd3fe1454813fb2ecf7c (commit)
via c66f77d7fa015bf80209e13366e5a38f94bc7624 (commit)
from 38d8cd804ecb52c8228c35ac90801bfc8fa39eef (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/alphagen.git/commit/?id=0976a623848f537887...
commit 0976a623848f537887d43e35f60ebad1ea230821
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Set -O2 optimisation flag.
diff --git a/Makefile b/Makefile
index a7b4462..eb4df92 100644
--- a/Makefile
+++ b/Makefile
@@ -19,6 +19,9 @@ WARNFLAGS := -Wall -W -Wundef -Wpointer-arith -Wcast-align \
-Wmissing-declarations -Wnested-externs -Wredundant-decls \
-Wuninitialized -pedantic
+# Optimisation flags
+CFLAGS += -O2
+
# libpng and libz
ifneq ($(findstring clean,$(MAKECMDGOALS)),clean)
CFLAGS := $(CFLAGS) -I$(PREFIX)/include
commitdiff http://git.netsurf-browser.org/alphagen.git/commit/?id=c8179e660a44083bc4...
commit c8179e660a44083bc49f98c53b012e5e787b4515
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Enable extra warnings.
-Wredundant-decls and -Wuninitialized
diff --git a/Makefile b/Makefile
index d0ea5d5..a7b4462 100644
--- a/Makefile
+++ b/Makefile
@@ -16,7 +16,8 @@ include $(NSSHARED)/makefiles/Makefile.tools
# Toolchain flags
WARNFLAGS := -Wall -W -Wundef -Wpointer-arith -Wcast-align \
-Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes \
- -Wmissing-declarations -Wnested-externs -pedantic
+ -Wmissing-declarations -Wnested-externs -Wredundant-decls \
+ -Wuninitialized -pedantic
# libpng and libz
ifneq ($(findstring clean,$(MAKECMDGOALS)),clean)
commitdiff http://git.netsurf-browser.org/alphagen.git/commit/?id=9e7a64a05995f9b9f3...
commit 9e7a64a05995f9b9f376d03bb624279ee66834f6
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Explicitly include string.h header.
As of libpng 1.6.0, png.h does not include string.h.
diff --git a/src/alphagen.c b/src/alphagen.c
index 2510e5e..384e70b 100644
--- a/src/alphagen.c
+++ b/src/alphagen.c
@@ -24,6 +24,7 @@
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <png.h>
commitdiff http://git.netsurf-browser.org/alphagen.git/commit/?id=9484b1df333a60b72b...
commit 9484b1df333a60b72bcb8eb02c934998b82bcfda
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
The png_sizeof() macro was made private in libpng 1.5.0.
Not exposed to applications, so just use regular sizeof.
diff --git a/src/alphagen.c b/src/alphagen.c
index d37b36c..2510e5e 100644
--- a/src/alphagen.c
+++ b/src/alphagen.c
@@ -415,7 +415,7 @@ bool image_write_png(char *file_name, struct image *img)
/* pack pixels into bytes */
png_set_packing(png_ptr);
- if (img->height > PNG_UINT_32_MAX/png_sizeof(png_bytep)) {
+ if (img->height > PNG_UINT_32_MAX / sizeof(png_bytep)) {
png_error (png_ptr, "Image is too tall to process in memory");
return false;
}
commitdiff http://git.netsurf-browser.org/alphagen.git/commit/?id=d8af6b79ab624a3233...
commit d8af6b79ab624a323319cd3fe1454813fb2ecf7c
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Don't use typecasted NULL definitions. (Removed in libpng 1.4.0)
Use plain NULL instead.
diff --git a/src/alphagen.c b/src/alphagen.c
index a60368e..d37b36c 100644
--- a/src/alphagen.c
+++ b/src/alphagen.c
@@ -287,8 +287,7 @@ bool image_read_png(char *file_name, struct image *img)
info_ptr = png_create_info_struct(png_ptr);
if (info_ptr == NULL) {
fclose(fp);
- png_destroy_read_struct(&png_ptr, png_infopp_NULL,
- png_infopp_NULL);
+ png_destroy_read_struct(&png_ptr, NULL, NULL);
return false;
}
@@ -297,7 +296,7 @@ bool image_read_png(char *file_name, struct image *img)
if (setjmp(png_jmpbuf(png_ptr))) {
/* Free all of the memory associated with the png_ptr and
* info_ptr */
- png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL);
+ png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
fclose(fp);
/* If we get here, we had a problem reading the file */
return false;
@@ -310,7 +309,7 @@ bool image_read_png(char *file_name, struct image *img)
png_set_sig_bytes(png_ptr, sig_read);
/* Read in the entire image at once */
- png_read_png(png_ptr, info_ptr, PNG_TRANSFORM_PACKING, png_voidp_NULL);
+ png_read_png(png_ptr, info_ptr, PNG_TRANSFORM_PACKING, NULL);
width = png_get_image_width(png_ptr, info_ptr);
height = png_get_image_height(png_ptr, info_ptr);
@@ -331,7 +330,7 @@ bool image_read_png(char *file_name, struct image *img)
}
/* clean up after the read, and free any memory allocated */
- png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL);
+ png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
/* close the file */
fclose(fp);
@@ -387,7 +386,7 @@ bool image_write_png(char *file_name, struct image *img)
info_ptr = png_create_info_struct(png_ptr);
if (info_ptr == NULL) {
fclose(fp);
- png_destroy_write_struct(&png_ptr, png_infopp_NULL);
+ png_destroy_write_struct(&png_ptr, NULL);
return false;
}
/* Set error handling, needed because I gave NULLs to
commitdiff http://git.netsurf-browser.org/alphagen.git/commit/?id=c66f77d7fa015bf802...
commit c66f77d7fa015bf80209e13366e5a38f94bc7624
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Change to unix line endings.
diff --git a/src/alphagen.c b/src/alphagen.c
index 1ef3bc3..a60368e 100644
--- a/src/alphagen.c
+++ b/src/alphagen.c
@@ -1,436 +1,436 @@
-/*
- * Copyright 2009-2010 Michael Drake <tlsa(a)netsurf-browser.org>
- *
- * This file is part of AlphaGen.
- *
- * Licensed under the MIT License,
- * http://www.opensource.org/licenses/mit-license.php
- *
- * AlphaGen is a tool for obtaining a bitmap image with an alpha channel from
- * software which lacks this facility itself. It recovers alpha channel
- * information from two input images; one with a black baground and one with a
- * white background.
- *
- * Inputs required:
- * + The input image exported on a _black_ background.
- * + The input image exported on a _white_ background.
- * Output:
- * + The resultant image with an alpha channel.
- *
- * Note that both images must be the same size.
- */
-
-#include <stdbool.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include <png.h>
-
-
-/* Bitmap image representation */
-struct image {
- unsigned int width;
- unsigned int height;
- unsigned int channels;
- uint8_t **d; /* data */
-};
-
-/* Main functionality of AlphaGen. */
-bool alphagen(char *black_name, char *white_name, char *alpha_name);
-bool alphagen_check_inputs(struct image *b, struct image *w);
-
-/* image_* functions, so the libpng stuff is kept hidden */
-bool image_init(struct image *img, int width, int height, int channels);
-void image_free(struct image *img);
-bool image_read_png(char *file_name, struct image *img);
-bool image_write_png(char *file_name, struct image *img);
-
-/**
- * Main entry point from OS.
- */
-int main(int argc, char** argv)
-{
- /* Validate execution arguments. */
- if (argc != 4) {
- /* Too few arguments */
- printf("Usage: %s <black> <white> <output>\n", argv[0]);
- return EXIT_FAILURE;
- }
-
- /* Generate the alpha channel bitmap. */
- if (!alphagen(argv[1], argv[2], argv[3])) {
- return EXIT_FAILURE;
- }
-
- return EXIT_SUCCESS;
-}
-
-
-/**
- * Performs alpha channel recovery on an image provided with black and white
- * backgrounds.
- *
- * \param black_name filename for black background input PNG
- * \param white_name filename for white background input PNG
- * \param alpha_name filename for output PNG
- * \return true on success, false on error
- */
-bool alphagen(char *black_name, char *white_name, char *alpha_name)
-{
- struct image b, w, a;
- unsigned int row_data_width;
- unsigned int x, y, z;
- uint8_t ar, ag, ab;
-
- /* Default background colour; 0 = black, 255 = white */
- const uint8_t bg = 255;
-
- /* Load input PNGs */
- if (!image_read_png(black_name, &b)) {
- printf("Couldn't load \"%s\" as black background input.\n",
- black_name);
- return false;
- }
- if (!image_read_png(white_name, &w)) {
- printf("Couldn't load \"%s\" as white background input.\n",
- white_name);
- return false;
- }
-
- /* Return failure if there's a problem with the input images. */
- if (!alphagen_check_inputs(&b, &w)) {
- return false;
- }
-
- /* Prepare output image */
- if (!image_init(&a, b.width, b.height, 4)) {
- printf("Couldn't create output image.\n");
- return false;
- }
-
- /* Recover true image colours and alpha channel for the image */
- row_data_width = a.width * a.channels;
- for (y = 0; y < a.height; y++) {
- z = 0; /* x-position in input images */
- for (x = 0; x < row_data_width; x += 4) {
- /* Get alpha values first */
- ar = 255 - w.d[y][z] + b.d[y][z];
- ag = 255 - w.d[y][z+1] + b.d[y][z+1];
- ab = 255 - w.d[y][z+2] + b.d[y][z+2];
-
- /* Set red, green and blue colour values
- * use preset bg colour if fully transparent */
- a.d[y][x] = (ar == 0) ? bg : (b.d[y][z] * 255) / ar;
- a.d[y][x+1] = (ag == 0) ? bg : (b.d[y][z+1] * 255) / ag;
- a.d[y][x+2] = (ab == 0) ? bg : (b.d[y][z+2] * 255) / ab;
-
- /* Set alpha value */
- a.d[y][x+3] = (ar + ag + ab) / 3;
-
- z += 3;
- }
- }
-
- /* Save PNG with recovered colour and alpha data */
- if (!image_write_png(alpha_name, &a)) {
- printf("Couldn't write output file \"%s\".\n", alpha_name);
- return false;
- }
-
- /* Free image memory */
- image_free(&b);
- image_free(&w);
- image_free(&a);
-
- return true;
-}
-
-
-/**
- * Check input images for problems
- *
- * \param b black backgrounded input image
- * \param w white backgrounded input image
- * \return true on success, false on error
- */
-bool alphagen_check_inputs(struct image *b, struct image *w)
-{
- unsigned int data_size;
- unsigned int i;
- bool opaque = true;
-
- /* Check both input images are the same size */
- if (b->width != w->width || b->height != w->height) {
- printf("Error: Input images have different dimensions.\n");
- return false;
- }
-
- /* Check input images are both the same bit depth */
- if (b->channels != w->channels || b->channels != 3) {
- /* AlphaGen should load both as 24bpp, so it's not an input
- * error, but an internal error. */
- printf("Error: Internal error.\n");
- return false;
- }
-
- /* Check that black background image is darker than white and check
- * for opaque image (identical input images). */
- data_size = b->height * b->width * b->channels;
- for (i = 0; i < data_size; i++) {
- if (b->d[0][i] > w->d[0][i]) {
- /* Black bg image is brighter than white bg image. */
- printf("Error: Black background input image has pixel "
- "brighter than White background\n"
- "input image.\n");
- return false;
- }
- if (b->d[0][i] < w->d[0][i]) {
- /* White bg image data brighter than black bg image. */
- opaque = false;
- }
- }
-
- /* If input images were identical, the image is opaque and there
- * is no alpha channel to recover. */
- if (opaque) {
- printf("Error: Input images are identical. "
- "No alpha channel to recover.\n");
- return false;
- }
-
- return true;
-}
-
-
-/**
- * Initialise an image, allocating memory for it.
- *
- * \param img pointer to image to initialise
- * \param width required image width
- * \param height required image height
- * \param channels required number of colour channels
- * \return true on success, false on error
- */
-bool image_init(struct image *img, int width, int height, int channels)
-{
- int row_data_width;
- int i;
-
- /* Set frame dimensions */
- img->width = width;
- img->height = height;
- img->channels = channels;
-
- /* Allocate memory for row pointers */
- img->d = malloc(height * sizeof(uint8_t*));
- if (img->d == NULL)
- return false;
-
- /* Allocate memory for image data */
- row_data_width = width * channels;
- img->d[0] = malloc(height * row_data_width * sizeof(uint8_t));
- if (img->d[0] == NULL)
- return false;
-
- for (i = 1; i < height; i++) {
- /* Set pointers to each row */
- img->d[i] = img->d[i - 1] + row_data_width;
- }
- return true;
-}
-
-
-/**
- * Free an image.
- *
- * \param img pointer to image to free
- */
-void image_free(struct image *img)
-{
- free(img->d[0]);
- free(img->d);
-}
-
-
-/**
- * Read RGB PNG with no alpha channel into img.
- *
- * \param file_name file to load
- * \param img pointer to image to put data in
- * \return true on success, false on error
- */
-bool image_read_png(char *file_name, struct image *img)
-{
- png_structp png_ptr;
- png_infop info_ptr;
- unsigned int sig_read = 0;
- unsigned int row_data_width;
- png_uint_32 width, height;
- int bit_depth, color_type;
- int i;
- FILE *fp;
-
- if ((fp = fopen(file_name, "rb")) == NULL)
- return false;
-
- /* Create and initialize the png_struct. */
- png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,
- NULL, NULL, NULL);
-
- if (png_ptr == NULL) {
- fclose(fp);
- return false;
- }
-
- /* Allocate/initialize the memory for image information. */
- info_ptr = png_create_info_struct(png_ptr);
- if (info_ptr == NULL) {
- fclose(fp);
- png_destroy_read_struct(&png_ptr, png_infopp_NULL,
- png_infopp_NULL);
- return false;
- }
-
- /* Set error handling if you are using the setjmp/longjmp method
- * because I left stuff as NULL in png_create_read_struct(). */
- if (setjmp(png_jmpbuf(png_ptr))) {
- /* Free all of the memory associated with the png_ptr and
- * info_ptr */
- png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL);
- fclose(fp);
- /* If we get here, we had a problem reading the file */
- return false;
- }
-
- /* Set up the input control */
- png_init_io(png_ptr, fp);
-
- /* If we have already read some of the signature */
- png_set_sig_bytes(png_ptr, sig_read);
-
- /* Read in the entire image at once */
- png_read_png(png_ptr, info_ptr, PNG_TRANSFORM_PACKING, png_voidp_NULL);
-
- width = png_get_image_width(png_ptr, info_ptr);
- height = png_get_image_height(png_ptr, info_ptr);
- bit_depth = png_get_bit_depth(png_ptr, info_ptr);
- color_type = png_get_color_type(png_ptr, info_ptr);
-
- if (color_type != PNG_COLOR_TYPE_RGB && bit_depth != 8)
- return false;
-
- if (!image_init(img, width, height, 3))
- return false;
-
- png_bytepp row_pointers = png_get_rows(png_ptr, info_ptr);
-
- row_data_width = img->width * img->channels;
- for (i = 0; i < img->height; i++) {
- memcpy(img->d[i], row_pointers[i], row_data_width);
- }
-
- /* clean up after the read, and free any memory allocated */
- png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL);
-
- /* close the file */
- fclose(fp);
-
- return true;
-}
-
-
-/**
- * Save output PNG file with alpha channel with img data
- *
- * \param file_name file to write PNG out to
- * \param img image data to generate PNG from
- * \returnreturn true on success, false on error
- */
-bool image_write_png(char *file_name, struct image *img)
-{
- FILE *fp;
- png_structp png_ptr;
- png_infop info_ptr;
- int colour_type;
-
- switch (img->channels) {
- case 1:
- colour_type = PNG_COLOR_TYPE_GRAY;
- break;
- case 3:
- colour_type = PNG_COLOR_TYPE_RGB;
- break;
- case 4:
- colour_type = PNG_COLOR_TYPE_RGB_ALPHA;
- break;
- default:
- /* Unsupported number of image channels */
- return false;
- }
-
- /* open the file */
- fp = fopen(file_name, "wb");
- if (fp == NULL)
- return false;
-
- /* Create and initialize the png_struct */
- png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,
- NULL, NULL, NULL);
-
- if (png_ptr == NULL) {
- fclose(fp);
- return false;
- }
-
- /* Allocate/initialize the image information data. */
- info_ptr = png_create_info_struct(png_ptr);
- if (info_ptr == NULL) {
- fclose(fp);
- png_destroy_write_struct(&png_ptr, png_infopp_NULL);
- return false;
- }
- /* Set error handling, needed because I gave NULLs to
- * png_create_write_struct. */
- if (setjmp(png_jmpbuf(png_ptr))) {
- /* If we get here, we had a problem reading the file */
- fclose(fp);
- png_destroy_write_struct(&png_ptr, &info_ptr);
- return false;
- }
-
- /* set up the output control */
- png_init_io(png_ptr, fp);
-
- /* Set the image information. */
- png_set_IHDR(png_ptr, info_ptr, img->width, img->height, 8,
- colour_type, PNG_INTERLACE_ADAM7,
- PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
-
- /* TODO: ??? Maybe I should set gamma stuff, but I dunno what */
- /* png_set_gAMA(png_ptr, info_ptr, gamma); */
-
- /* Write the file header information. */
- png_write_info(png_ptr, info_ptr);
-
- /* pack pixels into bytes */
- png_set_packing(png_ptr);
-
- if (img->height > PNG_UINT_32_MAX/png_sizeof(png_bytep)) {
- png_error (png_ptr, "Image is too tall to process in memory");
- return false;
- }
-
- png_write_image(png_ptr, (png_byte **)img->d);
-
- /* finish writing the rest of the file */
- png_write_end(png_ptr, info_ptr);
-
- /* clean up after the write, and free any memory allocated */
- png_destroy_write_struct(&png_ptr, &info_ptr);
-
- /* close the file */
- fclose(fp);
-
- return true;
-}
+/*
+ * Copyright 2009-2010 Michael Drake <tlsa(a)netsurf-browser.org>
+ *
+ * This file is part of AlphaGen.
+ *
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ *
+ * AlphaGen is a tool for obtaining a bitmap image with an alpha channel from
+ * software which lacks this facility itself. It recovers alpha channel
+ * information from two input images; one with a black baground and one with a
+ * white background.
+ *
+ * Inputs required:
+ * + The input image exported on a _black_ background.
+ * + The input image exported on a _white_ background.
+ * Output:
+ * + The resultant image with an alpha channel.
+ *
+ * Note that both images must be the same size.
+ */
+
+#include <stdbool.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <png.h>
+
+
+/* Bitmap image representation */
+struct image {
+ unsigned int width;
+ unsigned int height;
+ unsigned int channels;
+ uint8_t **d; /* data */
+};
+
+/* Main functionality of AlphaGen. */
+bool alphagen(char *black_name, char *white_name, char *alpha_name);
+bool alphagen_check_inputs(struct image *b, struct image *w);
+
+/* image_* functions, so the libpng stuff is kept hidden */
+bool image_init(struct image *img, int width, int height, int channels);
+void image_free(struct image *img);
+bool image_read_png(char *file_name, struct image *img);
+bool image_write_png(char *file_name, struct image *img);
+
+/**
+ * Main entry point from OS.
+ */
+int main(int argc, char** argv)
+{
+ /* Validate execution arguments. */
+ if (argc != 4) {
+ /* Too few arguments */
+ printf("Usage: %s <black> <white> <output>\n", argv[0]);
+ return EXIT_FAILURE;
+ }
+
+ /* Generate the alpha channel bitmap. */
+ if (!alphagen(argv[1], argv[2], argv[3])) {
+ return EXIT_FAILURE;
+ }
+
+ return EXIT_SUCCESS;
+}
+
+
+/**
+ * Performs alpha channel recovery on an image provided with black and white
+ * backgrounds.
+ *
+ * \param black_name filename for black background input PNG
+ * \param white_name filename for white background input PNG
+ * \param alpha_name filename for output PNG
+ * \return true on success, false on error
+ */
+bool alphagen(char *black_name, char *white_name, char *alpha_name)
+{
+ struct image b, w, a;
+ unsigned int row_data_width;
+ unsigned int x, y, z;
+ uint8_t ar, ag, ab;
+
+ /* Default background colour; 0 = black, 255 = white */
+ const uint8_t bg = 255;
+
+ /* Load input PNGs */
+ if (!image_read_png(black_name, &b)) {
+ printf("Couldn't load \"%s\" as black background input.\n",
+ black_name);
+ return false;
+ }
+ if (!image_read_png(white_name, &w)) {
+ printf("Couldn't load \"%s\" as white background input.\n",
+ white_name);
+ return false;
+ }
+
+ /* Return failure if there's a problem with the input images. */
+ if (!alphagen_check_inputs(&b, &w)) {
+ return false;
+ }
+
+ /* Prepare output image */
+ if (!image_init(&a, b.width, b.height, 4)) {
+ printf("Couldn't create output image.\n");
+ return false;
+ }
+
+ /* Recover true image colours and alpha channel for the image */
+ row_data_width = a.width * a.channels;
+ for (y = 0; y < a.height; y++) {
+ z = 0; /* x-position in input images */
+ for (x = 0; x < row_data_width; x += 4) {
+ /* Get alpha values first */
+ ar = 255 - w.d[y][z] + b.d[y][z];
+ ag = 255 - w.d[y][z+1] + b.d[y][z+1];
+ ab = 255 - w.d[y][z+2] + b.d[y][z+2];
+
+ /* Set red, green and blue colour values
+ * use preset bg colour if fully transparent */
+ a.d[y][x] = (ar == 0) ? bg : (b.d[y][z] * 255) / ar;
+ a.d[y][x+1] = (ag == 0) ? bg : (b.d[y][z+1] * 255) / ag;
+ a.d[y][x+2] = (ab == 0) ? bg : (b.d[y][z+2] * 255) / ab;
+
+ /* Set alpha value */
+ a.d[y][x+3] = (ar + ag + ab) / 3;
+
+ z += 3;
+ }
+ }
+
+ /* Save PNG with recovered colour and alpha data */
+ if (!image_write_png(alpha_name, &a)) {
+ printf("Couldn't write output file \"%s\".\n", alpha_name);
+ return false;
+ }
+
+ /* Free image memory */
+ image_free(&b);
+ image_free(&w);
+ image_free(&a);
+
+ return true;
+}
+
+
+/**
+ * Check input images for problems
+ *
+ * \param b black backgrounded input image
+ * \param w white backgrounded input image
+ * \return true on success, false on error
+ */
+bool alphagen_check_inputs(struct image *b, struct image *w)
+{
+ unsigned int data_size;
+ unsigned int i;
+ bool opaque = true;
+
+ /* Check both input images are the same size */
+ if (b->width != w->width || b->height != w->height) {
+ printf("Error: Input images have different dimensions.\n");
+ return false;
+ }
+
+ /* Check input images are both the same bit depth */
+ if (b->channels != w->channels || b->channels != 3) {
+ /* AlphaGen should load both as 24bpp, so it's not an input
+ * error, but an internal error. */
+ printf("Error: Internal error.\n");
+ return false;
+ }
+
+ /* Check that black background image is darker than white and check
+ * for opaque image (identical input images). */
+ data_size = b->height * b->width * b->channels;
+ for (i = 0; i < data_size; i++) {
+ if (b->d[0][i] > w->d[0][i]) {
+ /* Black bg image is brighter than white bg image. */
+ printf("Error: Black background input image has pixel "
+ "brighter than White background\n"
+ "input image.\n");
+ return false;
+ }
+ if (b->d[0][i] < w->d[0][i]) {
+ /* White bg image data brighter than black bg image. */
+ opaque = false;
+ }
+ }
+
+ /* If input images were identical, the image is opaque and there
+ * is no alpha channel to recover. */
+ if (opaque) {
+ printf("Error: Input images are identical. "
+ "No alpha channel to recover.\n");
+ return false;
+ }
+
+ return true;
+}
+
+
+/**
+ * Initialise an image, allocating memory for it.
+ *
+ * \param img pointer to image to initialise
+ * \param width required image width
+ * \param height required image height
+ * \param channels required number of colour channels
+ * \return true on success, false on error
+ */
+bool image_init(struct image *img, int width, int height, int channels)
+{
+ int row_data_width;
+ int i;
+
+ /* Set frame dimensions */
+ img->width = width;
+ img->height = height;
+ img->channels = channels;
+
+ /* Allocate memory for row pointers */
+ img->d = malloc(height * sizeof(uint8_t*));
+ if (img->d == NULL)
+ return false;
+
+ /* Allocate memory for image data */
+ row_data_width = width * channels;
+ img->d[0] = malloc(height * row_data_width * sizeof(uint8_t));
+ if (img->d[0] == NULL)
+ return false;
+
+ for (i = 1; i < height; i++) {
+ /* Set pointers to each row */
+ img->d[i] = img->d[i - 1] + row_data_width;
+ }
+ return true;
+}
+
+
+/**
+ * Free an image.
+ *
+ * \param img pointer to image to free
+ */
+void image_free(struct image *img)
+{
+ free(img->d[0]);
+ free(img->d);
+}
+
+
+/**
+ * Read RGB PNG with no alpha channel into img.
+ *
+ * \param file_name file to load
+ * \param img pointer to image to put data in
+ * \return true on success, false on error
+ */
+bool image_read_png(char *file_name, struct image *img)
+{
+ png_structp png_ptr;
+ png_infop info_ptr;
+ unsigned int sig_read = 0;
+ unsigned int row_data_width;
+ png_uint_32 width, height;
+ int bit_depth, color_type;
+ int i;
+ FILE *fp;
+
+ if ((fp = fopen(file_name, "rb")) == NULL)
+ return false;
+
+ /* Create and initialize the png_struct. */
+ png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,
+ NULL, NULL, NULL);
+
+ if (png_ptr == NULL) {
+ fclose(fp);
+ return false;
+ }
+
+ /* Allocate/initialize the memory for image information. */
+ info_ptr = png_create_info_struct(png_ptr);
+ if (info_ptr == NULL) {
+ fclose(fp);
+ png_destroy_read_struct(&png_ptr, png_infopp_NULL,
+ png_infopp_NULL);
+ return false;
+ }
+
+ /* Set error handling if you are using the setjmp/longjmp method
+ * because I left stuff as NULL in png_create_read_struct(). */
+ if (setjmp(png_jmpbuf(png_ptr))) {
+ /* Free all of the memory associated with the png_ptr and
+ * info_ptr */
+ png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL);
+ fclose(fp);
+ /* If we get here, we had a problem reading the file */
+ return false;
+ }
+
+ /* Set up the input control */
+ png_init_io(png_ptr, fp);
+
+ /* If we have already read some of the signature */
+ png_set_sig_bytes(png_ptr, sig_read);
+
+ /* Read in the entire image at once */
+ png_read_png(png_ptr, info_ptr, PNG_TRANSFORM_PACKING, png_voidp_NULL);
+
+ width = png_get_image_width(png_ptr, info_ptr);
+ height = png_get_image_height(png_ptr, info_ptr);
+ bit_depth = png_get_bit_depth(png_ptr, info_ptr);
+ color_type = png_get_color_type(png_ptr, info_ptr);
+
+ if (color_type != PNG_COLOR_TYPE_RGB && bit_depth != 8)
+ return false;
+
+ if (!image_init(img, width, height, 3))
+ return false;
+
+ png_bytepp row_pointers = png_get_rows(png_ptr, info_ptr);
+
+ row_data_width = img->width * img->channels;
+ for (i = 0; i < img->height; i++) {
+ memcpy(img->d[i], row_pointers[i], row_data_width);
+ }
+
+ /* clean up after the read, and free any memory allocated */
+ png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL);
+
+ /* close the file */
+ fclose(fp);
+
+ return true;
+}
+
+
+/**
+ * Save output PNG file with alpha channel with img data
+ *
+ * \param file_name file to write PNG out to
+ * \param img image data to generate PNG from
+ * \returnreturn true on success, false on error
+ */
+bool image_write_png(char *file_name, struct image *img)
+{
+ FILE *fp;
+ png_structp png_ptr;
+ png_infop info_ptr;
+ int colour_type;
+
+ switch (img->channels) {
+ case 1:
+ colour_type = PNG_COLOR_TYPE_GRAY;
+ break;
+ case 3:
+ colour_type = PNG_COLOR_TYPE_RGB;
+ break;
+ case 4:
+ colour_type = PNG_COLOR_TYPE_RGB_ALPHA;
+ break;
+ default:
+ /* Unsupported number of image channels */
+ return false;
+ }
+
+ /* open the file */
+ fp = fopen(file_name, "wb");
+ if (fp == NULL)
+ return false;
+
+ /* Create and initialize the png_struct */
+ png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,
+ NULL, NULL, NULL);
+
+ if (png_ptr == NULL) {
+ fclose(fp);
+ return false;
+ }
+
+ /* Allocate/initialize the image information data. */
+ info_ptr = png_create_info_struct(png_ptr);
+ if (info_ptr == NULL) {
+ fclose(fp);
+ png_destroy_write_struct(&png_ptr, png_infopp_NULL);
+ return false;
+ }
+ /* Set error handling, needed because I gave NULLs to
+ * png_create_write_struct. */
+ if (setjmp(png_jmpbuf(png_ptr))) {
+ /* If we get here, we had a problem reading the file */
+ fclose(fp);
+ png_destroy_write_struct(&png_ptr, &info_ptr);
+ return false;
+ }
+
+ /* set up the output control */
+ png_init_io(png_ptr, fp);
+
+ /* Set the image information. */
+ png_set_IHDR(png_ptr, info_ptr, img->width, img->height, 8,
+ colour_type, PNG_INTERLACE_ADAM7,
+ PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
+
+ /* TODO: ??? Maybe I should set gamma stuff, but I dunno what */
+ /* png_set_gAMA(png_ptr, info_ptr, gamma); */
+
+ /* Write the file header information. */
+ png_write_info(png_ptr, info_ptr);
+
+ /* pack pixels into bytes */
+ png_set_packing(png_ptr);
+
+ if (img->height > PNG_UINT_32_MAX/png_sizeof(png_bytep)) {
+ png_error (png_ptr, "Image is too tall to process in memory");
+ return false;
+ }
+
+ png_write_image(png_ptr, (png_byte **)img->d);
+
+ /* finish writing the rest of the file */
+ png_write_end(png_ptr, info_ptr);
+
+ /* clean up after the write, and free any memory allocated */
+ png_destroy_write_struct(&png_ptr, &info_ptr);
+
+ /* close the file */
+ fclose(fp);
+
+ return true;
+}
-----------------------------------------------------------------------
Summary of changes:
Makefile | 6 +-
src/alphagen.c | 872 ++++++++++++++++++++++++++++----------------------------
2 files changed, 441 insertions(+), 437 deletions(-)
diff --git a/Makefile b/Makefile
index d0ea5d5..eb4df92 100644
--- a/Makefile
+++ b/Makefile
@@ -16,7 +16,11 @@ include $(NSSHARED)/makefiles/Makefile.tools
# Toolchain flags
WARNFLAGS := -Wall -W -Wundef -Wpointer-arith -Wcast-align \
-Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes \
- -Wmissing-declarations -Wnested-externs -pedantic
+ -Wmissing-declarations -Wnested-externs -Wredundant-decls \
+ -Wuninitialized -pedantic
+
+# Optimisation flags
+CFLAGS += -O2
# libpng and libz
ifneq ($(findstring clean,$(MAKECMDGOALS)),clean)
diff --git a/src/alphagen.c b/src/alphagen.c
index 1ef3bc3..384e70b 100644
--- a/src/alphagen.c
+++ b/src/alphagen.c
@@ -1,436 +1,436 @@
-/*
- * Copyright 2009-2010 Michael Drake <tlsa(a)netsurf-browser.org>
- *
- * This file is part of AlphaGen.
- *
- * Licensed under the MIT License,
- * http://www.opensource.org/licenses/mit-license.php
- *
- * AlphaGen is a tool for obtaining a bitmap image with an alpha channel from
- * software which lacks this facility itself. It recovers alpha channel
- * information from two input images; one with a black baground and one with a
- * white background.
- *
- * Inputs required:
- * + The input image exported on a _black_ background.
- * + The input image exported on a _white_ background.
- * Output:
- * + The resultant image with an alpha channel.
- *
- * Note that both images must be the same size.
- */
-
-#include <stdbool.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include <png.h>
-
-
-/* Bitmap image representation */
-struct image {
- unsigned int width;
- unsigned int height;
- unsigned int channels;
- uint8_t **d; /* data */
-};
-
-/* Main functionality of AlphaGen. */
-bool alphagen(char *black_name, char *white_name, char *alpha_name);
-bool alphagen_check_inputs(struct image *b, struct image *w);
-
-/* image_* functions, so the libpng stuff is kept hidden */
-bool image_init(struct image *img, int width, int height, int channels);
-void image_free(struct image *img);
-bool image_read_png(char *file_name, struct image *img);
-bool image_write_png(char *file_name, struct image *img);
-
-/**
- * Main entry point from OS.
- */
-int main(int argc, char** argv)
-{
- /* Validate execution arguments. */
- if (argc != 4) {
- /* Too few arguments */
- printf("Usage: %s <black> <white> <output>\n", argv[0]);
- return EXIT_FAILURE;
- }
-
- /* Generate the alpha channel bitmap. */
- if (!alphagen(argv[1], argv[2], argv[3])) {
- return EXIT_FAILURE;
- }
-
- return EXIT_SUCCESS;
-}
-
-
-/**
- * Performs alpha channel recovery on an image provided with black and white
- * backgrounds.
- *
- * \param black_name filename for black background input PNG
- * \param white_name filename for white background input PNG
- * \param alpha_name filename for output PNG
- * \return true on success, false on error
- */
-bool alphagen(char *black_name, char *white_name, char *alpha_name)
-{
- struct image b, w, a;
- unsigned int row_data_width;
- unsigned int x, y, z;
- uint8_t ar, ag, ab;
-
- /* Default background colour; 0 = black, 255 = white */
- const uint8_t bg = 255;
-
- /* Load input PNGs */
- if (!image_read_png(black_name, &b)) {
- printf("Couldn't load \"%s\" as black background input.\n",
- black_name);
- return false;
- }
- if (!image_read_png(white_name, &w)) {
- printf("Couldn't load \"%s\" as white background input.\n",
- white_name);
- return false;
- }
-
- /* Return failure if there's a problem with the input images. */
- if (!alphagen_check_inputs(&b, &w)) {
- return false;
- }
-
- /* Prepare output image */
- if (!image_init(&a, b.width, b.height, 4)) {
- printf("Couldn't create output image.\n");
- return false;
- }
-
- /* Recover true image colours and alpha channel for the image */
- row_data_width = a.width * a.channels;
- for (y = 0; y < a.height; y++) {
- z = 0; /* x-position in input images */
- for (x = 0; x < row_data_width; x += 4) {
- /* Get alpha values first */
- ar = 255 - w.d[y][z] + b.d[y][z];
- ag = 255 - w.d[y][z+1] + b.d[y][z+1];
- ab = 255 - w.d[y][z+2] + b.d[y][z+2];
-
- /* Set red, green and blue colour values
- * use preset bg colour if fully transparent */
- a.d[y][x] = (ar == 0) ? bg : (b.d[y][z] * 255) / ar;
- a.d[y][x+1] = (ag == 0) ? bg : (b.d[y][z+1] * 255) / ag;
- a.d[y][x+2] = (ab == 0) ? bg : (b.d[y][z+2] * 255) / ab;
-
- /* Set alpha value */
- a.d[y][x+3] = (ar + ag + ab) / 3;
-
- z += 3;
- }
- }
-
- /* Save PNG with recovered colour and alpha data */
- if (!image_write_png(alpha_name, &a)) {
- printf("Couldn't write output file \"%s\".\n", alpha_name);
- return false;
- }
-
- /* Free image memory */
- image_free(&b);
- image_free(&w);
- image_free(&a);
-
- return true;
-}
-
-
-/**
- * Check input images for problems
- *
- * \param b black backgrounded input image
- * \param w white backgrounded input image
- * \return true on success, false on error
- */
-bool alphagen_check_inputs(struct image *b, struct image *w)
-{
- unsigned int data_size;
- unsigned int i;
- bool opaque = true;
-
- /* Check both input images are the same size */
- if (b->width != w->width || b->height != w->height) {
- printf("Error: Input images have different dimensions.\n");
- return false;
- }
-
- /* Check input images are both the same bit depth */
- if (b->channels != w->channels || b->channels != 3) {
- /* AlphaGen should load both as 24bpp, so it's not an input
- * error, but an internal error. */
- printf("Error: Internal error.\n");
- return false;
- }
-
- /* Check that black background image is darker than white and check
- * for opaque image (identical input images). */
- data_size = b->height * b->width * b->channels;
- for (i = 0; i < data_size; i++) {
- if (b->d[0][i] > w->d[0][i]) {
- /* Black bg image is brighter than white bg image. */
- printf("Error: Black background input image has pixel "
- "brighter than White background\n"
- "input image.\n");
- return false;
- }
- if (b->d[0][i] < w->d[0][i]) {
- /* White bg image data brighter than black bg image. */
- opaque = false;
- }
- }
-
- /* If input images were identical, the image is opaque and there
- * is no alpha channel to recover. */
- if (opaque) {
- printf("Error: Input images are identical. "
- "No alpha channel to recover.\n");
- return false;
- }
-
- return true;
-}
-
-
-/**
- * Initialise an image, allocating memory for it.
- *
- * \param img pointer to image to initialise
- * \param width required image width
- * \param height required image height
- * \param channels required number of colour channels
- * \return true on success, false on error
- */
-bool image_init(struct image *img, int width, int height, int channels)
-{
- int row_data_width;
- int i;
-
- /* Set frame dimensions */
- img->width = width;
- img->height = height;
- img->channels = channels;
-
- /* Allocate memory for row pointers */
- img->d = malloc(height * sizeof(uint8_t*));
- if (img->d == NULL)
- return false;
-
- /* Allocate memory for image data */
- row_data_width = width * channels;
- img->d[0] = malloc(height * row_data_width * sizeof(uint8_t));
- if (img->d[0] == NULL)
- return false;
-
- for (i = 1; i < height; i++) {
- /* Set pointers to each row */
- img->d[i] = img->d[i - 1] + row_data_width;
- }
- return true;
-}
-
-
-/**
- * Free an image.
- *
- * \param img pointer to image to free
- */
-void image_free(struct image *img)
-{
- free(img->d[0]);
- free(img->d);
-}
-
-
-/**
- * Read RGB PNG with no alpha channel into img.
- *
- * \param file_name file to load
- * \param img pointer to image to put data in
- * \return true on success, false on error
- */
-bool image_read_png(char *file_name, struct image *img)
-{
- png_structp png_ptr;
- png_infop info_ptr;
- unsigned int sig_read = 0;
- unsigned int row_data_width;
- png_uint_32 width, height;
- int bit_depth, color_type;
- int i;
- FILE *fp;
-
- if ((fp = fopen(file_name, "rb")) == NULL)
- return false;
-
- /* Create and initialize the png_struct. */
- png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,
- NULL, NULL, NULL);
-
- if (png_ptr == NULL) {
- fclose(fp);
- return false;
- }
-
- /* Allocate/initialize the memory for image information. */
- info_ptr = png_create_info_struct(png_ptr);
- if (info_ptr == NULL) {
- fclose(fp);
- png_destroy_read_struct(&png_ptr, png_infopp_NULL,
- png_infopp_NULL);
- return false;
- }
-
- /* Set error handling if you are using the setjmp/longjmp method
- * because I left stuff as NULL in png_create_read_struct(). */
- if (setjmp(png_jmpbuf(png_ptr))) {
- /* Free all of the memory associated with the png_ptr and
- * info_ptr */
- png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL);
- fclose(fp);
- /* If we get here, we had a problem reading the file */
- return false;
- }
-
- /* Set up the input control */
- png_init_io(png_ptr, fp);
-
- /* If we have already read some of the signature */
- png_set_sig_bytes(png_ptr, sig_read);
-
- /* Read in the entire image at once */
- png_read_png(png_ptr, info_ptr, PNG_TRANSFORM_PACKING, png_voidp_NULL);
-
- width = png_get_image_width(png_ptr, info_ptr);
- height = png_get_image_height(png_ptr, info_ptr);
- bit_depth = png_get_bit_depth(png_ptr, info_ptr);
- color_type = png_get_color_type(png_ptr, info_ptr);
-
- if (color_type != PNG_COLOR_TYPE_RGB && bit_depth != 8)
- return false;
-
- if (!image_init(img, width, height, 3))
- return false;
-
- png_bytepp row_pointers = png_get_rows(png_ptr, info_ptr);
-
- row_data_width = img->width * img->channels;
- for (i = 0; i < img->height; i++) {
- memcpy(img->d[i], row_pointers[i], row_data_width);
- }
-
- /* clean up after the read, and free any memory allocated */
- png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL);
-
- /* close the file */
- fclose(fp);
-
- return true;
-}
-
-
-/**
- * Save output PNG file with alpha channel with img data
- *
- * \param file_name file to write PNG out to
- * \param img image data to generate PNG from
- * \returnreturn true on success, false on error
- */
-bool image_write_png(char *file_name, struct image *img)
-{
- FILE *fp;
- png_structp png_ptr;
- png_infop info_ptr;
- int colour_type;
-
- switch (img->channels) {
- case 1:
- colour_type = PNG_COLOR_TYPE_GRAY;
- break;
- case 3:
- colour_type = PNG_COLOR_TYPE_RGB;
- break;
- case 4:
- colour_type = PNG_COLOR_TYPE_RGB_ALPHA;
- break;
- default:
- /* Unsupported number of image channels */
- return false;
- }
-
- /* open the file */
- fp = fopen(file_name, "wb");
- if (fp == NULL)
- return false;
-
- /* Create and initialize the png_struct */
- png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,
- NULL, NULL, NULL);
-
- if (png_ptr == NULL) {
- fclose(fp);
- return false;
- }
-
- /* Allocate/initialize the image information data. */
- info_ptr = png_create_info_struct(png_ptr);
- if (info_ptr == NULL) {
- fclose(fp);
- png_destroy_write_struct(&png_ptr, png_infopp_NULL);
- return false;
- }
- /* Set error handling, needed because I gave NULLs to
- * png_create_write_struct. */
- if (setjmp(png_jmpbuf(png_ptr))) {
- /* If we get here, we had a problem reading the file */
- fclose(fp);
- png_destroy_write_struct(&png_ptr, &info_ptr);
- return false;
- }
-
- /* set up the output control */
- png_init_io(png_ptr, fp);
-
- /* Set the image information. */
- png_set_IHDR(png_ptr, info_ptr, img->width, img->height, 8,
- colour_type, PNG_INTERLACE_ADAM7,
- PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
-
- /* TODO: ??? Maybe I should set gamma stuff, but I dunno what */
- /* png_set_gAMA(png_ptr, info_ptr, gamma); */
-
- /* Write the file header information. */
- png_write_info(png_ptr, info_ptr);
-
- /* pack pixels into bytes */
- png_set_packing(png_ptr);
-
- if (img->height > PNG_UINT_32_MAX/png_sizeof(png_bytep)) {
- png_error (png_ptr, "Image is too tall to process in memory");
- return false;
- }
-
- png_write_image(png_ptr, (png_byte **)img->d);
-
- /* finish writing the rest of the file */
- png_write_end(png_ptr, info_ptr);
-
- /* clean up after the write, and free any memory allocated */
- png_destroy_write_struct(&png_ptr, &info_ptr);
-
- /* close the file */
- fclose(fp);
-
- return true;
-}
+/*
+ * Copyright 2009-2010 Michael Drake <tlsa(a)netsurf-browser.org>
+ *
+ * This file is part of AlphaGen.
+ *
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ *
+ * AlphaGen is a tool for obtaining a bitmap image with an alpha channel from
+ * software which lacks this facility itself. It recovers alpha channel
+ * information from two input images; one with a black baground and one with a
+ * white background.
+ *
+ * Inputs required:
+ * + The input image exported on a _black_ background.
+ * + The input image exported on a _white_ background.
+ * Output:
+ * + The resultant image with an alpha channel.
+ *
+ * Note that both images must be the same size.
+ */
+
+#include <stdbool.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <png.h>
+
+
+/* Bitmap image representation */
+struct image {
+ unsigned int width;
+ unsigned int height;
+ unsigned int channels;
+ uint8_t **d; /* data */
+};
+
+/* Main functionality of AlphaGen. */
+bool alphagen(char *black_name, char *white_name, char *alpha_name);
+bool alphagen_check_inputs(struct image *b, struct image *w);
+
+/* image_* functions, so the libpng stuff is kept hidden */
+bool image_init(struct image *img, int width, int height, int channels);
+void image_free(struct image *img);
+bool image_read_png(char *file_name, struct image *img);
+bool image_write_png(char *file_name, struct image *img);
+
+/**
+ * Main entry point from OS.
+ */
+int main(int argc, char** argv)
+{
+ /* Validate execution arguments. */
+ if (argc != 4) {
+ /* Too few arguments */
+ printf("Usage: %s <black> <white> <output>\n", argv[0]);
+ return EXIT_FAILURE;
+ }
+
+ /* Generate the alpha channel bitmap. */
+ if (!alphagen(argv[1], argv[2], argv[3])) {
+ return EXIT_FAILURE;
+ }
+
+ return EXIT_SUCCESS;
+}
+
+
+/**
+ * Performs alpha channel recovery on an image provided with black and white
+ * backgrounds.
+ *
+ * \param black_name filename for black background input PNG
+ * \param white_name filename for white background input PNG
+ * \param alpha_name filename for output PNG
+ * \return true on success, false on error
+ */
+bool alphagen(char *black_name, char *white_name, char *alpha_name)
+{
+ struct image b, w, a;
+ unsigned int row_data_width;
+ unsigned int x, y, z;
+ uint8_t ar, ag, ab;
+
+ /* Default background colour; 0 = black, 255 = white */
+ const uint8_t bg = 255;
+
+ /* Load input PNGs */
+ if (!image_read_png(black_name, &b)) {
+ printf("Couldn't load \"%s\" as black background input.\n",
+ black_name);
+ return false;
+ }
+ if (!image_read_png(white_name, &w)) {
+ printf("Couldn't load \"%s\" as white background input.\n",
+ white_name);
+ return false;
+ }
+
+ /* Return failure if there's a problem with the input images. */
+ if (!alphagen_check_inputs(&b, &w)) {
+ return false;
+ }
+
+ /* Prepare output image */
+ if (!image_init(&a, b.width, b.height, 4)) {
+ printf("Couldn't create output image.\n");
+ return false;
+ }
+
+ /* Recover true image colours and alpha channel for the image */
+ row_data_width = a.width * a.channels;
+ for (y = 0; y < a.height; y++) {
+ z = 0; /* x-position in input images */
+ for (x = 0; x < row_data_width; x += 4) {
+ /* Get alpha values first */
+ ar = 255 - w.d[y][z] + b.d[y][z];
+ ag = 255 - w.d[y][z+1] + b.d[y][z+1];
+ ab = 255 - w.d[y][z+2] + b.d[y][z+2];
+
+ /* Set red, green and blue colour values
+ * use preset bg colour if fully transparent */
+ a.d[y][x] = (ar == 0) ? bg : (b.d[y][z] * 255) / ar;
+ a.d[y][x+1] = (ag == 0) ? bg : (b.d[y][z+1] * 255) / ag;
+ a.d[y][x+2] = (ab == 0) ? bg : (b.d[y][z+2] * 255) / ab;
+
+ /* Set alpha value */
+ a.d[y][x+3] = (ar + ag + ab) / 3;
+
+ z += 3;
+ }
+ }
+
+ /* Save PNG with recovered colour and alpha data */
+ if (!image_write_png(alpha_name, &a)) {
+ printf("Couldn't write output file \"%s\".\n", alpha_name);
+ return false;
+ }
+
+ /* Free image memory */
+ image_free(&b);
+ image_free(&w);
+ image_free(&a);
+
+ return true;
+}
+
+
+/**
+ * Check input images for problems
+ *
+ * \param b black backgrounded input image
+ * \param w white backgrounded input image
+ * \return true on success, false on error
+ */
+bool alphagen_check_inputs(struct image *b, struct image *w)
+{
+ unsigned int data_size;
+ unsigned int i;
+ bool opaque = true;
+
+ /* Check both input images are the same size */
+ if (b->width != w->width || b->height != w->height) {
+ printf("Error: Input images have different dimensions.\n");
+ return false;
+ }
+
+ /* Check input images are both the same bit depth */
+ if (b->channels != w->channels || b->channels != 3) {
+ /* AlphaGen should load both as 24bpp, so it's not an input
+ * error, but an internal error. */
+ printf("Error: Internal error.\n");
+ return false;
+ }
+
+ /* Check that black background image is darker than white and check
+ * for opaque image (identical input images). */
+ data_size = b->height * b->width * b->channels;
+ for (i = 0; i < data_size; i++) {
+ if (b->d[0][i] > w->d[0][i]) {
+ /* Black bg image is brighter than white bg image. */
+ printf("Error: Black background input image has pixel "
+ "brighter than White background\n"
+ "input image.\n");
+ return false;
+ }
+ if (b->d[0][i] < w->d[0][i]) {
+ /* White bg image data brighter than black bg image. */
+ opaque = false;
+ }
+ }
+
+ /* If input images were identical, the image is opaque and there
+ * is no alpha channel to recover. */
+ if (opaque) {
+ printf("Error: Input images are identical. "
+ "No alpha channel to recover.\n");
+ return false;
+ }
+
+ return true;
+}
+
+
+/**
+ * Initialise an image, allocating memory for it.
+ *
+ * \param img pointer to image to initialise
+ * \param width required image width
+ * \param height required image height
+ * \param channels required number of colour channels
+ * \return true on success, false on error
+ */
+bool image_init(struct image *img, int width, int height, int channels)
+{
+ int row_data_width;
+ int i;
+
+ /* Set frame dimensions */
+ img->width = width;
+ img->height = height;
+ img->channels = channels;
+
+ /* Allocate memory for row pointers */
+ img->d = malloc(height * sizeof(uint8_t*));
+ if (img->d == NULL)
+ return false;
+
+ /* Allocate memory for image data */
+ row_data_width = width * channels;
+ img->d[0] = malloc(height * row_data_width * sizeof(uint8_t));
+ if (img->d[0] == NULL)
+ return false;
+
+ for (i = 1; i < height; i++) {
+ /* Set pointers to each row */
+ img->d[i] = img->d[i - 1] + row_data_width;
+ }
+ return true;
+}
+
+
+/**
+ * Free an image.
+ *
+ * \param img pointer to image to free
+ */
+void image_free(struct image *img)
+{
+ free(img->d[0]);
+ free(img->d);
+}
+
+
+/**
+ * Read RGB PNG with no alpha channel into img.
+ *
+ * \param file_name file to load
+ * \param img pointer to image to put data in
+ * \return true on success, false on error
+ */
+bool image_read_png(char *file_name, struct image *img)
+{
+ png_structp png_ptr;
+ png_infop info_ptr;
+ unsigned int sig_read = 0;
+ unsigned int row_data_width;
+ png_uint_32 width, height;
+ int bit_depth, color_type;
+ int i;
+ FILE *fp;
+
+ if ((fp = fopen(file_name, "rb")) == NULL)
+ return false;
+
+ /* Create and initialize the png_struct. */
+ png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,
+ NULL, NULL, NULL);
+
+ if (png_ptr == NULL) {
+ fclose(fp);
+ return false;
+ }
+
+ /* Allocate/initialize the memory for image information. */
+ info_ptr = png_create_info_struct(png_ptr);
+ if (info_ptr == NULL) {
+ fclose(fp);
+ png_destroy_read_struct(&png_ptr, NULL, NULL);
+ return false;
+ }
+
+ /* Set error handling if you are using the setjmp/longjmp method
+ * because I left stuff as NULL in png_create_read_struct(). */
+ if (setjmp(png_jmpbuf(png_ptr))) {
+ /* Free all of the memory associated with the png_ptr and
+ * info_ptr */
+ png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
+ fclose(fp);
+ /* If we get here, we had a problem reading the file */
+ return false;
+ }
+
+ /* Set up the input control */
+ png_init_io(png_ptr, fp);
+
+ /* If we have already read some of the signature */
+ png_set_sig_bytes(png_ptr, sig_read);
+
+ /* Read in the entire image at once */
+ png_read_png(png_ptr, info_ptr, PNG_TRANSFORM_PACKING, NULL);
+
+ width = png_get_image_width(png_ptr, info_ptr);
+ height = png_get_image_height(png_ptr, info_ptr);
+ bit_depth = png_get_bit_depth(png_ptr, info_ptr);
+ color_type = png_get_color_type(png_ptr, info_ptr);
+
+ if (color_type != PNG_COLOR_TYPE_RGB && bit_depth != 8)
+ return false;
+
+ if (!image_init(img, width, height, 3))
+ return false;
+
+ png_bytepp row_pointers = png_get_rows(png_ptr, info_ptr);
+
+ row_data_width = img->width * img->channels;
+ for (i = 0; i < img->height; i++) {
+ memcpy(img->d[i], row_pointers[i], row_data_width);
+ }
+
+ /* clean up after the read, and free any memory allocated */
+ png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
+
+ /* close the file */
+ fclose(fp);
+
+ return true;
+}
+
+
+/**
+ * Save output PNG file with alpha channel with img data
+ *
+ * \param file_name file to write PNG out to
+ * \param img image data to generate PNG from
+ * \returnreturn true on success, false on error
+ */
+bool image_write_png(char *file_name, struct image *img)
+{
+ FILE *fp;
+ png_structp png_ptr;
+ png_infop info_ptr;
+ int colour_type;
+
+ switch (img->channels) {
+ case 1:
+ colour_type = PNG_COLOR_TYPE_GRAY;
+ break;
+ case 3:
+ colour_type = PNG_COLOR_TYPE_RGB;
+ break;
+ case 4:
+ colour_type = PNG_COLOR_TYPE_RGB_ALPHA;
+ break;
+ default:
+ /* Unsupported number of image channels */
+ return false;
+ }
+
+ /* open the file */
+ fp = fopen(file_name, "wb");
+ if (fp == NULL)
+ return false;
+
+ /* Create and initialize the png_struct */
+ png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,
+ NULL, NULL, NULL);
+
+ if (png_ptr == NULL) {
+ fclose(fp);
+ return false;
+ }
+
+ /* Allocate/initialize the image information data. */
+ info_ptr = png_create_info_struct(png_ptr);
+ if (info_ptr == NULL) {
+ fclose(fp);
+ png_destroy_write_struct(&png_ptr, NULL);
+ return false;
+ }
+ /* Set error handling, needed because I gave NULLs to
+ * png_create_write_struct. */
+ if (setjmp(png_jmpbuf(png_ptr))) {
+ /* If we get here, we had a problem reading the file */
+ fclose(fp);
+ png_destroy_write_struct(&png_ptr, &info_ptr);
+ return false;
+ }
+
+ /* set up the output control */
+ png_init_io(png_ptr, fp);
+
+ /* Set the image information. */
+ png_set_IHDR(png_ptr, info_ptr, img->width, img->height, 8,
+ colour_type, PNG_INTERLACE_ADAM7,
+ PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
+
+ /* TODO: ??? Maybe I should set gamma stuff, but I dunno what */
+ /* png_set_gAMA(png_ptr, info_ptr, gamma); */
+
+ /* Write the file header information. */
+ png_write_info(png_ptr, info_ptr);
+
+ /* pack pixels into bytes */
+ png_set_packing(png_ptr);
+
+ if (img->height > PNG_UINT_32_MAX / sizeof(png_bytep)) {
+ png_error (png_ptr, "Image is too tall to process in memory");
+ return false;
+ }
+
+ png_write_image(png_ptr, (png_byte **)img->d);
+
+ /* finish writing the rest of the file */
+ png_write_end(png_ptr, info_ptr);
+
+ /* clean up after the write, and free any memory allocated */
+ png_destroy_write_struct(&png_ptr, &info_ptr);
+
+ /* close the file */
+ fclose(fp);
+
+ return true;
+}
--
Bitmap alpha-channel generator
9 years, 5 months
libdom: branch rupindersingh/libdom updated. release/0.1.0-47-gd1ca3ce
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/libdom.git/shortlog/d1ca3ce434f91036c56cb4...
...commit http://git.netsurf-browser.org/libdom.git/commit/d1ca3ce434f91036c56cb4d4...
...tree http://git.netsurf-browser.org/libdom.git/tree/d1ca3ce434f91036c56cb4d4e7...
The branch, rupindersingh/libdom has been updated
via d1ca3ce434f91036c56cb4d4e7a2875e8d6ecd7b (commit)
from 2c08402e7bfaf19cbeab15ee09090337b0b33a82 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/libdom.git/commit/?id=d1ca3ce434f91036c56c...
commit d1ca3ce434f91036c56cb4d4e7a2875e8d6ecd7b
Author: Rupinder Singh Khokhar <rsk1coder99(a)gmail.com>
Commit: Rupinder Singh Khokhar <rsk1coder99(a)gmail.com>
HTMLCollection
diff --git a/src/html/html_collection.c b/src/html/html_collection.c
index 2b4d8aa..43a26c5 100644
--- a/src/html/html_collection.c
+++ b/src/html/html_collection.c
@@ -11,6 +11,7 @@
#include <libwapcaplet/libwapcaplet.h>
#include "html/html_collection.h"
+#include "html/html_document.h"
#include "core/node.h"
#include "core/element.h"
@@ -182,7 +183,7 @@ dom_exception dom_html_collection_item(dom_html_collection *col,
/* No children and siblings */
struct dom_node_internal *parent = n->parent;
- while (parent != col->root &&
+ while (n != col->root &&
n == parent->last_child) {
n = parent;
parent = parent->parent;
@@ -212,8 +213,8 @@ dom_exception dom_html_collection_named_item(dom_html_collection *col,
dom_string *name, struct dom_node **node)
{
struct dom_node_internal *n = col->root;
+ dom_html_document *doc = (dom_html_document *)dom_node_get_owner(n);
dom_exception err;
-
while (n != NULL) {
if (n->type == DOM_ELEMENT_NODE &&
col->ic(n, col->ctx) == true) {
@@ -235,6 +236,22 @@ dom_exception dom_html_collection_named_item(dom_html_collection *col,
if (id != NULL)
dom_string_unref(id);
+
+ /* Check for Name attr if id not matched/found */
+ dom_string *id_name = NULL;
+ err = _dom_element_get_attribute((dom_element *)n,
+ doc->memoised[hds_name], &id_name);
+ if(err != DOM_NO_ERR) {
+ return err;
+ }
+ if (id_name != NULL && dom_string_isequal(name, id_name)) {
+ *node = (struct dom_node *) n;
+ dom_node_ref(n);
+ dom_string_unref(id_name);
+
+ return DOM_NO_ERR;
+ }
+
}
/* Depth first iterating */
@@ -246,13 +263,13 @@ dom_exception dom_html_collection_named_item(dom_html_collection *col,
/* No children and siblings */
struct dom_node_internal *parent = n->parent;
- while (parent != col->root &&
+ while (n != col->root &&
n == parent->last_child) {
n = parent;
parent = parent->parent;
}
- if (parent == col->root)
+ if (n == col->root)
n = NULL;
else
n = n->next;
diff --git a/src/html/html_document.c b/src/html/html_document.c
index ee16ac4..0eca66d 100644
--- a/src/html/html_document.c
+++ b/src/html/html_document.c
@@ -907,6 +907,7 @@ dom_exception _dom_html_document_set_cookie(dom_html_document *doc,
{
UNUSED(doc);
UNUSED(cookie);
+
/*todo implement this after updating client interface */
return DOM_NOT_SUPPORTED_ERR;
}
diff --git a/test/testcases/tests/level1/html/HTMLCollection04.xml b/test/testcases/tests/level1/html/HTMLCollection04.xml
new file mode 100644
index 0000000..5d78405
--- /dev/null
+++ b/test/testcases/tests/level1/html/HTMLCollection04.xml
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?xml-stylesheet href="test-to-html.xml" 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="HTMLCollection04">
+<metadata>
+<title>HTMLCollection04</title>
+<creator>NIST</creator>
+<description>
+ HTMLCollections are live, they are automatically updated when the
+ underlying document is changed.
+
+ Create a HTMLCollection object by invoking the rows attribute of the
+ first TABLE element and examine its length, then add a new row and
+ re-examine the length.
+</description>
+<contributor>Rick Rivello</contributor>
+<date qualifier="created">2002-05-01</date>
+<subject resource="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-4005..."/>
+</metadata>
+<var name="nodeList" type="NodeList"/>
+<var name="testNode" type="Node"/>
+<var name="rowLength1" type="int"/>
+<var name="rowLength2" type="int"/>
+<var name="rowsnodeList" type="HTMLCollection"/>
+<var name="newRow" type="HTMLElement"/>
+<var name="vrowindex" type="int" />
+<var name="doc" type="Document"/>
+<var name="result" type="List"/>
+<var name="expectedResult" type="List">
+<member>4</member>
+<member>5</member>
+</var>
+<load var="doc" href="collection" willBeModified="true"/>
+<getElementsByTagName interface="Document" obj="doc" var="nodeList" tagname='"table"'/>
+<assertSize collection="nodeList" size="1" id="Asize"/>
+<item interface="NodeList" obj="nodeList" var="testNode" index="0"/>
+<rows interface="HTMLTableElement" obj="testNode" var="rowsnodeList"/>
+<length interface="HTMLCollection" obj="rowsnodeList" var="rowLength1"/>
+<append collection="result" item="rowLength1"/>
+<insertRow interface="HTMLTableElement" obj="testNode" var="newRow" index="4"/>
+<length interface="HTMLCollection" obj="rowsnodeList" var="rowLength2"/>
+<append collection="result" item="rowLength2"/>
+<assertEquals actual="result" expected="expectedResult" id="rowIndexLink" ignoreCase="false"/>
+</test>
diff --git a/test/testcases/tests/level1/html/HTMLCollection04.xml.kfail b/test/testcases/tests/level1/html/HTMLCollection04.xml.kfail
deleted file mode 100644
index 5d78405..0000000
--- a/test/testcases/tests/level1/html/HTMLCollection04.xml.kfail
+++ /dev/null
@@ -1,59 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?xml-stylesheet href="test-to-html.xml" 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="HTMLCollection04">
-<metadata>
-<title>HTMLCollection04</title>
-<creator>NIST</creator>
-<description>
- HTMLCollections are live, they are automatically updated when the
- underlying document is changed.
-
- Create a HTMLCollection object by invoking the rows attribute of the
- first TABLE element and examine its length, then add a new row and
- re-examine the length.
-</description>
-<contributor>Rick Rivello</contributor>
-<date qualifier="created">2002-05-01</date>
-<subject resource="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-4005..."/>
-</metadata>
-<var name="nodeList" type="NodeList"/>
-<var name="testNode" type="Node"/>
-<var name="rowLength1" type="int"/>
-<var name="rowLength2" type="int"/>
-<var name="rowsnodeList" type="HTMLCollection"/>
-<var name="newRow" type="HTMLElement"/>
-<var name="vrowindex" type="int" />
-<var name="doc" type="Document"/>
-<var name="result" type="List"/>
-<var name="expectedResult" type="List">
-<member>4</member>
-<member>5</member>
-</var>
-<load var="doc" href="collection" willBeModified="true"/>
-<getElementsByTagName interface="Document" obj="doc" var="nodeList" tagname='"table"'/>
-<assertSize collection="nodeList" size="1" id="Asize"/>
-<item interface="NodeList" obj="nodeList" var="testNode" index="0"/>
-<rows interface="HTMLTableElement" obj="testNode" var="rowsnodeList"/>
-<length interface="HTMLCollection" obj="rowsnodeList" var="rowLength1"/>
-<append collection="result" item="rowLength1"/>
-<insertRow interface="HTMLTableElement" obj="testNode" var="newRow" index="4"/>
-<length interface="HTMLCollection" obj="rowsnodeList" var="rowLength2"/>
-<append collection="result" item="rowLength2"/>
-<assertEquals actual="result" expected="expectedResult" id="rowIndexLink" ignoreCase="false"/>
-</test>
diff --git a/test/testcases/tests/level1/html/HTMLCollection04.xml.notimpl b/test/testcases/tests/level1/html/HTMLCollection04.xml.notimpl
deleted file mode 100644
index 5d78405..0000000
--- a/test/testcases/tests/level1/html/HTMLCollection04.xml.notimpl
+++ /dev/null
@@ -1,59 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?xml-stylesheet href="test-to-html.xml" 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="HTMLCollection04">
-<metadata>
-<title>HTMLCollection04</title>
-<creator>NIST</creator>
-<description>
- HTMLCollections are live, they are automatically updated when the
- underlying document is changed.
-
- Create a HTMLCollection object by invoking the rows attribute of the
- first TABLE element and examine its length, then add a new row and
- re-examine the length.
-</description>
-<contributor>Rick Rivello</contributor>
-<date qualifier="created">2002-05-01</date>
-<subject resource="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-4005..."/>
-</metadata>
-<var name="nodeList" type="NodeList"/>
-<var name="testNode" type="Node"/>
-<var name="rowLength1" type="int"/>
-<var name="rowLength2" type="int"/>
-<var name="rowsnodeList" type="HTMLCollection"/>
-<var name="newRow" type="HTMLElement"/>
-<var name="vrowindex" type="int" />
-<var name="doc" type="Document"/>
-<var name="result" type="List"/>
-<var name="expectedResult" type="List">
-<member>4</member>
-<member>5</member>
-</var>
-<load var="doc" href="collection" willBeModified="true"/>
-<getElementsByTagName interface="Document" obj="doc" var="nodeList" tagname='"table"'/>
-<assertSize collection="nodeList" size="1" id="Asize"/>
-<item interface="NodeList" obj="nodeList" var="testNode" index="0"/>
-<rows interface="HTMLTableElement" obj="testNode" var="rowsnodeList"/>
-<length interface="HTMLCollection" obj="rowsnodeList" var="rowLength1"/>
-<append collection="result" item="rowLength1"/>
-<insertRow interface="HTMLTableElement" obj="testNode" var="newRow" index="4"/>
-<length interface="HTMLCollection" obj="rowsnodeList" var="rowLength2"/>
-<append collection="result" item="rowLength2"/>
-<assertEquals actual="result" expected="expectedResult" id="rowIndexLink" ignoreCase="false"/>
-</test>
diff --git a/test/testcases/tests/level1/html/HTMLCollection05.xml b/test/testcases/tests/level1/html/HTMLCollection05.xml
new file mode 100644
index 0000000..ffb7d13
--- /dev/null
+++ b/test/testcases/tests/level1/html/HTMLCollection05.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?xml-stylesheet href="test-to-html.xml" 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="HTMLCollection05">
+<metadata>
+<title>HTMLCollection05</title>
+<creator>NIST</creator>
+<description>
+ The length attribute specifies the length or size of the list.
+
+ Retrieve the first TABLE element and create a HTMLCollection by invoking
+ the "rows" attribute. Retrieve the length attribute of the HTMLCollection
+ object.
+</description>
+<contributor>Rick Rivello</contributor>
+<date qualifier="created">2002-05-01</date>
+<subject resource="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-4005..."/>
+</metadata>
+<var name="nodeList" type="NodeList"/>
+<var name="testNode" type="Node"/>
+<var name="rowsnodeList" type="HTMLCollection"/>
+<var name="rowLength" type="int" />
+<var name="doc" type="Document"/>
+<load var="doc" href="collection" willBeModified="false"/>
+<getElementsByTagName interface="Document" obj="doc" var="nodeList" tagname='"table"'/>
+<assertSize collection="nodeList" size="1" id="Asize"/>
+<item interface="NodeList" obj="nodeList" var="testNode" index="0"/>
+<rows interface="HTMLTableElement" obj="testNode" var="rowsnodeList"/>
+<length interface="HTMLCollection" obj="rowsnodeList" var="rowLength"/>
+<assertEquals actual="rowLength" expected="4" id="rowIndexLink" ignoreCase="false"/>
+</test>
diff --git a/test/testcases/tests/level1/html/HTMLCollection05.xml.kfail b/test/testcases/tests/level1/html/HTMLCollection05.xml.kfail
deleted file mode 100644
index ffb7d13..0000000
--- a/test/testcases/tests/level1/html/HTMLCollection05.xml.kfail
+++ /dev/null
@@ -1,46 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?xml-stylesheet href="test-to-html.xml" 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="HTMLCollection05">
-<metadata>
-<title>HTMLCollection05</title>
-<creator>NIST</creator>
-<description>
- The length attribute specifies the length or size of the list.
-
- Retrieve the first TABLE element and create a HTMLCollection by invoking
- the "rows" attribute. Retrieve the length attribute of the HTMLCollection
- object.
-</description>
-<contributor>Rick Rivello</contributor>
-<date qualifier="created">2002-05-01</date>
-<subject resource="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-4005..."/>
-</metadata>
-<var name="nodeList" type="NodeList"/>
-<var name="testNode" type="Node"/>
-<var name="rowsnodeList" type="HTMLCollection"/>
-<var name="rowLength" type="int" />
-<var name="doc" type="Document"/>
-<load var="doc" href="collection" willBeModified="false"/>
-<getElementsByTagName interface="Document" obj="doc" var="nodeList" tagname='"table"'/>
-<assertSize collection="nodeList" size="1" id="Asize"/>
-<item interface="NodeList" obj="nodeList" var="testNode" index="0"/>
-<rows interface="HTMLTableElement" obj="testNode" var="rowsnodeList"/>
-<length interface="HTMLCollection" obj="rowsnodeList" var="rowLength"/>
-<assertEquals actual="rowLength" expected="4" id="rowIndexLink" ignoreCase="false"/>
-</test>
diff --git a/test/testcases/tests/level1/html/HTMLCollection05.xml.notimpl b/test/testcases/tests/level1/html/HTMLCollection05.xml.notimpl
deleted file mode 100644
index ffb7d13..0000000
--- a/test/testcases/tests/level1/html/HTMLCollection05.xml.notimpl
+++ /dev/null
@@ -1,46 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?xml-stylesheet href="test-to-html.xml" 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="HTMLCollection05">
-<metadata>
-<title>HTMLCollection05</title>
-<creator>NIST</creator>
-<description>
- The length attribute specifies the length or size of the list.
-
- Retrieve the first TABLE element and create a HTMLCollection by invoking
- the "rows" attribute. Retrieve the length attribute of the HTMLCollection
- object.
-</description>
-<contributor>Rick Rivello</contributor>
-<date qualifier="created">2002-05-01</date>
-<subject resource="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-4005..."/>
-</metadata>
-<var name="nodeList" type="NodeList"/>
-<var name="testNode" type="Node"/>
-<var name="rowsnodeList" type="HTMLCollection"/>
-<var name="rowLength" type="int" />
-<var name="doc" type="Document"/>
-<load var="doc" href="collection" willBeModified="false"/>
-<getElementsByTagName interface="Document" obj="doc" var="nodeList" tagname='"table"'/>
-<assertSize collection="nodeList" size="1" id="Asize"/>
-<item interface="NodeList" obj="nodeList" var="testNode" index="0"/>
-<rows interface="HTMLTableElement" obj="testNode" var="rowsnodeList"/>
-<length interface="HTMLCollection" obj="rowsnodeList" var="rowLength"/>
-<assertEquals actual="rowLength" expected="4" id="rowIndexLink" ignoreCase="false"/>
-</test>
diff --git a/test/testcases/tests/level1/html/HTMLCollection06.xml b/test/testcases/tests/level1/html/HTMLCollection06.xml
new file mode 100644
index 0000000..1026310
--- /dev/null
+++ b/test/testcases/tests/level1/html/HTMLCollection06.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?xml-stylesheet href="test-to-html.xml" 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="HTMLCollection06">
+<metadata>
+<title>HTMLCollection06</title>
+<creator>NIST</creator>
+<description>
+ An item(index) method retrieves an item specified by ordinal index
+ (Test for index=0).
+
+ Retrieve the first TABLE element and create a HTMLCollection by invoking
+ the "rows" attribute. The item located at ordinal index 0 is further
+ retrieved and its "rowIndex" attribute is examined.
+</description>
+<contributor>Rick Rivello</contributor>
+<date qualifier="created">2002-05-01</date>
+<subject resource="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-6156016"/>
+<subject resource="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-3326..."/>
+</metadata>
+<var name="nodeList" type="NodeList"/>
+<var name="testNode" type="Node"/>
+<var name="rowNode" type="Node"/>
+<var name="rowsnodeList" type="HTMLCollection"/>
+<var name="vrowindex" type="int" />
+<var name="doc" type="Document"/>
+<load var="doc" href="collection" willBeModified="false"/>
+<getElementsByTagName interface="Document" obj="doc" var="nodeList" tagname='"table"'/>
+<assertSize collection="nodeList" size="1" id="Asize"/>
+<item interface="NodeList" obj="nodeList" var="testNode" index="0"/>
+<rows interface="HTMLTableElement" obj="testNode" var="rowsnodeList"/>
+<item interface="HTMLCollection" obj="rowsnodeList" var="rowNode" index="0"/>
+<rowIndex interface="HTMLTableRowElement" obj="rowNode" var="vrowindex"/>
+<assertEquals actual="vrowindex" expected="0" id="rowIndexLink" ignoreCase="false"/>
+</test>
diff --git a/test/testcases/tests/level1/html/HTMLCollection06.xml.notimpl b/test/testcases/tests/level1/html/HTMLCollection06.xml.notimpl
deleted file mode 100644
index 1026310..0000000
--- a/test/testcases/tests/level1/html/HTMLCollection06.xml.notimpl
+++ /dev/null
@@ -1,50 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?xml-stylesheet href="test-to-html.xml" 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="HTMLCollection06">
-<metadata>
-<title>HTMLCollection06</title>
-<creator>NIST</creator>
-<description>
- An item(index) method retrieves an item specified by ordinal index
- (Test for index=0).
-
- Retrieve the first TABLE element and create a HTMLCollection by invoking
- the "rows" attribute. The item located at ordinal index 0 is further
- retrieved and its "rowIndex" attribute is examined.
-</description>
-<contributor>Rick Rivello</contributor>
-<date qualifier="created">2002-05-01</date>
-<subject resource="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-6156016"/>
-<subject resource="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-3326..."/>
-</metadata>
-<var name="nodeList" type="NodeList"/>
-<var name="testNode" type="Node"/>
-<var name="rowNode" type="Node"/>
-<var name="rowsnodeList" type="HTMLCollection"/>
-<var name="vrowindex" type="int" />
-<var name="doc" type="Document"/>
-<load var="doc" href="collection" willBeModified="false"/>
-<getElementsByTagName interface="Document" obj="doc" var="nodeList" tagname='"table"'/>
-<assertSize collection="nodeList" size="1" id="Asize"/>
-<item interface="NodeList" obj="nodeList" var="testNode" index="0"/>
-<rows interface="HTMLTableElement" obj="testNode" var="rowsnodeList"/>
-<item interface="HTMLCollection" obj="rowsnodeList" var="rowNode" index="0"/>
-<rowIndex interface="HTMLTableRowElement" obj="rowNode" var="vrowindex"/>
-<assertEquals actual="vrowindex" expected="0" id="rowIndexLink" ignoreCase="false"/>
-</test>
diff --git a/test/testcases/tests/level1/html/HTMLCollection07.xml b/test/testcases/tests/level1/html/HTMLCollection07.xml
new file mode 100644
index 0000000..55e392f
--- /dev/null
+++ b/test/testcases/tests/level1/html/HTMLCollection07.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?xml-stylesheet href="test-to-html.xml" 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="HTMLCollection07">
+<metadata>
+<title>HTMLCollection07</title>
+<creator>NIST</creator>
+<description>
+ An item(index) method retrieves an item specified by ordinal index
+ (Test for index=3).
+
+ Retrieve the first TABLE element and create a HTMLCollection by invoking
+ the "rows" attribute. The item located at ordinal index 3 is further
+ retrieved and its "rowIndex" attribute is examined.
+</description>
+<contributor>Rick Rivello</contributor>
+<date qualifier="created">2002-05-01</date>
+<subject resource="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-3326..."/>
+</metadata>
+<var name="nodeList" type="NodeList"/>
+<var name="testNode" type="Node"/>
+<var name="rowNode" type="Node"/>
+<var name="rowsnodeList" type="HTMLCollection"/>
+<var name="vrowindex" type="int" />
+<var name="doc" type="Document"/>
+<load var="doc" href="collection" willBeModified="false"/>
+<getElementsByTagName interface="Document" obj="doc" var="nodeList" tagname='"table"'/>
+<assertSize collection="nodeList" size="1" id="Asize"/>
+<item interface="NodeList" obj="nodeList" var="testNode" index="0"/>
+<rows interface="HTMLTableElement" obj="testNode" var="rowsnodeList"/>
+<item interface="HTMLCollection" obj="rowsnodeList" var="rowNode" index="3"/>
+<rowIndex interface="HTMLTableRowElement" obj="rowNode" var="vrowindex"/>
+<assertEquals actual="vrowindex" expected="2" id="rowIndexLink" ignoreCase="false"/>
+</test>
diff --git a/test/testcases/tests/level1/html/HTMLCollection07.xml.notimpl b/test/testcases/tests/level1/html/HTMLCollection07.xml.notimpl
deleted file mode 100644
index e0a21a2..0000000
--- a/test/testcases/tests/level1/html/HTMLCollection07.xml.notimpl
+++ /dev/null
@@ -1,49 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?xml-stylesheet href="test-to-html.xml" 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="HTMLCollection07">
-<metadata>
-<title>HTMLCollection07</title>
-<creator>NIST</creator>
-<description>
- An item(index) method retrieves an item specified by ordinal index
- (Test for index=3).
-
- Retrieve the first TABLE element and create a HTMLCollection by invoking
- the "rows" attribute. The item located at ordinal index 3 is further
- retrieved and its "rowIndex" attribute is examined.
-</description>
-<contributor>Rick Rivello</contributor>
-<date qualifier="created">2002-05-01</date>
-<subject resource="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-3326..."/>
-</metadata>
-<var name="nodeList" type="NodeList"/>
-<var name="testNode" type="Node"/>
-<var name="rowNode" type="Node"/>
-<var name="rowsnodeList" type="HTMLCollection"/>
-<var name="vrowindex" type="int" />
-<var name="doc" type="Document"/>
-<load var="doc" href="collection" willBeModified="false"/>
-<getElementsByTagName interface="Document" obj="doc" var="nodeList" tagname='"table"'/>
-<assertSize collection="nodeList" size="1" id="Asize"/>
-<item interface="NodeList" obj="nodeList" var="testNode" index="0"/>
-<rows interface="HTMLTableElement" obj="testNode" var="rowsnodeList"/>
-<item interface="HTMLCollection" obj="rowsnodeList" var="rowNode" index="3"/>
-<rowIndex interface="HTMLTableRowElement" obj="rowNode" var="vrowindex"/>
-<assertEquals actual="vrowindex" expected="3" id="rowIndexLink" ignoreCase="false"/>
-</test>
diff --git a/test/testcases/tests/level1/html/HTMLCollection08.xml b/test/testcases/tests/level1/html/HTMLCollection08.xml
new file mode 100644
index 0000000..8f7f138
--- /dev/null
+++ b/test/testcases/tests/level1/html/HTMLCollection08.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?xml-stylesheet href="test-to-html.xml" 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="HTMLCollection08">
+<metadata>
+<title>HTMLCollection08</title>
+<creator>NIST</creator>
+<description>
+ Nodes in a HTMLCollection object are numbered in tree order.
+ (Depth-first traversal order).
+
+ Retrieve the first TABLE element and create a HTMLCollection by invoking
+ the "rows" attribute. Access the item in the third ordinal index. The
+ resulting rowIndex attribute is examined and should be two.
+</description>
+<contributor>Rick Rivello</contributor>
+<date qualifier="created">2002-05-01</date>
+<subject resource="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-3326..."/>
+</metadata>
+<var name="nodeList" type="NodeList"/>
+<var name="testNode" type="Node"/>
+<var name="rowNode" type="Node"/>
+<var name="rowsnodeList" type="HTMLCollection"/>
+<var name="vrowindex" type="int" />
+<var name="doc" type="Document"/>
+<load var="doc" href="collection" willBeModified="false"/>
+<getElementsByTagName interface="Document" obj="doc" var="nodeList" tagname='"table"'/>
+<assertSize collection="nodeList" size="1" id="Asize"/>
+<item interface="NodeList" obj="nodeList" var="testNode" index="0"/>
+<rows interface="HTMLTableElement" obj="testNode" var="rowsnodeList"/>
+<item interface="HTMLCollection" obj="rowsnodeList" var="rowNode" index="3"/>
+<rowIndex interface="HTMLTableRowElement" obj="rowNode" var="vrowindex"/>
+<assertEquals actual="vrowindex" expected="2" id="rowIndexLink" ignoreCase="false"/>
+</test>
diff --git a/test/testcases/tests/level1/html/HTMLCollection08.xml.notimpl b/test/testcases/tests/level1/html/HTMLCollection08.xml.notimpl
deleted file mode 100644
index dfc2e10..0000000
--- a/test/testcases/tests/level1/html/HTMLCollection08.xml.notimpl
+++ /dev/null
@@ -1,49 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?xml-stylesheet href="test-to-html.xml" 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="HTMLCollection08">
-<metadata>
-<title>HTMLCollection08</title>
-<creator>NIST</creator>
-<description>
- Nodes in a HTMLCollection object are numbered in tree order.
- (Depth-first traversal order).
-
- Retrieve the first TABLE element and create a HTMLCollection by invoking
- the "rows" attribute. Access the item in the third ordinal index. The
- resulting rowIndex attribute is examined and should be two.
-</description>
-<contributor>Rick Rivello</contributor>
-<date qualifier="created">2002-05-01</date>
-<subject resource="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-3326..."/>
-</metadata>
-<var name="nodeList" type="NodeList"/>
-<var name="testNode" type="Node"/>
-<var name="rowNode" type="Node"/>
-<var name="rowsnodeList" type="HTMLCollection"/>
-<var name="vrowindex" type="int" />
-<var name="doc" type="Document"/>
-<load var="doc" href="collection" willBeModified="false"/>
-<getElementsByTagName interface="Document" obj="doc" var="nodeList" tagname='"table"'/>
-<assertSize collection="nodeList" size="1" id="Asize"/>
-<item interface="NodeList" obj="nodeList" var="testNode" index="0"/>
-<rows interface="HTMLTableElement" obj="testNode" var="rowsnodeList"/>
-<item interface="HTMLCollection" obj="rowsnodeList" var="rowNode" index="2"/>
-<rowIndex interface="HTMLTableRowElement" obj="rowNode" var="vrowindex"/>
-<assertEquals actual="vrowindex" expected="2" id="rowIndexLink" ignoreCase="false"/>
-</test>
diff --git a/test/testcases/tests/level1/html/HTMLCollection09.xml b/test/testcases/tests/level1/html/HTMLCollection09.xml
new file mode 100644
index 0000000..f81e7af
--- /dev/null
+++ b/test/testcases/tests/level1/html/HTMLCollection09.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?xml-stylesheet href="test-to-html.xml" 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="HTMLCollection09">
+<metadata>
+<title>HTMLCollection09</title>
+<creator>NIST</creator>
+<description>
+ The item(index) method returns null if the index is out of range.
+
+ Retrieve the first TABLE element and create a HTMLCollection by invoking
+ the "rows" attribute. Invoke the item(index) method with an index
+ of 5. This index is out of range and should return null.
+</description>
+<contributor>Rick Rivello</contributor>
+<date qualifier="created">2002-05-01</date>
+<subject resource="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-3326..."/>
+</metadata>
+<var name="nodeList" type="NodeList"/>
+<var name="testNode" type="Node"/>
+<var name="rowNode" type="Node"/>
+<var name="rowsnodeList" type="HTMLCollection"/>
+<var name="vrowindex" type="int" />
+<var name="doc" type="Document"/>
+<load var="doc" href="collection" willBeModified="false"/>
+<getElementsByTagName interface="Document" obj="doc" var="nodeList" tagname='"table"'/>
+<assertSize collection="nodeList" size="1" id="Asize"/>
+<item interface="NodeList" obj="nodeList" var="testNode" index="0"/>
+<rows interface="HTMLTableElement" obj="testNode" var="rowsnodeList"/>
+<item interface="HTMLCollection" obj="rowsnodeList" var="rowNode" index="5"/>
+<assertNull actual="rowNode" id="rowIndexLink"/>
+</test>
diff --git a/test/testcases/tests/level1/html/HTMLCollection09.xml.kfail b/test/testcases/tests/level1/html/HTMLCollection09.xml.kfail
deleted file mode 100644
index f81e7af..0000000
--- a/test/testcases/tests/level1/html/HTMLCollection09.xml.kfail
+++ /dev/null
@@ -1,47 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?xml-stylesheet href="test-to-html.xml" 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="HTMLCollection09">
-<metadata>
-<title>HTMLCollection09</title>
-<creator>NIST</creator>
-<description>
- The item(index) method returns null if the index is out of range.
-
- Retrieve the first TABLE element and create a HTMLCollection by invoking
- the "rows" attribute. Invoke the item(index) method with an index
- of 5. This index is out of range and should return null.
-</description>
-<contributor>Rick Rivello</contributor>
-<date qualifier="created">2002-05-01</date>
-<subject resource="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-3326..."/>
-</metadata>
-<var name="nodeList" type="NodeList"/>
-<var name="testNode" type="Node"/>
-<var name="rowNode" type="Node"/>
-<var name="rowsnodeList" type="HTMLCollection"/>
-<var name="vrowindex" type="int" />
-<var name="doc" type="Document"/>
-<load var="doc" href="collection" willBeModified="false"/>
-<getElementsByTagName interface="Document" obj="doc" var="nodeList" tagname='"table"'/>
-<assertSize collection="nodeList" size="1" id="Asize"/>
-<item interface="NodeList" obj="nodeList" var="testNode" index="0"/>
-<rows interface="HTMLTableElement" obj="testNode" var="rowsnodeList"/>
-<item interface="HTMLCollection" obj="rowsnodeList" var="rowNode" index="5"/>
-<assertNull actual="rowNode" id="rowIndexLink"/>
-</test>
diff --git a/test/testcases/tests/level1/html/HTMLCollection09.xml.notimpl b/test/testcases/tests/level1/html/HTMLCollection09.xml.notimpl
deleted file mode 100644
index f81e7af..0000000
--- a/test/testcases/tests/level1/html/HTMLCollection09.xml.notimpl
+++ /dev/null
@@ -1,47 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?xml-stylesheet href="test-to-html.xml" 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="HTMLCollection09">
-<metadata>
-<title>HTMLCollection09</title>
-<creator>NIST</creator>
-<description>
- The item(index) method returns null if the index is out of range.
-
- Retrieve the first TABLE element and create a HTMLCollection by invoking
- the "rows" attribute. Invoke the item(index) method with an index
- of 5. This index is out of range and should return null.
-</description>
-<contributor>Rick Rivello</contributor>
-<date qualifier="created">2002-05-01</date>
-<subject resource="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-3326..."/>
-</metadata>
-<var name="nodeList" type="NodeList"/>
-<var name="testNode" type="Node"/>
-<var name="rowNode" type="Node"/>
-<var name="rowsnodeList" type="HTMLCollection"/>
-<var name="vrowindex" type="int" />
-<var name="doc" type="Document"/>
-<load var="doc" href="collection" willBeModified="false"/>
-<getElementsByTagName interface="Document" obj="doc" var="nodeList" tagname='"table"'/>
-<assertSize collection="nodeList" size="1" id="Asize"/>
-<item interface="NodeList" obj="nodeList" var="testNode" index="0"/>
-<rows interface="HTMLTableElement" obj="testNode" var="rowsnodeList"/>
-<item interface="HTMLCollection" obj="rowsnodeList" var="rowNode" index="5"/>
-<assertNull actual="rowNode" id="rowIndexLink"/>
-</test>
diff --git a/test/testcases/tests/level1/html/HTMLCollection10.xml b/test/testcases/tests/level1/html/HTMLCollection10.xml
new file mode 100644
index 0000000..78f4c9a
--- /dev/null
+++ b/test/testcases/tests/level1/html/HTMLCollection10.xml
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?xml-stylesheet href="test-to-html.xml" 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="HTMLCollection10">
+<metadata>
+<title>HTMLCollection10</title>
+<creator>NIST</creator>
+<description>
+ The namedItem(name) method retrieves a node using a name. It first
+ searches for a node with a matching id attribute. If it doesn't find
+ one, it then searches for a Node with a matching name attribute, but only
+ on those elements that are allowed a name attribute.
+
+ Retrieve the first FORM element and create a HTMLCollection by invoking
+ the elements attribute. The first SELECT element is further retrieved
+ using the elements name attribute since the id attribute doesn't match.
+</description>
+<contributor>Rick Rivello</contributor>
+<date qualifier="created">2002-05-01</date>
+<subject resource="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-2106..."/>
+</metadata>
+<var name="nodeList" type="NodeList"/>
+<var name="testNode" type="Node"/>
+<var name="formNode" type="Node"/>
+<var name="formsnodeList" type="HTMLCollection"/>
+<var name="vname" type="DOMString" />
+<var name="doc" type="Document"/>
+<load var="doc" href="collection" willBeModified="false"/>
+<getElementsByTagName interface="Document" obj="doc" var="nodeList" tagname='"form"'/>
+<assertSize collection="nodeList" size="1" id="Asize"/>
+<item interface="NodeList" obj="nodeList" var="testNode" index="0"/>
+<elements interface="HTMLFormElement" obj="testNode" var="formsnodeList"/>
+<namedItem obj="formsnodeList" var="formNode" name='"select1"'/>
+<nodeName obj="formNode" var="vname"/>
+<assertEquals actual="vname" expected='"SELECT"' id="nameIndexLink" ignoreCase="auto"/>
+</test>
diff --git a/test/testcases/tests/level1/html/HTMLCollection10.xml.kfail b/test/testcases/tests/level1/html/HTMLCollection10.xml.kfail
deleted file mode 100644
index 78f4c9a..0000000
--- a/test/testcases/tests/level1/html/HTMLCollection10.xml.kfail
+++ /dev/null
@@ -1,51 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?xml-stylesheet href="test-to-html.xml" 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="HTMLCollection10">
-<metadata>
-<title>HTMLCollection10</title>
-<creator>NIST</creator>
-<description>
- The namedItem(name) method retrieves a node using a name. It first
- searches for a node with a matching id attribute. If it doesn't find
- one, it then searches for a Node with a matching name attribute, but only
- on those elements that are allowed a name attribute.
-
- Retrieve the first FORM element and create a HTMLCollection by invoking
- the elements attribute. The first SELECT element is further retrieved
- using the elements name attribute since the id attribute doesn't match.
-</description>
-<contributor>Rick Rivello</contributor>
-<date qualifier="created">2002-05-01</date>
-<subject resource="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-2106..."/>
-</metadata>
-<var name="nodeList" type="NodeList"/>
-<var name="testNode" type="Node"/>
-<var name="formNode" type="Node"/>
-<var name="formsnodeList" type="HTMLCollection"/>
-<var name="vname" type="DOMString" />
-<var name="doc" type="Document"/>
-<load var="doc" href="collection" willBeModified="false"/>
-<getElementsByTagName interface="Document" obj="doc" var="nodeList" tagname='"form"'/>
-<assertSize collection="nodeList" size="1" id="Asize"/>
-<item interface="NodeList" obj="nodeList" var="testNode" index="0"/>
-<elements interface="HTMLFormElement" obj="testNode" var="formsnodeList"/>
-<namedItem obj="formsnodeList" var="formNode" name='"select1"'/>
-<nodeName obj="formNode" var="vname"/>
-<assertEquals actual="vname" expected='"SELECT"' id="nameIndexLink" ignoreCase="auto"/>
-</test>
diff --git a/test/testcases/tests/level1/html/HTMLCollection11.xml b/test/testcases/tests/level1/html/HTMLCollection11.xml
new file mode 100644
index 0000000..ebf217f
--- /dev/null
+++ b/test/testcases/tests/level1/html/HTMLCollection11.xml
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?xml-stylesheet href="test-to-html.xml" 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="HTMLCollection11">
+<metadata>
+<title>HTMLCollection11</title>
+<creator>NIST</creator>
+<description>
+ The namedItem(name) method retrieves a node using a name. It first
+ searches for a node with a matching id attribute. If it doesn't find
+ one, it then searches for a Node with a matching name attribute, but only
+ on those elements that are allowed a name attribute.
+
+ Retrieve the first FORM element and create a HTMLCollection by invoking
+ the elements attribute. The first SELECT element is further retrieved
+ using the elements id attribute.
+</description>
+<contributor>Rick Rivello</contributor>
+<date qualifier="created">2002-05-01</date>
+<subject resource="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-7672..."/>
+</metadata>
+<var name="nodeList" type="NodeList"/>
+<var name="testNode" type="Node"/>
+<var name="formNode" type="Node"/>
+<var name="formsnodeList" type="HTMLCollection"/>
+<var name="vname" type="DOMString" />
+<var name="doc" type="Document"/>
+<load var="doc" href="collection" willBeModified="false"/>
+<getElementsByTagName interface="Document" obj="doc" var="nodeList" tagname='"form"'/>
+<assertSize collection="nodeList" size="1" id="Asize"/>
+<item interface="NodeList" obj="nodeList" var="testNode" index="0"/>
+<elements interface="HTMLFormElement" obj="testNode" var="formsnodeList"/>
+<namedItem obj="formsnodeList" var="formNode" name='"selectId"'/>
+<nodeName obj="formNode" var="vname"/>
+<assertEquals actual="vname" expected='"select"' id="nameIndexLink" ignoreCase="auto"/>
+</test>
diff --git a/test/testcases/tests/level1/html/HTMLCollection11.xml.kfail b/test/testcases/tests/level1/html/HTMLCollection11.xml.kfail
deleted file mode 100644
index ebf217f..0000000
--- a/test/testcases/tests/level1/html/HTMLCollection11.xml.kfail
+++ /dev/null
@@ -1,51 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?xml-stylesheet href="test-to-html.xml" 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="HTMLCollection11">
-<metadata>
-<title>HTMLCollection11</title>
-<creator>NIST</creator>
-<description>
- The namedItem(name) method retrieves a node using a name. It first
- searches for a node with a matching id attribute. If it doesn't find
- one, it then searches for a Node with a matching name attribute, but only
- on those elements that are allowed a name attribute.
-
- Retrieve the first FORM element and create a HTMLCollection by invoking
- the elements attribute. The first SELECT element is further retrieved
- using the elements id attribute.
-</description>
-<contributor>Rick Rivello</contributor>
-<date qualifier="created">2002-05-01</date>
-<subject resource="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-7672..."/>
-</metadata>
-<var name="nodeList" type="NodeList"/>
-<var name="testNode" type="Node"/>
-<var name="formNode" type="Node"/>
-<var name="formsnodeList" type="HTMLCollection"/>
-<var name="vname" type="DOMString" />
-<var name="doc" type="Document"/>
-<load var="doc" href="collection" willBeModified="false"/>
-<getElementsByTagName interface="Document" obj="doc" var="nodeList" tagname='"form"'/>
-<assertSize collection="nodeList" size="1" id="Asize"/>
-<item interface="NodeList" obj="nodeList" var="testNode" index="0"/>
-<elements interface="HTMLFormElement" obj="testNode" var="formsnodeList"/>
-<namedItem obj="formsnodeList" var="formNode" name='"selectId"'/>
-<nodeName obj="formNode" var="vname"/>
-<assertEquals actual="vname" expected='"select"' id="nameIndexLink" ignoreCase="auto"/>
-</test>
diff --git a/test/testcases/tests/level1/html/HTMLCollection12.xml.kfail b/test/testcases/tests/level1/html/HTMLCollection12.xml.kfail
deleted file mode 100644
index d7feb3d..0000000
--- a/test/testcases/tests/level1/html/HTMLCollection12.xml.kfail
+++ /dev/null
@@ -1,50 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?xml-stylesheet href="test-to-html.xml" 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="HTMLCollection12">
-<metadata>
-<title>HTMLCollection12</title>
-<creator>NIST</creator>
-<description>
- The namedItem(name) method retrieves a node using a name. It first
- searches for a node with a matching id attribute. If it doesn't find
- one, it then searches for a Node with a matching name attribute, but only
- on those elements that are allowed a name attribute. If there isn't
- a matching node the method returns null.
-
- Retrieve the first FORM element and create a HTMLCollection by invoking
- the elements attribute. The method returns null since there is not a
- match of the name or id attribute.
-</description>
-<contributor>Rick Rivello</contributor>
-<date qualifier="created">2002-05-01</date>
-<subject resource="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-2106..."/>
-</metadata>
-<var name="nodeList" type="NodeList"/>
-<var name="testNode" type="Node"/>
-<var name="formNode" type="Node"/>
-<var name="formsnodeList" type="HTMLCollection"/>
-<var name="doc" type="Document"/>
-<load var="doc" href="collection" willBeModified="false"/>
-<getElementsByTagName interface="Document" obj="doc" var="nodeList" tagname='"form"'/>
-<assertSize collection="nodeList" size="1" id="Asize"/>
-<item interface="NodeList" obj="nodeList" var="testNode" index="0"/>
-<elements interface="HTMLFormElement" obj="testNode" var="formsnodeList"/>
-<namedItem obj="formsnodeList" var="formNode" name='"select9"'/>
-<assertNull actual="formNode" id="nameIndexLink" />
-</test>
-----------------------------------------------------------------------
Summary of changes:
src/html/html_collection.c | 25 +++++++-
src/html/html_document.c | 1 +
...Collection04.xml.kfail => HTMLCollection04.xml} | 0
.../tests/level1/html/HTMLCollection04.xml.notimpl | 59 --------------------
...Collection05.xml.kfail => HTMLCollection05.xml} | 0
.../tests/level1/html/HTMLCollection05.xml.notimpl | 46 ---------------
...llection06.xml.notimpl => HTMLCollection06.xml} | 0
...llection07.xml.notimpl => HTMLCollection07.xml} | 2 +-
...llection08.xml.notimpl => HTMLCollection08.xml} | 2 +-
...Collection09.xml.kfail => HTMLCollection09.xml} | 0
.../tests/level1/html/HTMLCollection09.xml.notimpl | 47 ----------------
...Collection10.xml.kfail => HTMLCollection10.xml} | 0
...Collection11.xml.kfail => HTMLCollection11.xml} | 0
.../tests/level1/html/HTMLCollection12.xml.kfail | 50 -----------------
14 files changed, 24 insertions(+), 208 deletions(-)
rename test/testcases/tests/level1/html/{HTMLCollection04.xml.kfail => HTMLCollection04.xml} (100%)
delete mode 100644 test/testcases/tests/level1/html/HTMLCollection04.xml.notimpl
rename test/testcases/tests/level1/html/{HTMLCollection05.xml.kfail => HTMLCollection05.xml} (100%)
delete mode 100644 test/testcases/tests/level1/html/HTMLCollection05.xml.notimpl
rename test/testcases/tests/level1/html/{HTMLCollection06.xml.notimpl => HTMLCollection06.xml} (100%)
rename test/testcases/tests/level1/html/{HTMLCollection07.xml.notimpl => HTMLCollection07.xml} (97%)
rename test/testcases/tests/level1/html/{HTMLCollection08.xml.notimpl => HTMLCollection08.xml} (99%)
rename test/testcases/tests/level1/html/{HTMLCollection09.xml.kfail => HTMLCollection09.xml} (100%)
delete mode 100644 test/testcases/tests/level1/html/HTMLCollection09.xml.notimpl
rename test/testcases/tests/level1/html/{HTMLCollection10.xml.kfail => HTMLCollection10.xml} (100%)
rename test/testcases/tests/level1/html/{HTMLCollection11.xml.kfail => HTMLCollection11.xml} (100%)
delete mode 100644 test/testcases/tests/level1/html/HTMLCollection12.xml.kfail
diff --git a/src/html/html_collection.c b/src/html/html_collection.c
index 2b4d8aa..43a26c5 100644
--- a/src/html/html_collection.c
+++ b/src/html/html_collection.c
@@ -11,6 +11,7 @@
#include <libwapcaplet/libwapcaplet.h>
#include "html/html_collection.h"
+#include "html/html_document.h"
#include "core/node.h"
#include "core/element.h"
@@ -182,7 +183,7 @@ dom_exception dom_html_collection_item(dom_html_collection *col,
/* No children and siblings */
struct dom_node_internal *parent = n->parent;
- while (parent != col->root &&
+ while (n != col->root &&
n == parent->last_child) {
n = parent;
parent = parent->parent;
@@ -212,8 +213,8 @@ dom_exception dom_html_collection_named_item(dom_html_collection *col,
dom_string *name, struct dom_node **node)
{
struct dom_node_internal *n = col->root;
+ dom_html_document *doc = (dom_html_document *)dom_node_get_owner(n);
dom_exception err;
-
while (n != NULL) {
if (n->type == DOM_ELEMENT_NODE &&
col->ic(n, col->ctx) == true) {
@@ -235,6 +236,22 @@ dom_exception dom_html_collection_named_item(dom_html_collection *col,
if (id != NULL)
dom_string_unref(id);
+
+ /* Check for Name attr if id not matched/found */
+ dom_string *id_name = NULL;
+ err = _dom_element_get_attribute((dom_element *)n,
+ doc->memoised[hds_name], &id_name);
+ if(err != DOM_NO_ERR) {
+ return err;
+ }
+ if (id_name != NULL && dom_string_isequal(name, id_name)) {
+ *node = (struct dom_node *) n;
+ dom_node_ref(n);
+ dom_string_unref(id_name);
+
+ return DOM_NO_ERR;
+ }
+
}
/* Depth first iterating */
@@ -246,13 +263,13 @@ dom_exception dom_html_collection_named_item(dom_html_collection *col,
/* No children and siblings */
struct dom_node_internal *parent = n->parent;
- while (parent != col->root &&
+ while (n != col->root &&
n == parent->last_child) {
n = parent;
parent = parent->parent;
}
- if (parent == col->root)
+ if (n == col->root)
n = NULL;
else
n = n->next;
diff --git a/src/html/html_document.c b/src/html/html_document.c
index ee16ac4..0eca66d 100644
--- a/src/html/html_document.c
+++ b/src/html/html_document.c
@@ -907,6 +907,7 @@ dom_exception _dom_html_document_set_cookie(dom_html_document *doc,
{
UNUSED(doc);
UNUSED(cookie);
+
/*todo implement this after updating client interface */
return DOM_NOT_SUPPORTED_ERR;
}
diff --git a/test/testcases/tests/level1/html/HTMLCollection04.xml.kfail b/test/testcases/tests/level1/html/HTMLCollection04.xml
similarity index 100%
rename from test/testcases/tests/level1/html/HTMLCollection04.xml.kfail
rename to test/testcases/tests/level1/html/HTMLCollection04.xml
diff --git a/test/testcases/tests/level1/html/HTMLCollection04.xml.notimpl b/test/testcases/tests/level1/html/HTMLCollection04.xml.notimpl
deleted file mode 100644
index 5d78405..0000000
--- a/test/testcases/tests/level1/html/HTMLCollection04.xml.notimpl
+++ /dev/null
@@ -1,59 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?xml-stylesheet href="test-to-html.xml" 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="HTMLCollection04">
-<metadata>
-<title>HTMLCollection04</title>
-<creator>NIST</creator>
-<description>
- HTMLCollections are live, they are automatically updated when the
- underlying document is changed.
-
- Create a HTMLCollection object by invoking the rows attribute of the
- first TABLE element and examine its length, then add a new row and
- re-examine the length.
-</description>
-<contributor>Rick Rivello</contributor>
-<date qualifier="created">2002-05-01</date>
-<subject resource="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-4005..."/>
-</metadata>
-<var name="nodeList" type="NodeList"/>
-<var name="testNode" type="Node"/>
-<var name="rowLength1" type="int"/>
-<var name="rowLength2" type="int"/>
-<var name="rowsnodeList" type="HTMLCollection"/>
-<var name="newRow" type="HTMLElement"/>
-<var name="vrowindex" type="int" />
-<var name="doc" type="Document"/>
-<var name="result" type="List"/>
-<var name="expectedResult" type="List">
-<member>4</member>
-<member>5</member>
-</var>
-<load var="doc" href="collection" willBeModified="true"/>
-<getElementsByTagName interface="Document" obj="doc" var="nodeList" tagname='"table"'/>
-<assertSize collection="nodeList" size="1" id="Asize"/>
-<item interface="NodeList" obj="nodeList" var="testNode" index="0"/>
-<rows interface="HTMLTableElement" obj="testNode" var="rowsnodeList"/>
-<length interface="HTMLCollection" obj="rowsnodeList" var="rowLength1"/>
-<append collection="result" item="rowLength1"/>
-<insertRow interface="HTMLTableElement" obj="testNode" var="newRow" index="4"/>
-<length interface="HTMLCollection" obj="rowsnodeList" var="rowLength2"/>
-<append collection="result" item="rowLength2"/>
-<assertEquals actual="result" expected="expectedResult" id="rowIndexLink" ignoreCase="false"/>
-</test>
diff --git a/test/testcases/tests/level1/html/HTMLCollection05.xml.kfail b/test/testcases/tests/level1/html/HTMLCollection05.xml
similarity index 100%
rename from test/testcases/tests/level1/html/HTMLCollection05.xml.kfail
rename to test/testcases/tests/level1/html/HTMLCollection05.xml
diff --git a/test/testcases/tests/level1/html/HTMLCollection05.xml.notimpl b/test/testcases/tests/level1/html/HTMLCollection05.xml.notimpl
deleted file mode 100644
index ffb7d13..0000000
--- a/test/testcases/tests/level1/html/HTMLCollection05.xml.notimpl
+++ /dev/null
@@ -1,46 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?xml-stylesheet href="test-to-html.xml" 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="HTMLCollection05">
-<metadata>
-<title>HTMLCollection05</title>
-<creator>NIST</creator>
-<description>
- The length attribute specifies the length or size of the list.
-
- Retrieve the first TABLE element and create a HTMLCollection by invoking
- the "rows" attribute. Retrieve the length attribute of the HTMLCollection
- object.
-</description>
-<contributor>Rick Rivello</contributor>
-<date qualifier="created">2002-05-01</date>
-<subject resource="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-4005..."/>
-</metadata>
-<var name="nodeList" type="NodeList"/>
-<var name="testNode" type="Node"/>
-<var name="rowsnodeList" type="HTMLCollection"/>
-<var name="rowLength" type="int" />
-<var name="doc" type="Document"/>
-<load var="doc" href="collection" willBeModified="false"/>
-<getElementsByTagName interface="Document" obj="doc" var="nodeList" tagname='"table"'/>
-<assertSize collection="nodeList" size="1" id="Asize"/>
-<item interface="NodeList" obj="nodeList" var="testNode" index="0"/>
-<rows interface="HTMLTableElement" obj="testNode" var="rowsnodeList"/>
-<length interface="HTMLCollection" obj="rowsnodeList" var="rowLength"/>
-<assertEquals actual="rowLength" expected="4" id="rowIndexLink" ignoreCase="false"/>
-</test>
diff --git a/test/testcases/tests/level1/html/HTMLCollection06.xml.notimpl b/test/testcases/tests/level1/html/HTMLCollection06.xml
similarity index 100%
rename from test/testcases/tests/level1/html/HTMLCollection06.xml.notimpl
rename to test/testcases/tests/level1/html/HTMLCollection06.xml
diff --git a/test/testcases/tests/level1/html/HTMLCollection07.xml.notimpl b/test/testcases/tests/level1/html/HTMLCollection07.xml
similarity index 97%
rename from test/testcases/tests/level1/html/HTMLCollection07.xml.notimpl
rename to test/testcases/tests/level1/html/HTMLCollection07.xml
index e0a21a2..55e392f 100644
--- a/test/testcases/tests/level1/html/HTMLCollection07.xml.notimpl
+++ b/test/testcases/tests/level1/html/HTMLCollection07.xml
@@ -45,5 +45,5 @@ See W3C License http://www.w3.org/Consortium/Legal/ for more details.
<rows interface="HTMLTableElement" obj="testNode" var="rowsnodeList"/>
<item interface="HTMLCollection" obj="rowsnodeList" var="rowNode" index="3"/>
<rowIndex interface="HTMLTableRowElement" obj="rowNode" var="vrowindex"/>
-<assertEquals actual="vrowindex" expected="3" id="rowIndexLink" ignoreCase="false"/>
+<assertEquals actual="vrowindex" expected="2" id="rowIndexLink" ignoreCase="false"/>
</test>
diff --git a/test/testcases/tests/level1/html/HTMLCollection08.xml.notimpl b/test/testcases/tests/level1/html/HTMLCollection08.xml
similarity index 99%
rename from test/testcases/tests/level1/html/HTMLCollection08.xml.notimpl
rename to test/testcases/tests/level1/html/HTMLCollection08.xml
index dfc2e10..8f7f138 100644
--- a/test/testcases/tests/level1/html/HTMLCollection08.xml.notimpl
+++ b/test/testcases/tests/level1/html/HTMLCollection08.xml
@@ -43,7 +43,7 @@ See W3C License http://www.w3.org/Consortium/Legal/ for more details.
<assertSize collection="nodeList" size="1" id="Asize"/>
<item interface="NodeList" obj="nodeList" var="testNode" index="0"/>
<rows interface="HTMLTableElement" obj="testNode" var="rowsnodeList"/>
-<item interface="HTMLCollection" obj="rowsnodeList" var="rowNode" index="2"/>
+<item interface="HTMLCollection" obj="rowsnodeList" var="rowNode" index="3"/>
<rowIndex interface="HTMLTableRowElement" obj="rowNode" var="vrowindex"/>
<assertEquals actual="vrowindex" expected="2" id="rowIndexLink" ignoreCase="false"/>
</test>
diff --git a/test/testcases/tests/level1/html/HTMLCollection09.xml.kfail b/test/testcases/tests/level1/html/HTMLCollection09.xml
similarity index 100%
rename from test/testcases/tests/level1/html/HTMLCollection09.xml.kfail
rename to test/testcases/tests/level1/html/HTMLCollection09.xml
diff --git a/test/testcases/tests/level1/html/HTMLCollection09.xml.notimpl b/test/testcases/tests/level1/html/HTMLCollection09.xml.notimpl
deleted file mode 100644
index f81e7af..0000000
--- a/test/testcases/tests/level1/html/HTMLCollection09.xml.notimpl
+++ /dev/null
@@ -1,47 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?xml-stylesheet href="test-to-html.xml" 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="HTMLCollection09">
-<metadata>
-<title>HTMLCollection09</title>
-<creator>NIST</creator>
-<description>
- The item(index) method returns null if the index is out of range.
-
- Retrieve the first TABLE element and create a HTMLCollection by invoking
- the "rows" attribute. Invoke the item(index) method with an index
- of 5. This index is out of range and should return null.
-</description>
-<contributor>Rick Rivello</contributor>
-<date qualifier="created">2002-05-01</date>
-<subject resource="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-3326..."/>
-</metadata>
-<var name="nodeList" type="NodeList"/>
-<var name="testNode" type="Node"/>
-<var name="rowNode" type="Node"/>
-<var name="rowsnodeList" type="HTMLCollection"/>
-<var name="vrowindex" type="int" />
-<var name="doc" type="Document"/>
-<load var="doc" href="collection" willBeModified="false"/>
-<getElementsByTagName interface="Document" obj="doc" var="nodeList" tagname='"table"'/>
-<assertSize collection="nodeList" size="1" id="Asize"/>
-<item interface="NodeList" obj="nodeList" var="testNode" index="0"/>
-<rows interface="HTMLTableElement" obj="testNode" var="rowsnodeList"/>
-<item interface="HTMLCollection" obj="rowsnodeList" var="rowNode" index="5"/>
-<assertNull actual="rowNode" id="rowIndexLink"/>
-</test>
diff --git a/test/testcases/tests/level1/html/HTMLCollection10.xml.kfail b/test/testcases/tests/level1/html/HTMLCollection10.xml
similarity index 100%
rename from test/testcases/tests/level1/html/HTMLCollection10.xml.kfail
rename to test/testcases/tests/level1/html/HTMLCollection10.xml
diff --git a/test/testcases/tests/level1/html/HTMLCollection11.xml.kfail b/test/testcases/tests/level1/html/HTMLCollection11.xml
similarity index 100%
rename from test/testcases/tests/level1/html/HTMLCollection11.xml.kfail
rename to test/testcases/tests/level1/html/HTMLCollection11.xml
diff --git a/test/testcases/tests/level1/html/HTMLCollection12.xml.kfail b/test/testcases/tests/level1/html/HTMLCollection12.xml.kfail
deleted file mode 100644
index d7feb3d..0000000
--- a/test/testcases/tests/level1/html/HTMLCollection12.xml.kfail
+++ /dev/null
@@ -1,50 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?xml-stylesheet href="test-to-html.xml" 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="HTMLCollection12">
-<metadata>
-<title>HTMLCollection12</title>
-<creator>NIST</creator>
-<description>
- The namedItem(name) method retrieves a node using a name. It first
- searches for a node with a matching id attribute. If it doesn't find
- one, it then searches for a Node with a matching name attribute, but only
- on those elements that are allowed a name attribute. If there isn't
- a matching node the method returns null.
-
- Retrieve the first FORM element and create a HTMLCollection by invoking
- the elements attribute. The method returns null since there is not a
- match of the name or id attribute.
-</description>
-<contributor>Rick Rivello</contributor>
-<date qualifier="created">2002-05-01</date>
-<subject resource="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-2106..."/>
-</metadata>
-<var name="nodeList" type="NodeList"/>
-<var name="testNode" type="Node"/>
-<var name="formNode" type="Node"/>
-<var name="formsnodeList" type="HTMLCollection"/>
-<var name="doc" type="Document"/>
-<load var="doc" href="collection" willBeModified="false"/>
-<getElementsByTagName interface="Document" obj="doc" var="nodeList" tagname='"form"'/>
-<assertSize collection="nodeList" size="1" id="Asize"/>
-<item interface="NodeList" obj="nodeList" var="testNode" index="0"/>
-<elements interface="HTMLFormElement" obj="testNode" var="formsnodeList"/>
-<namedItem obj="formsnodeList" var="formNode" name='"select9"'/>
-<assertNull actual="formNode" id="nameIndexLink" />
-</test>
--
Document Object Model library
9 years, 5 months