r3594 jshaw - in /trunk/dom/test/lib: testassert.c testassert.h
by netsurf@semichrome.net
Author: jshaw
Date: Wed Sep 26 21:56:25 2007
New Revision: 3594
URL: http://source.netsurf-browser.org?rev=3594&view=rev
Log:
Alter assert_equals signature, stub out assert_uri_equals
Modified:
trunk/dom/test/lib/testassert.c
trunk/dom/test/lib/testassert.h
Modified: trunk/dom/test/lib/testassert.c
URL: http://source.netsurf-browser.org/trunk/dom/test/lib/testassert.c?rev=359...
==============================================================================
--- trunk/dom/test/lib/testassert.c (original)
+++ trunk/dom/test/lib/testassert.c Wed Sep 26 21:56:25 2007
@@ -3,10 +3,13 @@
* Licensed under the MIT License,
* http://www.opensource.org/licenses/mit-license.php
* Copyright 2007 John-Mark Bell <jmb(a)netsurf-browser.org>
+ * Copyright 2007 James Shaw <jshaw(a)netsurf-browser.org>
*/
#include <stdio.h>
#include <stdlib.h>
+
+#include <dom/core/string.h>
#include "testassert.h"
#include "comparators.h"
@@ -26,19 +29,36 @@
void assert_equals_collection(struct list* expected, struct list* actual,
comparator comparator)
{
- assert_not_null(expected);
- assert_not_null(actual);
- assert_equals(expected->size, actual->size, (int (*)(const void* a, const void* b)) int_comparator);
+ assert(expected != NULL);
+ assert(actual != NULL);
+ assert_equals(&(expected->size), &(actual->size), (int (*)(const void* a, const void* b)) int_comparator);
list_contains_all(actual, expected, comparator);
}
-void assert_equals(int expected, int actual, comparator comparator)
+void assert_equals(void* expected, void* actual, comparator comparator)
{
- assert(comparator(&expected, &actual) == 0);
+ assert(comparator(expected, actual) == 0);
}
-void assert_not_null(void* x)
+void assert_same(void* expected, void* actual, comparator comparator)
{
- assert(x != NULL);
+ if (!(expected == actual)) {
+ assert_equals(expected, actual, comparator);
+ }
+}
+void assert_uri_equals(char* scheme, char* path, char* host, char* file,
+ char* name, char* query, char* fragment, bool isAbsolute,
+ char* actual)
+{
+ UNUSED(scheme);
+ UNUSED(path);
+ UNUSED(host);
+ UNUSED(file);
+ UNUSED(name);
+ UNUSED(query);
+ UNUSED(fragment);
+ UNUSED(isAbsolute);
+ UNUSED(actual);
+ /* TODO: implement me. Look at netsurf/url.c */
}
Modified: trunk/dom/test/lib/testassert.h
URL: http://source.netsurf-browser.org/trunk/dom/test/lib/testassert.h?rev=359...
==============================================================================
--- trunk/dom/test/lib/testassert.h (original)
+++ trunk/dom/test/lib/testassert.h Wed Sep 26 21:56:25 2007
@@ -22,9 +22,13 @@
void assert_equals_collection(struct list* expected, struct list* actual,
comparator comparator);
-void assert_equals(int expected, int actual, comparator comparator);
-void assert_not_null(void* x);
+void assert_equals(void* expected, void* actual, comparator comparator);
+
+void assert_same(void* expected, void* actual, comparator comparator);
+
+void assert_uri_equals(char* scheme, char* path, char* host, char* file,
+ char* name, char* query, char* fragment, bool isAbsolute,
+ char* actual);
#endif
-
15 years, 6 months
r3593 rjek - /trunk/netsurf/gtk/gtk_scaffolding.c
by netsurf@semichrome.net
Author: rjek
Date: Wed Sep 26 19:16:35 2007
New Revision: 3593
URL: http://source.netsurf-browser.org?rev=3593&view=rev
Log:
Attempt to fix popup menu strangeness in nsgtk experienced by some.
Modified:
trunk/netsurf/gtk/gtk_scaffolding.c
Modified: trunk/netsurf/gtk/gtk_scaffolding.c
URL: http://source.netsurf-browser.org/trunk/netsurf/gtk/gtk_scaffolding.c?rev...
==============================================================================
--- trunk/netsurf/gtk/gtk_scaffolding.c (original)
+++ trunk/netsurf/gtk/gtk_scaffolding.c Wed Sep 26 19:16:35 2007
@@ -914,5 +914,6 @@
void nsgtk_scaffolding_popup_menu(nsgtk_scaffolding *g, guint button)
{
- gtk_menu_popup(g->popup_menu, NULL, NULL, NULL, NULL, button, 0);
-}
+ gtk_menu_popup(g->popup_menu, NULL, NULL, NULL, NULL, 0,
+ gtk_get_current_event_time());
+}
15 years, 6 months
r3592 rjek - /trunk/netsurf/gtk/gtk_gui.c
by netsurf@semichrome.net
Author: rjek
Date: Wed Sep 26 19:07:32 2007
New Revision: 3592
URL: http://source.netsurf-browser.org?rev=3592&view=rev
Log:
nsgtk single and multiple select form widgets now work
Modified:
trunk/netsurf/gtk/gtk_gui.c
Modified: trunk/netsurf/gtk/gtk_gui.c
URL: http://source.netsurf-browser.org/trunk/netsurf/gtk/gtk_gui.c?rev=3592&r1...
==============================================================================
--- trunk/netsurf/gtk/gtk_gui.c (original)
+++ trunk/netsurf/gtk/gtk_gui.c Wed Sep 26 19:07:32 2007
@@ -77,11 +77,17 @@
GtkLabel *labelTooltip;
GtkDialog *wndOpenFile;
+static GtkWidget *select_menu;
+static struct browser_window *select_menu_bw;
+static struct form_control *select_menu_control;
+
static void nsgtk_create_ssl_verify_window(struct browser_window *bw,
struct content *c, const struct ssl_cert_info *certs,
unsigned long num);
static void nsgtk_ssl_accept(GtkButton *w, gpointer data);
static void nsgtk_ssl_reject(GtkButton *w, gpointer data);
+static void nsgtk_select_menu_clicked(GtkCheckMenuItem *checkmenuitem,
+ gpointer user_data);
/**
* Locate a shared resource file by searching known places in order.
@@ -392,6 +398,12 @@
{
}
+static void nsgtk_select_menu_clicked(GtkCheckMenuItem *checkmenuitem,
+ gpointer user_data)
+{
+ browser_window_form_select(select_menu_bw, select_menu_control,
+ (int)user_data);
+}
void gui_create_form_select_menu(struct browser_window *bw,
struct form_control *control)
@@ -399,13 +411,38 @@
int i;
struct form_option *option;
-
- LOG(("Trying to open select menu..."));
+
+ GtkWidget *menu_item;
+
+ /* control->data.select.multiple is true if multiple selections
+ * are allowable. We ignore this, as the core handles it for us.
+ * Yay. \o/
+ */
+
+ if (select_menu != NULL)
+ gtk_widget_destroy(select_menu);
+
+ select_menu = gtk_menu_new();
+ select_menu_bw = bw;
+ select_menu_control = control;
for (i = 0, option = control->data.select.items; option;
i++, option = option->next) {
- LOG(("Option: %s", option->text));
- }
+ menu_item = gtk_check_menu_item_new_with_label(option->text);
+ if (option->selected)
+ gtk_check_menu_item_set_active(
+ GTK_CHECK_MENU_ITEM(menu_item), TRUE);
+
+ g_signal_connect(menu_item, "toggled",
+ G_CALLBACK(nsgtk_select_menu_clicked), (gpointer)i);
+
+ gtk_menu_shell_append(GTK_MENU_SHELL(select_menu), menu_item);
+ }
+
+ gtk_widget_show_all(select_menu);
+
+ gtk_menu_popup(GTK_MENU(select_menu), NULL, NULL, NULL,
+ NULL /* data */, 0, gtk_get_current_event_time());
}
15 years, 6 months
r3591 jmb - in /trunk/dom/src/core: element.c element.h namednodemap.c
by netsurf@semichrome.net
Author: jmb
Date: Tue Sep 25 01:02:07 2007
New Revision: 3591
URL: http://source.netsurf-browser.org?rev=3591&view=rev
Log:
Add library-internal accessor to the head of an Element's attribute list (dom_element_get_first_attribute())
Implement dom_namednodemap_get_length()
Implement dom_namednodemap_get_named_item()
Implement dom_namednodemap_set_named_item()
Implement dom_namednodemap_remove_named_item()
Implement dom_namednodemap_item()
All dom_namednodemap_*() still require support for maps of Entity and Notation nodes to be added (this requires DocumentType to gain support for these nodes).
Modified:
trunk/dom/src/core/element.c
trunk/dom/src/core/element.h
trunk/dom/src/core/namednodemap.c
Modified: trunk/dom/src/core/element.c
URL: http://source.netsurf-browser.org/trunk/dom/src/core/element.c?rev=3591&r...
==============================================================================
--- trunk/dom/src/core/element.c (original)
+++ trunk/dom/src/core/element.c Tue Sep 25 01:02:07 2007
@@ -883,3 +883,14 @@
return DOM_NO_ERR;
}
+/**
+ * Retrieve a pointer to the first attribute attached to an element
+ *
+ * \param element The element to retrieve the first attribute from
+ * \return Pointer to first attribute, or NULL if none.
+ */
+struct dom_node *dom_element_get_first_attribute(struct dom_element *element)
+{
+ return (struct dom_node *) element->attributes;
+}
+
Modified: trunk/dom/src/core/element.h
URL: http://source.netsurf-browser.org/trunk/dom/src/core/element.h?rev=3591&r...
==============================================================================
--- trunk/dom/src/core/element.h (original)
+++ trunk/dom/src/core/element.h Tue Sep 25 01:02:07 2007
@@ -15,6 +15,7 @@
struct dom_document;
struct dom_element;
struct dom_namednodemap;
+struct dom_node;
struct dom_string;
dom_exception dom_element_create(struct dom_document *doc,
@@ -28,4 +29,7 @@
dom_exception dom_element_has_attributes(struct dom_element *element,
bool *result);
+
+struct dom_node *dom_element_get_first_attribute(struct dom_element *element);
+
#endif
Modified: trunk/dom/src/core/namednodemap.c
URL: http://source.netsurf-browser.org/trunk/dom/src/core/namednodemap.c?rev=3...
==============================================================================
--- trunk/dom/src/core/namednodemap.c (original)
+++ trunk/dom/src/core/namednodemap.c Tue Sep 25 01:02:07 2007
@@ -5,10 +5,14 @@
* Copyright 2007 John-Mark Bell <jmb(a)netsurf-browser.org>
*/
+#include <dom/core/element.h>
#include <dom/core/node.h>
+#include <dom/core/string.h>
#include "core/document.h"
+#include "core/element.h"
#include "core/namednodemap.h"
+#include "core/node.h"
#include "utils/utils.h"
@@ -118,10 +122,29 @@
dom_exception dom_namednodemap_get_length(struct dom_namednodemap *map,
unsigned long *length)
{
- UNUSED(map);
- UNUSED(length);
-
- return DOM_NOT_SUPPORTED_ERR;
+ struct dom_node *cur;
+ unsigned long len = 0;
+
+ switch (map->type) {
+ case DOM_ATTRIBUTE_NODE:
+ cur = dom_element_get_first_attribute(
+ (struct dom_element *) map->head);
+ break;
+ case DOM_NOTATION_NODE:
+ case DOM_ENTITY_NODE:
+ /** \todo handle notation and entity nodes */
+ default:
+ return DOM_NOT_SUPPORTED_ERR;
+ break;
+ }
+
+ for (; cur != NULL; cur = cur->next) {
+ len++;
+ }
+
+ *length = len;
+
+ return DOM_NO_ERR;
}
/**
@@ -138,11 +161,33 @@
dom_exception dom_namednodemap_get_named_item(struct dom_namednodemap *map,
struct dom_string *name, struct dom_node **node)
{
- UNUSED(map);
- UNUSED(name);
- UNUSED(node);
-
- return DOM_NOT_SUPPORTED_ERR;
+ struct dom_node *cur;
+
+ switch (map->type) {
+ case DOM_ATTRIBUTE_NODE:
+ cur = dom_element_get_first_attribute(
+ (struct dom_element *) map->head);
+ break;
+ case DOM_NOTATION_NODE:
+ case DOM_ENTITY_NODE:
+ /** \todo handle notation and entity nodes */
+ default:
+ return DOM_NOT_SUPPORTED_ERR;
+ break;
+ }
+
+ for (; cur != NULL; cur = cur->next) {
+ if (dom_string_cmp(cur->name, name) == 0) {
+ break;
+ }
+ }
+
+ if (cur != NULL) {
+ dom_node_ref(cur);
+ }
+ *node = cur;
+
+ return DOM_NO_ERR;
}
/**
@@ -172,11 +217,45 @@
dom_exception dom_namednodemap_set_named_item(struct dom_namednodemap *map,
struct dom_node *arg, struct dom_node **node)
{
- UNUSED(map);
- UNUSED(arg);
- UNUSED(node);
-
- return DOM_NOT_SUPPORTED_ERR;
+ dom_exception err;
+
+ /* Ensure arg and map belong to the same document */
+ if (arg->owner != map->owner)
+ return DOM_WRONG_DOCUMENT_ERR;
+
+ /* Ensure map is writable */
+ if (_dom_node_readonly(map->head))
+ return DOM_NO_MODIFICATION_ALLOWED_ERR;
+
+ /* Ensure arg isn't attached to another element */
+ if (arg->type == DOM_ATTRIBUTE_NODE && arg->parent != NULL &&
+ arg->parent != map->head)
+ return DOM_INUSE_ATTRIBUTE_ERR;
+
+ /* Ensure arg is permitted in the map */
+ if (arg->type != map->type)
+ return DOM_HIERARCHY_REQUEST_ERR;
+
+ /* Now delegate to the container-specific function.
+ * NamedNodeMaps are live, so this is fine. */
+ switch (map->type) {
+ case DOM_ATTRIBUTE_NODE:
+ err = dom_element_set_attribute_node(
+ (struct dom_element *) map->head,
+ (struct dom_attr *) arg,
+ (struct dom_attr **) node);
+ break;
+ case DOM_NOTATION_NODE:
+ case DOM_ENTITY_NODE:
+ /** \todo handle notation and entity nodes */
+ default:
+ err = DOM_NOT_SUPPORTED_ERR;
+ break;
+ }
+
+ /* Reference counting is handled by the container-specific call */
+
+ return err;
}
/**
@@ -197,11 +276,44 @@
struct dom_namednodemap *map, struct dom_string *name,
struct dom_node **node)
{
- UNUSED(map);
- UNUSED(name);
- UNUSED(node);
-
- return DOM_NOT_SUPPORTED_ERR;
+ dom_exception err;
+
+ /* Ensure map is writable */
+ if (_dom_node_readonly(map->head))
+ return DOM_NO_MODIFICATION_ALLOWED_ERR;
+
+ /* Now delegate to the container-specific function.
+ * NamedNodeMaps are live, so this is fine. */
+ switch (map->type) {
+ case DOM_ATTRIBUTE_NODE:
+ {
+ struct dom_attr *attr;
+
+ err = dom_element_get_attribute_node(
+ (struct dom_element *) map->head,
+ name, &attr);
+ if (err == DOM_NO_ERR) {
+ err = dom_element_remove_attribute_node(
+ (struct dom_element *) map->head,
+ attr, (struct dom_attr **) node);
+ if (err == DOM_NO_ERR) {
+ /* No longer want attr */
+ dom_node_unref((struct dom_node *) attr);
+ }
+ }
+ }
+ break;
+ case DOM_NOTATION_NODE:
+ case DOM_ENTITY_NODE:
+ /** \todo handle notation and entity nodes */
+ default:
+ err = DOM_NOT_SUPPORTED_ERR;
+ break;
+ }
+
+ /* Reference counting is handled by the container-specific call */
+
+ return err;
}
/**
@@ -221,11 +333,36 @@
dom_exception dom_namednodemap_item(struct dom_namednodemap *map,
unsigned long index, struct dom_node **node)
{
- UNUSED(map);
- UNUSED(index);
- UNUSED(node);
-
- return DOM_NOT_SUPPORTED_ERR;
+ struct dom_node *cur;
+ unsigned long count = 0;
+
+ switch (map->type) {
+ case DOM_ATTRIBUTE_NODE:
+ cur = dom_element_get_first_attribute(
+ (struct dom_element *) map->head);
+ break;
+ case DOM_NOTATION_NODE:
+ case DOM_ENTITY_NODE:
+ /** \todo handle notation and entity nodes */
+ default:
+ return DOM_NOT_SUPPORTED_ERR;
+ break;
+ }
+
+ for (; cur != NULL; cur = cur->next) {
+ count++;
+
+ if ((index + 1) == count) {
+ break;
+ }
+ }
+
+ if (cur != NULL) {
+ dom_node_ref(cur);
+ }
+ *node = cur;
+
+ return DOM_NO_ERR;
}
/**
15 years, 6 months
r3590 jmb - in /trunk/dom/src/core: element.c element.h node.c node.h
by netsurf@semichrome.net
Author: jmb
Date: Tue Sep 25 00:26:04 2007
New Revision: 3590
URL: http://source.netsurf-browser.org?rev=3590&view=rev
Log:
Move attributes field to struct dom_element as it doesn't apply to other node types.
Modified:
trunk/dom/src/core/element.c
trunk/dom/src/core/element.h
trunk/dom/src/core/node.c
trunk/dom/src/core/node.h
Modified: trunk/dom/src/core/element.c
URL: http://source.netsurf-browser.org/trunk/dom/src/core/element.c?rev=3590&r...
==============================================================================
--- trunk/dom/src/core/element.c (original)
+++ trunk/dom/src/core/element.c Tue Sep 25 00:26:04 2007
@@ -22,6 +22,8 @@
*/
struct dom_element {
struct dom_node base; /**< Base node */
+
+ struct dom_attr *attributes; /**< Element attributes */
struct dom_type_info *schema_type_info; /**< Type information */
};
@@ -62,6 +64,7 @@
}
/* Perform our type-specific initialisation */
+ el->attributes = NULL;
el->schema_type_info = NULL;
*result = el;
@@ -105,7 +108,7 @@
}
/* Destroy attributes attached to this node */
- for (c = (struct dom_node *) element->base.attributes;
+ for (c = (struct dom_node *) element->attributes;
c != NULL; c = d) {
d = c->next;
@@ -205,7 +208,7 @@
dom_exception dom_element_get_attribute(struct dom_element *element,
struct dom_string *name, struct dom_string **value)
{
- struct dom_node *a = (struct dom_node *) element->base.attributes;
+ struct dom_node *a = (struct dom_node *) element->attributes;
/* Search attributes, looking for name */
for (; a != NULL; a = a->next) {
@@ -237,7 +240,7 @@
struct dom_string *name, struct dom_string *value)
{
struct dom_node *e = (struct dom_node *) element;
- struct dom_node *a = (struct dom_node *) e->attributes;
+ struct dom_node *a = (struct dom_node *) element->attributes;
/** \todo validate name */
@@ -278,12 +281,12 @@
/* And insert it into the element */
a->previous = NULL;
- a->next = (struct dom_node *) e->attributes;
+ a->next = (struct dom_node *) element->attributes;
if (a->next != NULL)
a->next->previous = a;
- e->attributes = attr;
+ element->attributes = attr;
}
return DOM_NO_ERR;
@@ -301,7 +304,7 @@
struct dom_string *name)
{
struct dom_node *e = (struct dom_node *) element;
- struct dom_node *a = (struct dom_node *) e->attributes;
+ struct dom_node *a = (struct dom_node *) element->attributes;
/* Ensure element can be written to */
if (_dom_node_readonly(e))
@@ -318,7 +321,7 @@
if (a->previous != NULL)
a->previous->next = a->next;
else
- e->attributes = (struct dom_attr *) a->next;
+ element->attributes = (struct dom_attr *) a->next;
if (a->next != NULL)
a->next->previous = a->previous;
@@ -349,7 +352,7 @@
dom_exception dom_element_get_attribute_node(struct dom_element *element,
struct dom_string *name, struct dom_attr **result)
{
- struct dom_node *a = (struct dom_node *) element->base.attributes;
+ struct dom_node *a = (struct dom_node *) element->attributes;
/* Search attributes, looking for name */
for (; a != NULL; a = a->next) {
@@ -404,7 +407,7 @@
if (a->parent == NULL) {
/* Search for existing attribute with same name */
- prev = e->attributes;
+ prev = element->attributes;
while (prev != NULL) {
struct dom_node *p = (struct dom_node *) prev;
@@ -426,7 +429,7 @@
if (a->previous != NULL)
a->previous->next = a;
else
- e->attributes = attr;
+ element->attributes = attr;
if (a->next != NULL)
a->next->previous = a;
@@ -438,12 +441,12 @@
} else {
/* No existing attribute, so insert at front of list */
a->previous = NULL;
- a->next = (struct dom_node *) e->attributes;
+ a->next = (struct dom_node *) element->attributes;
if (a->next != NULL)
a->next->previous = a;
- e->attributes = attr;
+ element->attributes = attr;
}
}
@@ -488,7 +491,7 @@
if (a->previous != NULL)
a->previous->next = a->next;
else
- e->attributes = (struct dom_attr *) a->next;
+ element->attributes = (struct dom_attr *) a->next;
if (a->next != NULL)
a->next->previous = a->previous;
@@ -718,7 +721,7 @@
dom_exception dom_element_has_attribute(struct dom_element *element,
struct dom_string *name, bool *result)
{
- struct dom_node *a = (struct dom_node *) element->base.attributes;
+ struct dom_node *a = (struct dom_node *) element->attributes;
/* Search attributes, looking for name */
for (; a != NULL; a = a->next) {
@@ -843,3 +846,40 @@
return DOM_NOT_SUPPORTED_ERR;
}
+/* */
+/*----------------------------------------------------------------------------*/
+/* */
+
+/**
+ * Retrieve a map of attributes associated with an Element
+ *
+ * \param element The element to retrieve the attributes of
+ * \param result Pointer to location to receive attribute map
+ * \return DOM_NO_ERR.
+ *
+ * The returned NamedNodeMap will be referenced. It is the responsibility
+ * of the caller to unref the map once it has finished with it.
+ */
+dom_exception dom_element_get_attributes(struct dom_element *element,
+ struct dom_namednodemap **result)
+{
+ return dom_document_get_namednodemap(element->base.owner,
+ (struct dom_node *) element, DOM_ATTRIBUTE_NODE,
+ result);
+}
+
+/**
+ * Determine if an element has any attributes
+ *
+ * \param element Element to inspect
+ * \param result Pointer to location to receive result
+ * \return DOM_NO_ERR.
+ */
+dom_exception dom_element_has_attributes(struct dom_element *element,
+ bool *result)
+{
+ *result = (element->attributes != NULL);
+
+ return DOM_NO_ERR;
+}
+
Modified: trunk/dom/src/core/element.h
URL: http://source.netsurf-browser.org/trunk/dom/src/core/element.h?rev=3590&r...
==============================================================================
--- trunk/dom/src/core/element.h (original)
+++ trunk/dom/src/core/element.h Tue Sep 25 00:26:04 2007
@@ -8,10 +8,13 @@
#ifndef dom_internal_core_element_h_
#define dom_internal_core_element_h_
+#include <stdbool.h>
+
#include <dom/core/exceptions.h>
struct dom_document;
struct dom_element;
+struct dom_namednodemap;
struct dom_string;
dom_exception dom_element_create(struct dom_document *doc,
@@ -20,4 +23,9 @@
void dom_element_destroy(struct dom_document *doc,
struct dom_element *element);
+dom_exception dom_element_get_attributes(struct dom_element *element,
+ struct dom_namednodemap **result);
+
+dom_exception dom_element_has_attributes(struct dom_element *element,
+ bool *result);
#endif
Modified: trunk/dom/src/core/node.c
URL: http://source.netsurf-browser.org/trunk/dom/src/core/node.c?rev=3590&r1=3...
==============================================================================
--- trunk/dom/src/core/node.c (original)
+++ trunk/dom/src/core/node.c Tue Sep 25 00:26:04 2007
@@ -157,7 +157,6 @@
node->last_child = NULL;
node->previous = NULL;
node->next = NULL;
- node->attributes = NULL;
/* Note: nodes do not reference the document to which they belong,
* as this would result in the document never being destroyed once
@@ -232,7 +231,6 @@
node->owner = NULL;
/* Paranoia */
- node->attributes = NULL;
node->next = NULL;
node->previous = NULL;
node->last_child = NULL;
@@ -565,8 +563,7 @@
return DOM_NO_ERR;
}
- return dom_document_get_namednodemap(node->owner, node,
- DOM_ATTRIBUTE_NODE, result);
+ return dom_element_get_attributes((struct dom_element *) node, result);
}
/**
@@ -1105,9 +1102,13 @@
*/
dom_exception dom_node_has_attributes(struct dom_node *node, bool *result)
{
- *result = node->attributes != NULL;
-
- return DOM_NO_ERR;
+ if (node->type != DOM_ELEMENT_NODE) {
+ *result = false;
+
+ return DOM_NO_ERR;
+ }
+
+ return dom_element_has_attributes((struct dom_element *) node, result);
}
/**
Modified: trunk/dom/src/core/node.h
URL: http://source.netsurf-browser.org/trunk/dom/src/core/node.h?rev=3590&r1=3...
==============================================================================
--- trunk/dom/src/core/node.h (original)
+++ trunk/dom/src/core/node.h Tue Sep 25 00:26:04 2007
@@ -12,7 +12,6 @@
#include <dom/core/node.h>
-struct dom_attr;
struct dom_string;
/**
@@ -41,7 +40,6 @@
struct dom_node *last_child; /**< Last child node */
struct dom_node *previous; /**< Previous sibling */
struct dom_node *next; /**< Next sibling */
- struct dom_attr *attributes; /**< Node attributes */
struct dom_document *owner; /**< Owning document */
15 years, 6 months
r3589 jmb - /trunk/dom/src/core/nodelist.c
by netsurf@semichrome.net
Author: jmb
Date: Mon Sep 24 23:53:16 2007
New Revision: 3589
URL: http://source.netsurf-browser.org?rev=3589&view=rev
Log:
Implement dom_nodelist_get_length()
Implement dom_nodelist_item()
Modified:
trunk/dom/src/core/nodelist.c
Modified: trunk/dom/src/core/nodelist.c
URL: http://source.netsurf-browser.org/trunk/dom/src/core/nodelist.c?rev=3589&...
==============================================================================
--- trunk/dom/src/core/nodelist.c (original)
+++ trunk/dom/src/core/nodelist.c Mon Sep 24 23:53:16 2007
@@ -10,11 +10,10 @@
#include <dom/core/string.h>
#include "core/document.h"
+#include "core/node.h"
#include "core/nodelist.h"
#include "utils/utils.h"
-
-struct dom_node;
/**
* DOM node list
@@ -166,10 +165,58 @@
dom_exception dom_nodelist_get_length(struct dom_nodelist *list,
unsigned long *length)
{
- UNUSED(list);
- UNUSED(length);
-
- return DOM_NOT_SUPPORTED_ERR;
+ struct dom_node *cur = list->root->first_child;
+ unsigned long len = 0;
+
+ /* Traverse data structure */
+ while (cur != NULL) {
+ /* Process current node */
+ if (list->type == DOM_NODELIST_CHILDREN) {
+ len++;
+ } else if (list->type == DOM_NODELIST_BY_NAME) {
+ if (dom_string_cmp(cur->name, list->data.name) == 0) {
+ len++;
+ }
+ } else {
+ if (dom_string_cmp(cur->namespace,
+ list->data.ns.namespace) == 0 &&
+ dom_string_cmp(cur->localname,
+ list->data.ns.localname) == 0) {
+ len++;
+ }
+ }
+
+ /* Now, find next node */
+ if (list->type == DOM_NODELIST_CHILDREN) {
+ /* Just interested in sibling list */
+ cur = cur->next;
+ } else {
+ /* Want a full in-order tree traversal */
+ if (cur->first_child != NULL) {
+ /* Has children */
+ cur = cur->first_child;
+ } else if (cur->next != NULL) {
+ /* No children, but has siblings */
+ cur = cur->next;
+ } else {
+ /* No children or siblings.
+ * Find first unvisited relation. */
+ struct dom_node *parent = cur->parent;
+
+ while (parent != list->root &&
+ cur == parent->last_child) {
+ cur = parent;
+ parent = parent->parent;
+ }
+
+ cur = cur->next;
+ }
+ }
+ }
+
+ *length = len;
+
+ return DOM_NO_ERR;
}
/**
@@ -189,11 +236,66 @@
dom_exception dom_nodelist_item(struct dom_nodelist *list,
unsigned long index, struct dom_node **node)
{
- UNUSED(list);
- UNUSED(index);
- UNUSED(node);
-
- return DOM_NOT_SUPPORTED_ERR;
+ struct dom_node *cur = list->root->first_child;
+ unsigned long count = 0;
+
+ /* Traverse data structure */
+ while (cur != NULL) {
+ /* Process current node */
+ if (list->type == DOM_NODELIST_CHILDREN) {
+ count++;
+ } else if (list->type == DOM_NODELIST_BY_NAME) {
+ if (dom_string_cmp(cur->name, list->data.name) == 0) {
+ count++;
+ }
+ } else {
+ if (dom_string_cmp(cur->namespace,
+ list->data.ns.namespace) == 0 &&
+ dom_string_cmp(cur->localname,
+ list->data.ns.localname) == 0) {
+ count++;
+ }
+ }
+
+ /* Stop if this is the requested index */
+ if ((index + 1) == count) {
+ break;
+ }
+
+ /* Now, find next node */
+ if (list->type == DOM_NODELIST_CHILDREN) {
+ /* Just interested in sibling list */
+ cur = cur->next;
+ } else {
+ /* Want a full in-order tree traversal */
+ if (cur->first_child != NULL) {
+ /* Has children */
+ cur = cur->first_child;
+ } else if (cur->next != NULL) {
+ /* No children, but has siblings */
+ cur = cur->next;
+ } else {
+ /* No children or siblings.
+ * Find first unvisited relation. */
+ struct dom_node *parent = cur->parent;
+
+ while (parent != list->root &&
+ cur == parent->last_child) {
+ cur = parent;
+ parent = parent->parent;
+ }
+
+ cur = cur->next;
+ }
+ }
+ }
+
+ if (cur != NULL) {
+ dom_node_ref(cur);
+ }
+ *node = cur;
+
+ return DOM_NO_ERR;
}
/**
15 years, 6 months
r3588 jmb - in /trunk/dom/src/core: attr.c entity_ref.c entity_ref.h
by netsurf@semichrome.net
Author: jmb
Date: Sun Sep 23 23:54:22 2007
New Revision: 3588
URL: http://source.netsurf-browser.org?rev=3588&view=rev
Log:
Add dom_entity_reference_get_textual_representation() as an internal library function.
Implement dom_attr_get_value()
Modified:
trunk/dom/src/core/attr.c
trunk/dom/src/core/entity_ref.c
trunk/dom/src/core/entity_ref.h
Modified: trunk/dom/src/core/attr.c
URL: http://source.netsurf-browser.org/trunk/dom/src/core/attr.c?rev=3588&r1=3...
==============================================================================
--- trunk/dom/src/core/attr.c (original)
+++ trunk/dom/src/core/attr.c Sun Sep 23 23:54:22 2007
@@ -6,6 +6,7 @@
*/
#include <stddef.h>
+#include <string.h>
#include <dom/core/attr.h>
#include <dom/core/document.h>
@@ -13,6 +14,7 @@
#include "core/attr.h"
#include "core/document.h"
+#include "core/entity_ref.h"
#include "core/node.h"
#include "utils/utils.h"
@@ -176,12 +178,124 @@
dom_exception dom_attr_get_value(struct dom_attr *attr,
struct dom_string **result)
{
- UNUSED(attr);
- UNUSED(result);
+ struct dom_node *a = (struct dom_node *) attr;
+ struct dom_node *c;
+ uint8_t *rep;
+ size_t rep_len;
+ size_t rep_alloc;
+ dom_exception err;
+
+#define CHUNK 128
+
+ rep = dom_document_alloc(a->owner, NULL, CHUNK);
+ if (rep == NULL)
+ return DOM_NO_MEM_ERR;
+
+ rep_len = 0;
+ rep_alloc = CHUNK;
/* Traverse children, building a string representation as we go */
-
- return DOM_NOT_SUPPORTED_ERR;
+ for (c = a->first_child; c != NULL; c = c->next) {
+ if (c->type == DOM_TEXT_NODE && c->value != NULL) {
+ const uint8_t *data;
+ size_t len;
+
+ err = dom_string_get_data(c->value, &data, &len);
+ if (err != DOM_NO_ERR) {
+ dom_document_alloc(a->owner, rep, 0);
+ return err;
+ }
+
+ /* Extend buffer, if necessary */
+ if (rep_len + len >= rep_alloc) {
+ uint8_t *temp;
+ size_t required = (rep_len + len) - rep_alloc;
+
+ /* Round required up to a chunk boundary */
+ required =
+ (required + CHUNK - 1) & ~(CHUNK - 1);
+
+ temp = dom_document_alloc(a->owner, rep,
+ rep_alloc + required);
+ if (temp == NULL) {
+ dom_document_alloc(a->owner, rep, 0);
+ return DOM_NO_MEM_ERR;
+ }
+
+ rep = temp;
+ rep_alloc += required;
+ }
+
+ /* Copy text into buffer */
+ memcpy(rep + rep_len, data, len);
+
+ /* And fix up length information */
+ rep_len += len;
+ } else if (c->type == DOM_ENTITY_REFERENCE_NODE) {
+ struct dom_string *tr;
+ const uint8_t *data;
+ size_t len;
+
+ /* Get textual representation of entity */
+ err = dom_entity_reference_get_textual_representation(
+ (struct dom_entity_reference *) c,
+ &tr);
+ if (err != DOM_NO_ERR) {
+ dom_document_alloc(a->owner, rep, 0);
+ return err;
+ }
+
+ err = dom_string_get_data(tr, &data, &len);
+ if (err != DOM_NO_ERR) {
+ dom_string_unref(tr);
+ dom_document_alloc(a->owner, rep, 0);
+ return err;
+ }
+
+ /* Extend buffer, if necessary */
+ if (rep_len + len >= rep_alloc) {
+ uint8_t *temp;
+ size_t required = (rep_len + len) - rep_alloc;
+
+ /* Round required up to a chunk boundary */
+ required =
+ (required + CHUNK - 1) & ~(CHUNK - 1);
+
+ temp = dom_document_alloc(a->owner, rep,
+ rep_alloc + required);
+ if (temp == NULL) {
+ dom_document_alloc(a->owner, rep, 0);
+ return DOM_NO_MEM_ERR;
+ }
+
+ rep = temp;
+ rep_alloc += required;
+ }
+
+ /* Copy text into buffer */
+ memcpy(rep + rep_len, data, len);
+
+ /* And fix up length information */
+ rep_len += len;
+
+ /* No longer need textual representation */
+ dom_string_unref(tr);
+ }
+ }
+
+#undef CHUNK
+
+ /* Create DOMString */
+ err = dom_string_create_from_ptr(a->owner, rep, rep_len, result);
+ if (err != DOM_NO_ERR) {
+ dom_document_alloc(a->owner, rep, 0);
+ return err;
+ }
+
+ /* Cleanup */
+ dom_document_alloc(a->owner, rep, 0);
+
+ return DOM_NO_ERR;
}
/**
Modified: trunk/dom/src/core/entity_ref.c
URL: http://source.netsurf-browser.org/trunk/dom/src/core/entity_ref.c?rev=358...
==============================================================================
--- trunk/dom/src/core/entity_ref.c (original)
+++ trunk/dom/src/core/entity_ref.c Sun Sep 23 23:54:22 2007
@@ -8,6 +8,7 @@
#include "core/document.h"
#include "core/entity_ref.h"
#include "core/node.h"
+#include "utils/utils.h"
/**
* A DOM entity reference
@@ -97,3 +98,24 @@
/* Destroy fragment */
dom_document_alloc(doc, entity, 0);
}
+
+/**
+ * Get the textual representation of an EntityReference
+ *
+ * \param entity The entity reference to get the textual representation of
+ * \param result Pointer to location to receive result
+ * \return DOM_NO_ERR on success.
+ *
+ * The returned string will have its reference count increased. It is
+ * the responsibility of the caller to unref the string once it has
+ * finished with it.
+ */
+dom_exception dom_entity_reference_get_textual_representation(
+ struct dom_entity_reference *entity, struct dom_string **result)
+{
+ UNUSED(entity);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
Modified: trunk/dom/src/core/entity_ref.h
URL: http://source.netsurf-browser.org/trunk/dom/src/core/entity_ref.h?rev=358...
==============================================================================
--- trunk/dom/src/core/entity_ref.h (original)
+++ trunk/dom/src/core/entity_ref.h Sun Sep 23 23:54:22 2007
@@ -21,4 +21,7 @@
void dom_entity_reference_destroy(struct dom_document *doc,
struct dom_entity_reference *entity);
+dom_exception dom_entity_reference_get_textual_representation(
+ struct dom_entity_reference *entity,
+ struct dom_string **result);
#endif
15 years, 6 months
r3587 jmb - in /trunk/netsurftest/works: margin-background1.html margin-background2.html margin-background3.html
by netsurf@semichrome.net
Author: jmb
Date: Sun Sep 23 22:55:52 2007
New Revision: 3587
URL: http://source.netsurf-browser.org?rev=3587&view=rev
Log:
Testcases for handling of backgrounds on the <html> and <body> elements.
Added:
trunk/netsurftest/works/margin-background1.html
trunk/netsurftest/works/margin-background2.html
trunk/netsurftest/works/margin-background3.html
Added: trunk/netsurftest/works/margin-background1.html
URL: http://source.netsurf-browser.org/trunk/netsurftest/works/margin-backgrou...
==============================================================================
--- trunk/netsurftest/works/margin-background1.html (added)
+++ trunk/netsurftest/works/margin-background1.html Sun Sep 23 22:55:52 2007
@@ -1,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>Testcase for interaction between margins and background on body</title>
+<style type="text/css">
+/* Backgrounds on the body element are positioned as if they
+ * were specified on the root element _unless_ the root element
+ * already has its own background (i.e. in this case, the
+ * background image should be touching the left edge of the viewport)
+ */
+body {
+ margin-left: 136px;
+ background-image: url(../images/bg.gif);
+ background-repeat: repeat-y;
+ background-position: top left;
+}
+
+#foo {
+ margin-left: 136px;
+ width: 400px;
+ height: 400px;
+ background-color: green;
+ background-image: url(../images/bg.gif);
+ background-repeat: repeat-x;
+}
+</style>
+</head>
+<body>
+ <div id="foo"></div>
+</body>
+</html>
Added: trunk/netsurftest/works/margin-background2.html
URL: http://source.netsurf-browser.org/trunk/netsurftest/works/margin-backgrou...
==============================================================================
--- trunk/netsurftest/works/margin-background2.html (added)
+++ trunk/netsurftest/works/margin-background2.html Sun Sep 23 22:55:52 2007
@@ -1,0 +1,28 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>Testcase for interaction between margins and background on body</title>
+<style type="text/css">
+/* Test handling of background on html
+ * This should produce a background at the bottom-right of the document
+ */
+html {
+ background-image: url(../images/bg.gif);
+ background-position: bottom right;
+ background-repeat: no-repeat;
+}
+
+#foo {
+ margin-left: 136px;
+ width: 400px;
+ height: 400px;
+ background-color: green;
+ background-image: url(../images/bg.gif);
+ background-repeat: repeat-x;
+}
+</style>
+</head>
+<body>
+ <div id="foo"></div>
+</body>
+</html>
Added: trunk/netsurftest/works/margin-background3.html
URL: http://source.netsurf-browser.org/trunk/netsurftest/works/margin-backgrou...
==============================================================================
--- trunk/netsurftest/works/margin-background3.html (added)
+++ trunk/netsurftest/works/margin-background3.html Sun Sep 23 22:55:52 2007
@@ -1,0 +1,38 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>Testcase for interaction between margins and background on body</title>
+<style type="text/css">
+/* Backgrounds on the body element are positioned as if they
+ * were specified on the root element _unless_ the root element
+ * already has its own background (i.e. in this case, the
+ * background image should *not* be touching the left edge of the viewport)
+ */
+
+html {
+ background-image: url(../images/bg.gif);
+ background-position: bottom right;
+ background-repeat: no-repeat;
+}
+
+body {
+ margin-left: 136px;
+ background-image: url(../images/bg.gif);
+ background-repeat: repeat-y;
+ background-position: top left;
+}
+
+#foo {
+ margin-left: 136px;
+ width: 400px;
+ height: 400px;
+ background-color: green;
+ background-image: url(../images/bg.gif);
+ background-repeat: repeat-x;
+}
+</style>
+</head>
+<body>
+ <div id="foo"></div>
+</body>
+</html>
15 years, 6 months
r3586 tlsa - in /trunk/netsurftest: haveproblems/overflow-scrollbars.html images/iyonixi.png
by netsurf@semichrome.net
Author: tlsa
Date: Sun Sep 23 19:42:31 2007
New Revision: 3586
URL: http://source.netsurf-browser.org?rev=3586&view=rev
Log:
Test case for broken overflow scrollbar behaviour.
Added:
trunk/netsurftest/haveproblems/overflow-scrollbars.html
trunk/netsurftest/images/iyonixi.png (with props)
Added: trunk/netsurftest/haveproblems/overflow-scrollbars.html
URL: http://source.netsurf-browser.org/trunk/netsurftest/haveproblems/overflow...
==============================================================================
--- trunk/netsurftest/haveproblems/overflow-scrollbars.html (added)
+++ trunk/netsurftest/haveproblems/overflow-scrollbars.html Sun Sep 23 19:42:31 2007
@@ -1,0 +1,32 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
+ "http://www.w3.org/TR/html4/strict.dtd">
+<html>
+<head>
+<style>
+
+.themeimage {
+ padding-bottom: 0;
+ margin-bottom: 3mm;
+ overflow: auto; }
+
+.themeimage a img {
+ border: 1px solid #fff; }
+
+.themeimage a img:hover {
+ border: 1px solid #00f; }
+
+</style>
+</head>
+
+<body>
+
+<p style="background-color: #f88; padding:1em; margin: 1em;">Make the window too narrow for the following image and the scrollbar that appears obscures part of the image instead of being placed below the image.</p>
+
+<p class="themeimage"><img src="../images/Iyonixi.png" alt="Install theme"></p>
+
+<p style="background-color: #f88; padding:1em; margin: 1em;">The following image has a vertical scrollbar but it should not. It seems to be some borders issue.</p>
+
+<p class="themeimage"><a href="Iyonix"><img src="../images/Iyonixi.png" alt="Install theme"></a></p>
+
+</body>
+</html>
Added: trunk/netsurftest/images/iyonixi.png
URL: http://source.netsurf-browser.org/trunk/netsurftest/images/iyonixi.png?re...
==============================================================================
Binary file - no diff available.
Propchange: trunk/netsurftest/images/iyonixi.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
15 years, 6 months
r3585 tlsa - in /trunk/netsurftest: haveproblems/floats-inside-overflow-scroll.html haveproblems/inline-block-images.html images/1.jpg images/2.jpg images/3.jpg images/4.jpg images/5.jpg images/6.jpg
by netsurf@semichrome.net
Author: tlsa
Date: Sun Sep 23 18:57:28 2007
New Revision: 3585
URL: http://source.netsurf-browser.org?rev=3585&view=rev
Log:
Test case for float / overflow:scroll problem.
Added:
trunk/netsurftest/haveproblems/floats-inside-overflow-scroll.html
trunk/netsurftest/images/1.jpg (with props)
trunk/netsurftest/images/2.jpg (with props)
trunk/netsurftest/images/3.jpg (with props)
trunk/netsurftest/images/4.jpg (with props)
trunk/netsurftest/images/5.jpg (with props)
trunk/netsurftest/images/6.jpg (with props)
Modified:
trunk/netsurftest/haveproblems/inline-block-images.html
Added: trunk/netsurftest/haveproblems/floats-inside-overflow-scroll.html
URL: http://source.netsurf-browser.org/trunk/netsurftest/haveproblems/floats-i...
==============================================================================
--- trunk/netsurftest/haveproblems/floats-inside-overflow-scroll.html (added)
+++ trunk/netsurftest/haveproblems/floats-inside-overflow-scroll.html Sun Sep 23 18:57:28 2007
@@ -1,0 +1,44 @@
+<html>
+<head>
+<style>
+#scroller {
+ overflow: auto;
+ width: 200px;
+ height: 200px;
+ border:thin solid black; }
+
+#scroller p {
+ clear: both; }
+
+#scroller p img {
+ float: left; }
+</style>
+</head>
+<body>
+
+
+<p style="background-color: #f88; padding:1em; margin: 1em;">Floats within an overflow:scroll should not be visible outside the area of the box. Also, they should scroll with the non floated content.</p>
+
+
+ <div id="scroller">
+ <p><img src="../images/1.jpg">Blah blah blah blah blah blah blah
+ blah blah blah blah blah blah</p>
+
+ <p><img src="../images/2.jpg">Blah blah blah blah blah blah blah
+ blah blah blah blah blah blah</p>
+
+ <p><img src="../images/3.jpg">Blah blah blah blah blah blah blah
+ blah blah blah blah blah blah</p>
+
+ <p><img src="../images/4.jpg">Blah blah blah blah blah blah blah
+ blah blah blah blah blah blah</p>
+
+ <p><img src="../images/5.jpg">Blah blah blah blah blah blah blah
+ blah blah blah blah blah blah</p>
+
+ <p><img src="../images/6.jpg">Blah blah blah blah blah blah blah
+ blah blah blah blah blah blah</p>
+ </div>
+
+</body>
+</html>
Modified: trunk/netsurftest/haveproblems/inline-block-images.html
URL: http://source.netsurf-browser.org/trunk/netsurftest/haveproblems/inline-b...
==============================================================================
--- trunk/netsurftest/haveproblems/inline-block-images.html (original)
+++ trunk/netsurftest/haveproblems/inline-block-images.html Sun Sep 23 18:57:28 2007
@@ -7,7 +7,6 @@
<p style="background-color: #f88; padding:1em; margin: 1em;">There should be two pictures of trees above. In NetSurf images aren't shown inside inline-blocks unless the image has some alt text. Even if the image does have alt text, the image is squashed to the size of the alt text and not displayed 1:1 scale.</p>
-</div>
</body>
</html>
Added: trunk/netsurftest/images/1.jpg
URL: http://source.netsurf-browser.org/trunk/netsurftest/images/1.jpg?rev=3585...
==============================================================================
Binary file - no diff available.
Propchange: trunk/netsurftest/images/1.jpg
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: trunk/netsurftest/images/2.jpg
URL: http://source.netsurf-browser.org/trunk/netsurftest/images/2.jpg?rev=3585...
==============================================================================
Binary file - no diff available.
Propchange: trunk/netsurftest/images/2.jpg
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: trunk/netsurftest/images/3.jpg
URL: http://source.netsurf-browser.org/trunk/netsurftest/images/3.jpg?rev=3585...
==============================================================================
Binary file - no diff available.
Propchange: trunk/netsurftest/images/3.jpg
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: trunk/netsurftest/images/4.jpg
URL: http://source.netsurf-browser.org/trunk/netsurftest/images/4.jpg?rev=3585...
==============================================================================
Binary file - no diff available.
Propchange: trunk/netsurftest/images/4.jpg
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: trunk/netsurftest/images/5.jpg
URL: http://source.netsurf-browser.org/trunk/netsurftest/images/5.jpg?rev=3585...
==============================================================================
Binary file - no diff available.
Propchange: trunk/netsurftest/images/5.jpg
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: trunk/netsurftest/images/6.jpg
URL: http://source.netsurf-browser.org/trunk/netsurftest/images/6.jpg?rev=3585...
==============================================================================
Binary file - no diff available.
Propchange: trunk/netsurftest/images/6.jpg
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
15 years, 6 months