r12540 tlsa - /trunk/netsurf/cocoa/apple_image.m
by netsurf@semichrome.net
Author: tlsa
Date: Wed Jun 29 03:15:52 2011
New Revision: 12540
URL: http://source.netsurf-browser.org?rev=12540&view=rev
Log:
Fix up apple image content handler.
Modified:
trunk/netsurf/cocoa/apple_image.m
Modified: trunk/netsurf/cocoa/apple_image.m
URL: http://source.netsurf-browser.org/trunk/netsurf/cocoa/apple_image.m?rev=1...
==============================================================================
--- trunk/netsurf/cocoa/apple_image.m (original)
+++ trunk/netsurf/cocoa/apple_image.m Wed Jun 29 03:15:52 2011
@@ -41,10 +41,8 @@
bool quirks, struct content **c);
static bool apple_image_convert(struct content *c);
static void apple_image_destroy(struct content *c);
-static bool apple_image_redraw(struct content *c, int x, int y,
- int width, int height, const struct rect *clip,
- float scale, colour background_colour,
- bool repeat_x, bool repeat_y);
+static bool apple_image_redraw(struct content *c, struct content_redraw_data *data,
+ const struct rect *clip);
static nserror apple_image_clone(const struct content *old,
struct content **newc);
static content_type apple_image_content_type(lwc_string *mime_type);
@@ -245,21 +243,18 @@
* Redraw a CONTENT_APPLE_IMAGE with appropriate tiling.
*/
-bool apple_image_redraw(struct content *c, int x, int y,
- int width, int height, const struct rect *clip,
- float scale, colour background_colour,
- bool repeat_x, bool repeat_y)
+bool apple_image_redraw(struct content *c, struct content_redraw_data *data,
+ const struct rect *clip)
{
bitmap_flags_t flags = BITMAPF_NONE;
- if (repeat_x)
+ if (data->repeat_x)
flags |= BITMAPF_REPEAT_X;
- if (repeat_y)
+ if (data->repeat_y)
flags |= BITMAPF_REPEAT_Y;
- return plot.bitmap(x, y, width, height,
- c->bitmap, background_colour,
- flags);
+ return plot.bitmap(data->x, data->y, data->width, data->height,
+ c->bitmap, data->background_colour, flags);
}
#endif /* WITH_APPLE_IMAGE */
11 years, 11 months
r12539 jmb - in /branches/jmb/dom-alloc-purge/src/events: event.c event.h
by netsurf@semichrome.net
Author: jmb
Date: Tue Jun 28 18:44:33 2011
New Revision: 12539
URL: http://source.netsurf-browser.org?rev=12539&view=rev
Log:
Fix event module
Modified:
branches/jmb/dom-alloc-purge/src/events/event.c
branches/jmb/dom-alloc-purge/src/events/event.h
Modified: branches/jmb/dom-alloc-purge/src/events/event.c
URL: http://source.netsurf-browser.org/branches/jmb/dom-alloc-purge/src/events...
==============================================================================
--- branches/jmb/dom-alloc-purge/src/events/event.c (original)
+++ branches/jmb/dom-alloc-purge/src/events/event.c Tue Jun 28 18:44:33 2011
@@ -6,28 +6,26 @@
*/
#include <assert.h>
+#include <stdlib.h>
#include <time.h>
#include "events/event.h"
-
-#include <libwapcaplet/libwapcaplet.h>
#include "core/string.h"
#include "core/node.h"
#include "core/document.h"
#include "utils/utils.h"
-static void _virtual_dom_event_destroy(struct dom_event *evt);
+static void _virtual_dom_event_destroy(dom_event *evt);
static struct dom_event_private_vtable _event_vtable = {
_virtual_dom_event_destroy
};
/* Constructor */
-dom_exception _dom_event_create(struct dom_document *doc,
- struct dom_event **evt)
-{
- *evt = (dom_event *) _dom_document_alloc(doc, NULL, sizeof(dom_event));
+dom_exception _dom_event_create(dom_document *doc, dom_event **evt)
+{
+ *evt = (dom_event *) malloc(sizeof(dom_event));
if (*evt == NULL)
return DOM_NO_MEM_ERR;
@@ -37,16 +35,15 @@
}
/* Destructor */
-void _dom_event_destroy(struct dom_document *doc, struct dom_event *evt)
-{
- _dom_event_finalise(doc, evt);
-
- _dom_document_alloc(doc, evt, sizeof(dom_event));
+void _dom_event_destroy(dom_event *evt)
+{
+ _dom_event_finalise(evt);
+
+ free(evt);
}
/* Initialise function */
-dom_exception _dom_event_initialise(struct dom_document *doc,
- struct dom_event *evt)
+dom_exception _dom_event_initialise(dom_document *doc, dom_event *evt)
{
assert(doc != NULL);
@@ -67,14 +64,12 @@
}
/* Finalise function */
-void _dom_event_finalise(struct dom_document *doc, struct dom_event *evt)
-{
- UNUSED(doc);
-
+void _dom_event_finalise(dom_event *evt)
+{
if (evt->type != NULL)
- lwc_string_unref(evt->type);
+ dom_string_unref(evt->type);
if (evt->namespace != NULL)
- lwc_string_unref(evt->namespace);
+ dom_string_unref(evt->namespace);
evt->stop = false;
evt->stop_now = false;
@@ -89,9 +84,9 @@
}
/* The virtual destroy function */
-void _virtual_dom_event_destroy(struct dom_event *evt)
-{
- _dom_event_destroy(evt->doc, evt);
+void _virtual_dom_event_destroy(dom_event *evt)
+{
+ _dom_event_destroy(evt);
}
/*----------------------------------------------------------------------*/
@@ -131,12 +126,7 @@
*/
dom_exception _dom_event_get_type(dom_event *evt, dom_string **type)
{
- struct dom_document *doc = evt->doc;
- dom_exception err;
-
- err = _dom_document_create_string_from_lwcstring(doc, evt->type, type);
- if (err != DOM_NO_ERR)
- return err;
+ *type = dom_string_ref(evt->type);
return DOM_NO_ERR;
}
@@ -249,14 +239,8 @@
bool bubble, bool cancelable)
{
assert(evt->doc != NULL);
- lwc_string *str = NULL;
- dom_exception err;
-
- err = _dom_string_intern(type, &str);
- if (err != DOM_NO_ERR)
- return err;
-
- evt->type = str;
+
+ evt->type = dom_string_ref(type);
evt->bubble = bubble;
evt->cancelable = cancelable;
@@ -275,13 +259,7 @@
dom_exception _dom_event_get_namespace(dom_event *evt,
dom_string **namespace)
{
- struct dom_document *doc = evt->doc;
- dom_exception err;
-
- err = _dom_document_create_string_from_lwcstring(doc, evt->namespace,
- namespace);
- if (err != DOM_NO_ERR)
- return err;
+ *namespace = dom_string_ref(evt->namespace);
return DOM_NO_ERR;
}
@@ -341,18 +319,10 @@
dom_string *type, bool bubble, bool cancelable)
{
assert(evt->doc != NULL);
- lwc_string *str = NULL;
- dom_exception err;
-
- err = _dom_string_intern(type, &str);
- if (err != DOM_NO_ERR)
- return err;
- evt->type = str;
-
- err = _dom_string_intern(namespace, &str);
- if (err != DOM_NO_ERR)
- return err;
- evt->namespace = str;
+
+ evt->type = dom_string_ref(type);
+
+ evt->namespace = dom_string_ref(namespace);
evt->bubble = bubble;
evt->cancelable = cancelable;
Modified: branches/jmb/dom-alloc-purge/src/events/event.h
URL: http://source.netsurf-browser.org/branches/jmb/dom-alloc-purge/src/events...
==============================================================================
--- branches/jmb/dom-alloc-purge/src/events/event.h (original)
+++ branches/jmb/dom-alloc-purge/src/events/event.h Tue Jun 28 18:44:33 2011
@@ -10,13 +10,11 @@
#include <inttypes.h>
+#include <dom/core/document.h>
#include <dom/events/event_target.h>
#include <dom/events/event.h>
#include "utils/list.h"
-
-struct lwc_string_s;
-struct dom_document;
/* The private virtual table */
struct dom_event_private_vtable {
@@ -27,7 +25,7 @@
* The Event Ojbect
*/
struct dom_event {
- struct lwc_string_s *type; /**< The type of the event */
+ dom_string *type; /**< The type of the event */
dom_event_target *target; /**< The event target */
dom_event_target *current; /**< The current event target */
dom_event_flow_phase phase; /**< The event phase */
@@ -36,10 +34,9 @@
unsigned int timestamp;
/**< The timestamp this event is created */
- struct lwc_string_s *namespace;
- /**< The namespace of this event */
+ dom_string *namespace; /**< The namespace of this event */
- struct dom_document *doc;
+ dom_document *doc;
/**< The document which create this event */
bool stop; /**< Whether stopPropagation is called */
@@ -57,25 +54,23 @@
};
/* Constructor */
-dom_exception _dom_event_create(struct dom_document *doc,
- struct dom_event **evt);
+dom_exception _dom_event_create(dom_document *doc, dom_event **evt);
/* Destructor */
-void _dom_event_destroy(struct dom_document *doc, struct dom_event *evt);
+void _dom_event_destroy(dom_event *evt);
/* Initialise function */
-dom_exception _dom_event_initialise(struct dom_document *doc,
- struct dom_event *evt);
+dom_exception _dom_event_initialise(dom_document *doc, dom_event *evt);
/* Finalise function */
-void _dom_event_finalise(struct dom_document *doc, struct dom_event *evt);
+void _dom_event_finalise(dom_event *evt);
-static inline void dom_event_destroy(struct dom_event *evt)
+static inline void dom_event_destroy(dom_event *evt)
{
evt->vtable->destroy(evt);
}
-#define dom_event_destroy(e) dom_event_destroy((struct dom_event *) (e))
+#define dom_event_destroy(e) dom_event_destroy((dom_event *) (e))
#endif
11 years, 11 months
r12538 jmb - in /branches/jmb/dom-alloc-purge: bindings/hubbub/parser.c bindings/xml/xmlparser.c src/core/attr.c src/core/document.c src/core/document.h src/core/element.c
by netsurf@semichrome.net
Author: jmb
Date: Tue Jun 28 18:28:50 2011
New Revision: 12538
URL: http://source.netsurf-browser.org?rev=12538&view=rev
Log:
Fix Document
Modified:
branches/jmb/dom-alloc-purge/bindings/hubbub/parser.c
branches/jmb/dom-alloc-purge/bindings/xml/xmlparser.c
branches/jmb/dom-alloc-purge/src/core/attr.c
branches/jmb/dom-alloc-purge/src/core/document.c
branches/jmb/dom-alloc-purge/src/core/document.h
branches/jmb/dom-alloc-purge/src/core/element.c
Modified: branches/jmb/dom-alloc-purge/bindings/hubbub/parser.c
URL: http://source.netsurf-browser.org/branches/jmb/dom-alloc-purge/bindings/h...
==============================================================================
--- branches/jmb/dom-alloc-purge/bindings/hubbub/parser.c (original)
+++ branches/jmb/dom-alloc-purge/bindings/hubbub/parser.c Tue Jun 28 18:28:50 2011
@@ -228,9 +228,9 @@
*/
dom_hubbub_error dom_hubbub_parser_completed(dom_hubbub_parser *parser)
{
+ dom_exception derr;
hubbub_error err;
- lwc_string *name = NULL;
- lwc_error lerr;
+ dom_string *name = NULL;
err = hubbub_parser_completed(parser->parser);
if (err != HUBBUB_OK) {
@@ -241,12 +241,12 @@
parser->complete = true;
- lerr = lwc_intern_string("id", strlen("id"), &name);
- if (lerr != lwc_error_ok)
+ derr = dom_string_create((const uint8_t *) "id", SLEN("id"), &name);
+ if (derr != DOM_NO_ERR)
return HUBBUB_UNKNOWN;
_dom_document_set_id_name(parser->doc, name);
- lwc_string_unref(name);
+ dom_string_unref(name);
return DOM_HUBBUB_OK;
}
Modified: branches/jmb/dom-alloc-purge/bindings/xml/xmlparser.c
URL: http://source.netsurf-browser.org/branches/jmb/dom-alloc-purge/bindings/x...
==============================================================================
--- branches/jmb/dom-alloc-purge/bindings/xml/xmlparser.c (original)
+++ branches/jmb/dom-alloc-purge/bindings/xml/xmlparser.c Tue Jun 28 18:28:50 2011
@@ -265,8 +265,8 @@
dom_xml_error dom_xml_parser_completed(dom_xml_parser *parser)
{
xmlParserErrors err;
- lwc_string *name = NULL;
- lwc_error lerr;
+ dom_string *name = NULL;
+ dom_exception derr;
err = xmlParseChunk(parser->xml_ctx, "", 0, 1);
if (err != XML_ERR_OK) {
@@ -280,12 +280,12 @@
/* TODO: In future, this string "id" should be extracted from the
* document schema file instead of just setting it as "id".
*/
- lerr = lwc_intern_string("id", SLEN("id"), &name);
- if (lerr != lwc_error_ok)
- return _dom_exception_from_lwc_error(lerr);
+ derr = dom_string_create((const uint8_t *) "id", SLEN("id"), &name);
+ if (derr != DOM_NO_ERR)
+ return derr;
_dom_document_set_id_name(parser->doc, name);
- lwc_string_unref(name);
+ dom_string_unref(name);
return DOM_XML_OK;
}
@@ -648,9 +648,8 @@
dom_string *tag_name;
/* Create tag name DOM string */
- err = _dom_document_create_string(parser->doc,
- child->name, strlen((const char *) child->name),
- &tag_name);
+ err = dom_string_create(child->name,
+ strlen((const char *) child->name), &tag_name);
if (err != DOM_NO_ERR) {
parser->msg(DOM_MSG_CRITICAL, parser->mctx,
"No memory for tag name");
@@ -681,7 +680,7 @@
uint8_t qnamebuf[qnamelen + 1 /* '\0' */];
/* Create namespace DOM string */
- err = _dom_document_create_string(parser->doc,
+ err = dom_string_create(
child->ns->href,
strlen((const char *) child->ns->href),
&namespace);
@@ -700,7 +699,7 @@
(const char *) child->name);
/* Create qname DOM string */
- err = _dom_document_create_string(parser->doc,
+ err = dom_string_create(
qnamebuf,
qnamelen,
&qname);
@@ -739,7 +738,7 @@
dom_string *name;
/* Create attribute name DOM string */
- err = _dom_document_create_string(parser->doc,
+ err = dom_string_create(
a->name,
strlen((const char *) a->name),
&name);
@@ -773,7 +772,7 @@
uint8_t qnamebuf[qnamelen + 1 /* '\0' */];
/* Create namespace DOM string */
- err = _dom_document_create_string(parser->doc,
+ err = dom_string_create(
a->ns->href,
strlen((const char *) a->ns->href),
&namespace);
@@ -792,7 +791,7 @@
(const char *) a->name);
/* Create qname DOM string */
- err = _dom_document_create_string(parser->doc,
+ err = dom_string_create(
qnamebuf,
qnamelen,
&qname);
@@ -914,7 +913,7 @@
dom_exception err;
/* Create DOM string data for text node */
- err = _dom_document_create_string(parser->doc, child->content,
+ err = dom_string_create(child->content,
strlen((const char *) child->content), &data);
if (err != DOM_NO_ERR) {
parser->msg(DOM_MSG_CRITICAL, parser->mctx,
@@ -975,7 +974,7 @@
dom_exception err;
/* Create DOM string data for cdata section */
- err = _dom_document_create_string(parser->doc, child->content,
+ err = dom_string_create(child->content,
strlen((const char *) child->content), &data);
if (err != DOM_NO_ERR) {
parser->msg(DOM_MSG_CRITICAL, parser->mctx,
@@ -1037,7 +1036,7 @@
dom_exception err;
/* Create name of entity reference */
- err = _dom_document_create_string(parser->doc, child->name,
+ err = dom_string_create(child->name,
strlen((const char *) child->name), &name);
if (err != DOM_NO_ERR) {
parser->msg(DOM_MSG_CRITICAL, parser->mctx,
@@ -1112,7 +1111,7 @@
dom_exception err;
/* Create DOM string data for comment */
- err = _dom_document_create_string(parser->doc, child->content,
+ err = dom_string_create(child->content,
strlen((const char *) child->content), &data);
if (err != DOM_NO_ERR) {
parser->msg(DOM_MSG_CRITICAL, parser->mctx,
Modified: branches/jmb/dom-alloc-purge/src/core/attr.c
URL: http://source.netsurf-browser.org/branches/jmb/dom-alloc-purge/src/core/a...
==============================================================================
--- branches/jmb/dom-alloc-purge/src/core/attr.c (original)
+++ branches/jmb/dom-alloc-purge/src/core/attr.c Tue Jun 28 18:28:50 2011
@@ -435,8 +435,7 @@
dom_string *value, *temp;
dom_exception err;
- err = _dom_document_create_string(a->owner,
- NULL, 0, &value);
+ err = dom_string_create(NULL, 0, &value);
if (err != DOM_NO_ERR) {
return err;
}
Modified: branches/jmb/dom-alloc-purge/src/core/document.c
URL: http://source.netsurf-browser.org/branches/jmb/dom-alloc-purge/src/core/d...
==============================================================================
--- branches/jmb/dom-alloc-purge/src/core/document.c (original)
+++ branches/jmb/dom-alloc-purge/src/core/document.c Tue Jun 28 18:28:50 2011
@@ -7,8 +7,7 @@
*/
#include <assert.h>
-
-#include <libwapcaplet/libwapcaplet.h>
+#include <stdlib.h>
#include <dom/functypes.h>
#include <dom/core/attr.h>
@@ -36,7 +35,7 @@
* Item in list of active nodelists
*/
struct dom_doc_nl {
- struct dom_nodelist *list; /**< Nodelist */
+ dom_nodelist *list; /**< Nodelist */
struct dom_doc_nl *next; /**< Next item */
struct dom_doc_nl *prev; /**< Previous item */
@@ -59,7 +58,7 @@
/* Internally used helper functions */
static dom_exception dom_document_dup_node(dom_document *doc,
- struct dom_node *node, bool deep, struct dom_node **result,
+ dom_node *node, bool deep, dom_node **result,
dom_node_operation opt);
@@ -70,26 +69,20 @@
/**
* Create a Document
*
- * \param alloc Memory (de)allocation function
- * \param pw Pointer to client-specific private data
* \param doc Pointer to location to receive created document
* \param daf The default action fetcher
- * \param daf The default action fetcher
* \return DOM_NO_ERR on success, DOM_NO_MEM_ERR on memory exhaustion.
*
- * ::impl will have its reference count increased.
- *
* The returned document will already be referenced.
*/
-dom_exception _dom_document_create(dom_alloc alloc, void *pw,
- dom_events_default_action_fetcher daf,
- struct dom_document **doc)
-{
- struct dom_document *d;
+dom_exception _dom_document_create(dom_events_default_action_fetcher daf,
+ dom_document **doc)
+{
+ dom_document *d;
dom_exception err;
/* Create document */
- d = alloc(NULL, sizeof(struct dom_document), pw);
+ d = malloc(sizeof(dom_document));
if (d == NULL)
return DOM_NO_MEM_ERR;
@@ -102,10 +95,10 @@
* reaches zero. Documents own themselves (this simplifies the
* rest of the code, as it doesn't need to special case Documents)
*/
- err = _dom_document_initialise(d, alloc, pw, daf);
+ err = _dom_document_initialise(d, daf);
if (err != DOM_NO_ERR) {
/* Clean up document */
- alloc(d, 0, pw);
+ free(d);
return err;
}
@@ -115,29 +108,24 @@
}
/* Initialise the document */
-dom_exception _dom_document_initialise(struct dom_document *doc,
- dom_alloc alloc, void *pw,
+dom_exception _dom_document_initialise(dom_document *doc,
dom_events_default_action_fetcher daf)
{
dom_exception err;
- lwc_string *name;
- lwc_error lerr;
+ dom_string *name;
assert(alloc != NULL);
- lerr = lwc_intern_string("#document", SLEN("#document"), &name);
- if (lerr != lwc_error_ok)
- return _dom_exception_from_lwc_error(lerr);
+ err = dom_string_create((const uint8_t *) "#document",
+ SLEN("#document"), &name);
+ if (err != DOM_NO_ERR)
+ return err;
doc->nodelists = NULL;
-
- /* Set up document allocation context - must be first */
- doc->alloc = alloc;
- doc->pw = pw;
err = _dom_node_initialise(&doc->base, doc, DOM_DOCUMENT_NODE,
name, NULL, NULL, NULL);
- lwc_string_unref(name);
+ dom_string_unref(name);
list_init(&doc->pending_nodes);
@@ -149,10 +137,10 @@
/* Finalise the document */
-bool _dom_document_finalise(struct dom_document *doc)
+bool _dom_document_finalise(dom_document *doc)
{
/* Finalise base class, delete the tree in force */
- _dom_node_finalise(doc, &doc->base);
+ _dom_node_finalise(&doc->base);
/* Now, the first_child and last_child should be null */
doc->base.first_child = NULL;
@@ -174,11 +162,9 @@
doc->nodelists = NULL;
if (doc->id_name != NULL)
- lwc_string_unref(doc->id_name);
+ dom_string_unref(doc->id_name);
_dom_document_event_internal_finalise(doc, &doc->dei);
-
- _dom_document_event_internal_finalise(doc, &doc->dei);
return true;
}
@@ -200,10 +186,10 @@
* the responsibility of the caller to unref the node once it has
* finished with it.
*/
-dom_exception _dom_document_get_doctype(struct dom_document *doc,
- struct dom_document_type **result)
-{
- struct dom_node_internal *c;
+dom_exception _dom_document_get_doctype(dom_document *doc,
+ dom_document_type **result)
+{
+ dom_node_internal *c;
for (c = doc->base.first_child; c != NULL; c = c->next) {
if (c->type == DOM_DOCUMENT_TYPE_NODE)
@@ -213,7 +199,7 @@
if (c != NULL)
dom_node_ref(c);
- *result = (struct dom_document_type *) c;
+ *result = (dom_document_type *) c;
return DOM_NO_ERR;
}
@@ -229,7 +215,7 @@
* It is the responsibility of the caller to unref the implementation once
* it has finished with it.
*/
-dom_exception _dom_document_get_implementation(struct dom_document *doc,
+dom_exception _dom_document_get_implementation(dom_document *doc,
dom_implementation **result)
{
UNUSED(doc);
@@ -250,10 +236,10 @@
* the responsibility of the caller to unref the node once it has
* finished with it.
*/
-dom_exception _dom_document_get_document_element(struct dom_document *doc,
- struct dom_element **result)
-{
- struct dom_node_internal *root;
+dom_exception _dom_document_get_document_element(dom_document *doc,
+ dom_element **result)
+{
+ dom_node_internal *root;
/* Find the first element node in child list */
for (root = doc->base.first_child; root != NULL; root = root->next) {
@@ -264,7 +250,7 @@
if (root != NULL)
dom_node_ref(root);
- *result = (struct dom_element *) root;
+ *result = (dom_element *) root;
return DOM_NO_ERR;
}
@@ -284,50 +270,39 @@
* the responsibility of the caller to unref the node once it has
* finished with it.
*/
-dom_exception _dom_document_create_element(struct dom_document *doc,
- dom_string *tag_name, struct dom_element **result)
-{
- lwc_string *name;
- dom_exception err;
-
+dom_exception _dom_document_create_element(dom_document *doc,
+ dom_string *tag_name, dom_element **result)
+{
if (_dom_validate_name(tag_name) == false)
return DOM_INVALID_CHARACTER_ERR;
- err = _dom_string_intern(tag_name, &name);
+ return _dom_element_create(doc, tag_name, NULL, NULL, result);
+}
+
+/**
+ * Create a document fragment
+ *
+ * \param doc The document owning the fragment
+ * \param result Pointer to location to receive result
+ * \return DOM_NO_ERR.
+ *
+ * The returned node will have its reference count increased. It is
+ * the responsibility of the caller to unref the node once it has
+ * finished with it.
+ */
+dom_exception _dom_document_create_document_fragment(dom_document *doc,
+ dom_document_fragment **result)
+{
+ dom_string *name;
+ dom_exception err;
+
+ err = dom_string_create((const uint8_t *) "#document-fragment",
+ SLEN("#document-fragment"), &name);
if (err != DOM_NO_ERR)
return err;
- err = _dom_element_create(doc, name, NULL, NULL, result);
- lwc_string_unref(name);
-
- return err;
-}
-
-/**
- * Create a document fragment
- *
- * \param doc The document owning the fragment
- * \param result Pointer to location to receive result
- * \return DOM_NO_ERR.
- *
- * The returned node will have its reference count increased. It is
- * the responsibility of the caller to unref the node once it has
- * finished with it.
- */
-dom_exception _dom_document_create_document_fragment(struct dom_document *doc,
- struct dom_document_fragment **result)
-{
- lwc_string *name;
- dom_exception err;
- lwc_error lerr;
-
- lerr = lwc_intern_string("#document-fragment",
- SLEN("#document-fragment"), &name);
- if (lerr != lwc_error_ok)
- return _dom_exception_from_lwc_error(lerr);
-
err = _dom_document_fragment_create(doc, name, NULL, result);
- lwc_string_unref(name);
+ dom_string_unref(name);
return err;
}
@@ -344,19 +319,19 @@
* the responsibility of the caller to unref the node once it has
* finished with it.
*/
-dom_exception _dom_document_create_text_node(struct dom_document *doc,
- dom_string *data, struct dom_text **result)
-{
- lwc_string *name;
+dom_exception _dom_document_create_text_node(dom_document *doc,
+ dom_string *data, dom_text **result)
+{
+ dom_string *name;
dom_exception err;
- lwc_error lerr;
-
- lerr = lwc_intern_string("#text", SLEN("#text"), &name);
- if (lerr != lwc_error_ok)
- return _dom_exception_from_lwc_error(lerr);
+
+ err = dom_string_create((const uint8_t *) "#text",
+ SLEN("#text"), &name);
+ if (err != DOM_NO_ERR)
+ return err;
err = _dom_text_create(doc, name, data, result);
- lwc_string_unref(name);
+ dom_string_unref(name);
return err;
}
@@ -373,20 +348,19 @@
* the responsibility of the caller to unref the node once it has
* finished with it.
*/
-dom_exception _dom_document_create_comment(struct dom_document *doc,
- dom_string *data, struct dom_comment **result)
-{
- lwc_string *name;
+dom_exception _dom_document_create_comment(dom_document *doc,
+ dom_string *data, dom_comment **result)
+{
+ dom_string *name;
dom_exception err;
- lwc_error lerr;
-
- lerr = lwc_intern_string("#comment", SLEN("#comment"),
+
+ err = dom_string_create((const uint8_t *) "#comment", SLEN("#comment"),
&name);
- if (lerr != lwc_error_ok)
- return _dom_exception_from_lwc_error(lerr);
+ if (err != DOM_NO_ERR)
+ return err;
err = _dom_comment_create(doc, name, data, result);
- lwc_string_unref(name);
+ dom_string_unref(name);
return err;
}
@@ -404,20 +378,19 @@
* the responsibility of the caller to unref the node once it has
* finished with it.
*/
-dom_exception _dom_document_create_cdata_section(struct dom_document *doc,
- dom_string *data, struct dom_cdata_section **result)
-{
- lwc_string *name;
+dom_exception _dom_document_create_cdata_section(dom_document *doc,
+ dom_string *data, dom_cdata_section **result)
+{
+ dom_string *name;
dom_exception err;
- lwc_error lerr;
-
- lerr = lwc_intern_string("#cdata-section",
+
+ err = dom_string_create((const uint8_t *) "#cdata-section",
SLEN("#cdata-section"), &name);
- if (lerr != lwc_error_ok)
- return _dom_exception_from_lwc_error(lerr);
+ if (err != DOM_NO_ERR)
+ return err;
err = _dom_cdata_section_create(doc, name, data, result);
- lwc_string_unref(name);
+ dom_string_unref(name);
return err;
}
@@ -438,24 +411,14 @@
* finished with it.
*/
dom_exception _dom_document_create_processing_instruction(
- struct dom_document *doc, dom_string *target,
+ dom_document *doc, dom_string *target,
dom_string *data,
- struct dom_processing_instruction **result)
-{
- lwc_string *name;
- dom_exception err;
-
+ dom_processing_instruction **result)
+{
if (_dom_validate_name(target) == false)
return DOM_INVALID_CHARACTER_ERR;
- err = _dom_string_intern(target, &name);
- if (err != DOM_NO_ERR)
- return err;
-
- err = _dom_processing_instruction_create(doc, name, data, result);
- lwc_string_unref(name);
-
- return err;
+ return _dom_processing_instruction_create(doc, target, data, result);
}
/**
@@ -471,22 +434,13 @@
* the responsibility of the caller to unref the node once it has
* finished with it.
*/
-dom_exception _dom_document_create_attribute(struct dom_document *doc,
- dom_string *name, struct dom_attr **result)
-{
- lwc_string *n;
- dom_exception err;
-
+dom_exception _dom_document_create_attribute(dom_document *doc,
+ dom_string *name, dom_attr **result)
+{
if (_dom_validate_name(name) == false)
return DOM_INVALID_CHARACTER_ERR;
- err = _dom_string_intern(name, &n);
- if (err != DOM_NO_ERR)
- return err;
-
- err = _dom_attr_create(doc, n, NULL, NULL, true, result);
- lwc_string_unref(n);
- return err;
+ return _dom_attr_create(doc, name, NULL, NULL, true, result);
}
/**
@@ -503,23 +457,14 @@
* the responsibility of the caller to unref the node once it has
* finished with it.
*/
-dom_exception _dom_document_create_entity_reference(struct dom_document *doc,
+dom_exception _dom_document_create_entity_reference(dom_document *doc,
dom_string *name,
- struct dom_entity_reference **result)
-{
- lwc_string *n;
- dom_exception err;
-
+ dom_entity_reference **result)
+{
if (_dom_validate_name(name) == false)
return DOM_INVALID_CHARACTER_ERR;
- err = _dom_string_intern(name, &n);
- if (err != DOM_NO_ERR)
- return err;
-
- err = _dom_entity_reference_create(doc, n, NULL, result);
- lwc_string_unref(n);
- return err;
+ return _dom_entity_reference_create(doc, name, NULL, result);
}
/**
@@ -534,22 +479,12 @@
* the responsibility of the caller to unref the list once it has
* finished with it.
*/
-dom_exception _dom_document_get_elements_by_tag_name(struct dom_document *doc,
- dom_string *tagname, struct dom_nodelist **result)
-{
- lwc_string *name;
- dom_exception err;
-
- err = _dom_string_intern(tagname, &name);
- if (err != DOM_NO_ERR)
- return err;
-
- err = _dom_document_get_nodelist(doc, DOM_NODELIST_BY_NAME,
- (struct dom_node_internal *) doc, name, NULL, NULL,
+dom_exception _dom_document_get_elements_by_tag_name(dom_document *doc,
+ dom_string *tagname, dom_nodelist **result)
+{
+ return _dom_document_get_nodelist(doc, DOM_NODELIST_BY_NAME,
+ (dom_node_internal *) doc, tagname, NULL, NULL,
result);
- lwc_string_unref(name);
-
- return err;
}
/**
@@ -567,8 +502,8 @@
* the responsibility of the caller to unref the node once it has
* finished with it.
*/
-dom_exception _dom_document_import_node(struct dom_document *doc,
- struct dom_node *node, bool deep, struct dom_node **result)
+dom_exception _dom_document_import_node(dom_document *doc,
+ dom_node *node, bool deep, dom_node **result)
{
/* TODO: The DOM_INVALID_CHARACTER_ERR exception */
@@ -604,9 +539,9 @@
* the responsibility of the caller to unref the node once it has
* finished with it.
*/
-dom_exception _dom_document_create_element_ns(struct dom_document *doc,
+dom_exception _dom_document_create_element_ns(dom_document *doc,
dom_string *namespace, dom_string *qname,
- struct dom_element **result)
+ dom_element **result)
{
dom_string *prefix, *localname;
dom_exception err;
@@ -626,56 +561,16 @@
return err;
}
- /* Get the interned string from the dom_string */
- lwc_string *l = NULL, *n = NULL, *p = NULL;
- if (localname != NULL) {
- err = _dom_string_intern(localname, &l);
- if (err != DOM_NO_ERR) {
- dom_string_unref(localname);
- if (prefix != NULL)
- dom_string_unref(prefix);
-
- return err;
- }
- }
- if (namespace != NULL) {
- err = _dom_string_intern(namespace, &n);
- if (err != DOM_NO_ERR) {
- lwc_string_unref(l);
- dom_string_unref(localname);
- if (prefix != NULL)
- dom_string_unref(prefix);
-
- return err;
- }
- }
- if (prefix != NULL) {
- err = _dom_string_intern(prefix, &p);
- if (err != DOM_NO_ERR) {
- lwc_string_unref(l);
- lwc_string_unref(n);
- dom_string_unref(localname);
- if (prefix != NULL)
- dom_string_unref(prefix);
-
- return err;
- }
- }
-
/* Attempt to create element */
- err = _dom_element_create(doc, l, n, p, result);
+ err = _dom_element_create(doc, localname, namespace, prefix, result);
/* Tidy up */
if (localname != NULL) {
dom_string_unref(localname);
- lwc_string_unref(l);
- }
+ }
+
if (prefix != NULL) {
dom_string_unref(prefix);
- lwc_string_unref(p);
- }
- if (namespace != NULL) {
- lwc_string_unref(n);
}
return err;
@@ -709,9 +604,9 @@
* the responsibility of the caller to unref the node once it has
* finished with it.
*/
-dom_exception _dom_document_create_attribute_ns(struct dom_document *doc,
+dom_exception _dom_document_create_attribute_ns(dom_document *doc,
dom_string *namespace, dom_string *qname,
- struct dom_attr **result)
+ dom_attr **result)
{
dom_string *prefix, *localname;
dom_exception err;
@@ -731,55 +626,16 @@
return err;
}
- /* Get the interned string from the dom_string */
- lwc_string *l = NULL, *n = NULL, *p = NULL;
- if (localname != NULL) {
- err = _dom_string_intern(localname, &l);
- if (err != DOM_NO_ERR) {
- dom_string_unref(localname);
- if (prefix != NULL)
- dom_string_unref(prefix);
-
- return err;
- }
- }
- if (namespace != NULL) {
- err = _dom_string_intern(namespace, &n);
- if (err != DOM_NO_ERR) {
- lwc_string_unref(l);
- dom_string_unref(localname);
- if (prefix != NULL)
- dom_string_unref(prefix);
-
- return err;
- }
- }
- if (prefix != NULL) {
- err = _dom_string_intern(prefix, &p);
- if (err != DOM_NO_ERR) {
- lwc_string_unref(l);
- lwc_string_unref(n);
- dom_string_unref(localname);
- if (prefix != NULL)
- dom_string_unref(prefix);
-
- return err;
- }
- }
/* Attempt to create attribute */
- err = _dom_attr_create(doc, l, n, p, true, result);
+ err = _dom_attr_create(doc, localname, namespace, prefix, true, result);
/* Tidy up */
if (localname != NULL) {
dom_string_unref(localname);
- lwc_string_unref(l);
- }
+ }
+
if (prefix != NULL) {
dom_string_unref(prefix);
- lwc_string_unref(p);
- }
- if (namespace != NULL) {
- lwc_string_unref(n);
}
return err;
@@ -799,35 +655,12 @@
* finished with it.
*/
dom_exception _dom_document_get_elements_by_tag_name_ns(
- struct dom_document *doc, dom_string *namespace,
- dom_string *localname, struct dom_nodelist **result)
-{
- dom_exception err;
- lwc_string *l = NULL, *n = NULL;
-
- /* Get the interned string from the dom_string */
- if (localname != NULL) {
- err = _dom_string_intern(localname, &l);
- if (err != DOM_NO_ERR)
- return err;
- }
- if (namespace != NULL) {
- err = _dom_string_intern(namespace, &n);
- if (err != DOM_NO_ERR) {
- lwc_string_unref(l);
- return err;
- }
- }
-
- err = _dom_document_get_nodelist(doc, DOM_NODELIST_BY_NAMESPACE,
- (struct dom_node_internal *) doc, NULL, n, l, result);
-
- if (l != NULL)
- lwc_string_unref(l);
- if (n != NULL)
- lwc_string_unref(n);
-
- return err;
+ dom_document *doc, dom_string *namespace,
+ dom_string *localname, dom_nodelist **result)
+{
+ return _dom_document_get_nodelist(doc, DOM_NODELIST_BY_NAMESPACE,
+ (dom_node_internal *) doc, NULL, namespace, localname,
+ result);
}
/**
@@ -842,24 +675,19 @@
* the responsibility of the caller to unref the node once it has
* finished with it.
*/
-dom_exception _dom_document_get_element_by_id(struct dom_document *doc,
- dom_string *id, struct dom_element **result)
-{
- lwc_string *i;
+dom_exception _dom_document_get_element_by_id(dom_document *doc,
+ dom_string *id, dom_element **result)
+{
dom_node_internal *root;
dom_exception err;
*result = NULL;
- err = _dom_string_intern(id, &i);
- if (err != DOM_NO_ERR)
- return err;
-
err = dom_document_get_document_element(doc, (void *) &root);
if (err != DOM_NO_ERR)
return err;
- err = _dom_find_element_by_id(root, i, result);
+ err = _dom_find_element_by_id(root, id, result);
dom_node_unref(root);
return err;
@@ -876,7 +704,7 @@
* the responsibility of the caller to unref the string once it has
* finished with it.
*/
-dom_exception _dom_document_get_input_encoding(struct dom_document *doc,
+dom_exception _dom_document_get_input_encoding(dom_document *doc,
dom_string **result)
{
UNUSED(doc);
@@ -896,7 +724,7 @@
* the responsibility of the caller to unref the string once it has
* finished with it.
*/
-dom_exception _dom_document_get_xml_encoding(struct dom_document *doc,
+dom_exception _dom_document_get_xml_encoding(dom_document *doc,
dom_string **result)
{
UNUSED(doc);
@@ -912,7 +740,7 @@
* \param result Pointer to location to receive result
* \return DOM_NOT_SUPPORTED_ERR, we don't support this API now.
*/
-dom_exception _dom_document_get_xml_standalone(struct dom_document *doc,
+dom_exception _dom_document_get_xml_standalone(dom_document *doc,
bool *result)
{
UNUSED(doc);
@@ -933,7 +761,7 @@
* We don't support this API now, so the return value is always
* DOM_NOT_SUPPORTED_ERR.
*/
-dom_exception _dom_document_set_xml_standalone(struct dom_document *doc,
+dom_exception _dom_document_set_xml_standalone(dom_document *doc,
bool standalone)
{
UNUSED(doc);
@@ -956,7 +784,7 @@
* We don't support this API now, so the return value is always
* DOM_NOT_SUPPORTED_ERR.
*/
-dom_exception _dom_document_get_xml_version(struct dom_document *doc,
+dom_exception _dom_document_get_xml_version(dom_document *doc,
dom_string **result)
{
UNUSED(doc);
@@ -977,7 +805,7 @@
* We don't support this API now, so the return value is always
* DOM_NOT_SUPPORTED_ERR.
*/
-dom_exception _dom_document_set_xml_version(struct dom_document *doc,
+dom_exception _dom_document_set_xml_version(dom_document *doc,
dom_string *version)
{
UNUSED(doc);
@@ -994,7 +822,7 @@
* \return DOM_NOT_SUPPORTED_ERR, we don't support this API now.
*/
dom_exception _dom_document_get_strict_error_checking(
- struct dom_document *doc, bool *result)
+ dom_document *doc, bool *result)
{
UNUSED(doc);
UNUSED(result);
@@ -1010,7 +838,7 @@
* \return DOM_NOT_SUPPORTED_ERR, we don't support this API now.
*/
dom_exception _dom_document_set_strict_error_checking(
- struct dom_document *doc, bool strict)
+ dom_document *doc, bool strict)
{
UNUSED(doc);
UNUSED(strict);
@@ -1029,11 +857,10 @@
* the responsibility of the caller to unref the string once it has
* finished with it.
*/
-dom_exception _dom_document_get_uri(struct dom_document *doc,
+dom_exception _dom_document_get_uri(dom_document *doc,
dom_string **result)
{
- dom_string_ref(doc->uri);
- *result = doc->uri;
+ *result = dom_string_ref(doc->uri);
return DOM_NO_ERR;
}
@@ -1049,12 +876,12 @@
* the responsibility of the caller to unref the string once it has
* finished with it.
*/
-dom_exception _dom_document_set_uri(struct dom_document *doc,
+dom_exception _dom_document_set_uri(dom_document *doc,
dom_string *uri)
{
dom_string_unref(doc->uri);
- dom_string_ref(uri);
- doc->uri = uri;
+
+ doc->uri = dom_string_ref(uri);
return DOM_NO_ERR;
}
@@ -1081,11 +908,11 @@
* generally, the adoptNode and importNode call the same function
* dom_document_dup_node.
*/
-dom_exception _dom_document_adopt_node(struct dom_document *doc,
- struct dom_node *node, struct dom_node **result)
-{
+dom_exception _dom_document_adopt_node(dom_document *doc,
+ dom_node *node, dom_node **result)
+{
+ dom_node_internal *n = (dom_node_internal *) node;
dom_exception err;
- dom_node_internal *n = (dom_node_internal *) node;
*result = NULL;
@@ -1142,7 +969,7 @@
* the responsibility of the caller to unref the object once it has
* finished with it.
*/
-dom_exception _dom_document_get_dom_config(struct dom_document *doc,
+dom_exception _dom_document_get_dom_config(dom_document *doc,
struct dom_configuration **result)
{
UNUSED(doc);
@@ -1157,7 +984,7 @@
* \param doc The document to normalize
* \return DOM_NOT_SUPPORTED_ERR, we don't support this API now.
*/
-dom_exception _dom_document_normalize(struct dom_document *doc)
+dom_exception _dom_document_normalize(dom_document *doc)
{
UNUSED(doc);
@@ -1198,10 +1025,10 @@
* We don't support this API now, so the return value is always
* DOM_NOT_SUPPORTED_ERR.
*/
-dom_exception _dom_document_rename_node(struct dom_document *doc,
- struct dom_node *node,
+dom_exception _dom_document_rename_node(dom_document *doc,
+ dom_node *node,
dom_string *namespace, dom_string *qname,
- struct dom_node **result)
+ dom_node **result)
{
UNUSED(doc);
UNUSED(node);
@@ -1217,38 +1044,21 @@
/* Overload protectd virtual functions */
/* The virtual destroy function of this class */
-void _dom_document_destroy(struct dom_node_internal *node)
-{
- struct dom_document *doc = (struct dom_document *) node;
+void _dom_document_destroy(dom_node_internal *node)
+{
+ dom_document *doc = (dom_document *) node;
if (_dom_document_finalise(doc) == true) {
- doc->alloc(doc, 0, doc->pw);
- }
-}
-
-/* The memory allocation function of this class */
-dom_exception __dom_document_alloc(struct dom_document *doc,
- struct dom_node_internal *n, struct dom_node_internal **ret)
-{
- UNUSED(n);
- struct dom_document *a;
-
- a = _dom_document_alloc(doc, NULL, sizeof(struct dom_document));
- if (a == NULL)
- return DOM_NO_MEM_ERR;
-
- *ret = (dom_node_internal *) a;
- dom_node_set_owner(*ret, doc);
-
- return DOM_NO_ERR;
+ free(doc);
+ }
}
/* The copy constructor function of this class */
-dom_exception _dom_document_copy(struct dom_node_internal *new,
- struct dom_node_internal *old)
-{
- UNUSED(new);
+dom_exception _dom_document_copy(dom_node_internal *old,
+ dom_node_internal **copy)
+{
UNUSED(old);
+ UNUSED(copy);
return DOM_NOT_SUPPORTED_ERR;
}
@@ -1257,125 +1067,6 @@
/* ----------------------------------------------------------------------- */
/* Helper functions */
-/**
- * Create a DOM string, using a document's allocation context
- *
- * \param doc The document
- * \param data Pointer to string data
- * \param len Length, in bytes, of string
- * \param result Pointer to location to receive result
- * \return DOM_NO_ERR on success, DOM_NO_MEM_ERR on memory exhaustion
- *
- * The returned string will already be referenced, so there is no need
- * to explicitly reference it.
- *
- * The string of characters passed in will be copied for use by the
- * returned DOM string.
- */
-dom_exception _dom_document_create_string(struct dom_document *doc,
- const uint8_t *data, size_t len, dom_string **result)
-{
- return dom_string_create(doc->alloc, doc->pw, data, len, result);
-}
-
-/**
- * Create a lwc_string
- *
- * \param doc The document object
- * \param data The raw string data
- * \param len The raw string length
- * \param result The resturned lwc_string
- * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
- */
-dom_exception _dom_document_create_lwcstring(struct dom_document *doc,
- const uint8_t *data, size_t len, struct lwc_string_s **result)
-{
- lwc_error lerr;
-
- UNUSED(doc);
-
- lerr = lwc_intern_string((const char *) data, len, result);
-
- return _dom_exception_from_lwc_error(lerr);
-}
-
-/* Unref a lwc_string created by this document */
-void _dom_document_unref_lwcstring(struct dom_document *doc,
- struct lwc_string_s *str)
-{
- UNUSED(doc);
-
- lwc_string_unref(str);
-}
-
-/* Get the resource manager from the document */
-void _dom_document_get_resource_mgr(
- struct dom_document *doc, struct dom_resource_mgr *rm)
-{
- rm->alloc = doc->alloc;
- rm->pw = doc->pw;
-}
-
-/* Simple accessor for allocator data for this document */
-void _dom_document_get_allocator(struct dom_document *doc, dom_alloc *al,
- void **pw)
-{
- *al = doc->alloc;
- *pw = doc->pw;
-}
-/*
- * Create a dom_string from a lwc_string.
- *
- * \param doc The document object
- * \param str The lwc_string object
- * \param result The retured dom_string
- * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
- */
-dom_exception _dom_document_create_string_from_lwcstring(
- struct dom_document *doc, struct lwc_string_s *str,
- dom_string **result)
-{
- return _dom_string_create_from_lwcstring(doc->alloc, doc->pw,
- str, result);
-}
-
-/**
- * Create a hash_table
- *
- * \param doc The dom_document
- * \param chains The number of chains
- * \param f The hash function
- * \param ht The returned hash_table
- * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
- */
-dom_exception _dom_document_create_hashtable(struct dom_document *doc,
- size_t chains, dom_hash_func f, struct dom_hash_table **ht)
-{
- struct dom_hash_table *ret;
-
- ret = _dom_hash_create(chains, f, doc->alloc, doc->pw);
- if (ret == NULL)
- return DOM_NO_MEM_ERR;
-
- *ht = ret;
- return DOM_NO_ERR;
-}
-
-/**
- * (De)allocate memory with a document's context
- *
- * \param doc The document context to allocate from
- * \param ptr Pointer to data to reallocate, or NULL to alloc new
- * \param size Required size of data, or 0 to free
- * \return Pointer to allocated data or NULL on failure
- *
- * This call (modulo ::doc) has the same semantics as realloc().
- * It is a thin veneer over the client-provided allocation function.
- */
-void *_dom_document_alloc(struct dom_document *doc, void *ptr, size_t size)
-{
- return doc->alloc(ptr, size, doc->pw);
-}
/**
* Get a nodelist, creating one if necessary
@@ -1393,10 +1084,10 @@
* the responsibility of the caller to unref the list once it has
* finished with it.
*/
-dom_exception _dom_document_get_nodelist(struct dom_document *doc,
- nodelist_type type, struct dom_node_internal *root,
- struct lwc_string_s *tagname, struct lwc_string_s *namespace,
- struct lwc_string_s *localname, struct dom_nodelist **list)
+dom_exception _dom_document_get_nodelist(dom_document *doc,
+ nodelist_type type, dom_node_internal *root,
+ dom_string *tagname, dom_string *namespace,
+ dom_string *localname, dom_nodelist **list)
{
struct dom_doc_nl *l;
dom_exception err;
@@ -1414,7 +1105,7 @@
/* No existing list */
/* Create active list entry */
- l = doc->alloc(NULL, sizeof(struct dom_doc_nl), doc->pw);
+ l = malloc(sizeof(struct dom_doc_nl));
if (l == NULL)
return DOM_NO_MEM_ERR;
@@ -1422,7 +1113,7 @@
err = _dom_nodelist_create(doc, type, root, tagname, namespace,
localname, &l->list);
if (err != DOM_NO_ERR) {
- doc->alloc(l, 0, doc->pw);
+ free(l);
return err;
}
@@ -1451,8 +1142,8 @@
* \param doc The document to remove the list from
* \param list The list to remove
*/
-void _dom_document_remove_nodelist(struct dom_document *doc,
- struct dom_nodelist *list)
+void _dom_document_remove_nodelist(dom_document *doc,
+ dom_nodelist *list)
{
struct dom_doc_nl *l;
@@ -1476,7 +1167,7 @@
l->next->prev = l->prev;
/* And free item */
- doc->alloc(l, 0, doc->pw);
+ free(l);
}
/**
@@ -1488,19 +1179,25 @@
* \return DOM_NO_ERR on success, appropriate dom_exception on failure.
*/
dom_exception _dom_find_element_by_id(dom_node_internal *root,
- struct lwc_string_s *id, struct dom_element **result)
-{
+ dom_string *id, dom_element **result)
+{
+ dom_node_internal *node = root;
+
*result = NULL;
- dom_node_internal *node = root;
while (node != NULL) {
if (node->type == DOM_ELEMENT_NODE) {
- lwc_string *real_id;
+ dom_string *real_id;
+
_dom_element_get_id((dom_element *) node, &real_id);
- if (real_id == id) {
+
+ if (dom_string_isequal(real_id, id)) {
+ dom_string_unref(real_id);
*result = (dom_element *) node;
return DOM_NO_ERR;
}
+
+ dom_string_unref(real_id);
}
if (node->first_child != NULL) {
@@ -1512,7 +1209,7 @@
} else {
/* No children or siblings.
* Find first unvisited relation. */
- struct dom_node_internal *parent = node->parent;
+ dom_node_internal *parent = node->parent;
while (parent != root &&
node == parent->last_child) {
@@ -1537,11 +1234,12 @@
* \param opt Whether this is adopt or import operation
* \return DOM_NO_ERR on success, appropriate dom_exception on failure.
*/
-dom_exception dom_document_dup_node(dom_document *doc, struct dom_node *node,
- bool deep, struct dom_node **result, dom_node_operation opt)
-{
+dom_exception dom_document_dup_node(dom_document *doc, dom_node *node,
+ bool deep, dom_node **result, dom_node_operation opt)
+{
+ dom_node_internal *n = (dom_node_internal *) node;
+ dom_node_internal *ret;
dom_exception err;
- dom_node_internal *n = (dom_node_internal *) node;
if (opt == DOM_NODE_ADOPTED && _dom_node_readonly(n))
return DOM_NO_MODIFICATION_ALLOWED_ERR;
@@ -1550,15 +1248,9 @@
n->type == DOM_DOCUMENT_TYPE_NODE)
return DOM_NOT_SUPPORTED_ERR;
- err = dom_node_alloc(doc, node, result);
+ err = dom_node_copy(node, &ret);
if (err != DOM_NO_ERR)
return err;
-
- err = dom_node_copy(*result, node);
- if (err != DOM_NO_ERR) {
- _dom_document_alloc(doc, *result, 0);
- return err;
- }
if (n->type == DOM_ATTRIBUTE_NODE) {
_dom_attr_set_specified((dom_attr *) node, true);
@@ -1588,13 +1280,13 @@
err = dom_document_import_node(doc, child, deep,
(void *) &r);
if (err != DOM_NO_ERR) {
- _dom_document_alloc(doc, *result, 0);
+ dom_node_unref(ret);
return err;
}
- err = dom_node_append_child(*result, r, (void *) &r);
+ err = dom_node_append_child(ret, r, (void *) &r);
if (err != DOM_NO_ERR) {
- _dom_document_alloc(doc, *result, 0);
+ dom_node_unref(ret);
dom_node_unref(r);
return err;
}
@@ -1608,11 +1300,14 @@
dom_user_data *ud;
ud = n->user_data;
while (ud != NULL) {
- if (ud->handler != NULL)
- ud->handler(opt, ud->key, ud->data,
- node, *result);
+ if (ud->handler != NULL) {
+ ud->handler(opt, ud->key, ud->data, node,
+ (dom_node *) ret);
+ }
ud = ud->next;
}
+
+ *result = (dom_node *) ret;
return DOM_NO_ERR;
}
@@ -1628,7 +1323,7 @@
*
* else, do nothing.
*/
-void _dom_document_try_destroy(struct dom_document *doc)
+void _dom_document_try_destroy(dom_document *doc)
{
if (doc->base.refcnt != 0 || doc->base.parent != NULL)
return;
@@ -1642,10 +1337,10 @@
* \param doc The document object
* \param name The ID name of the elements in this document
*/
-void _dom_document_set_id_name(dom_document *doc, struct lwc_string_s *name)
+void _dom_document_set_id_name(dom_document *doc, dom_string *name)
{
if (doc->id_name != NULL)
- lwc_string_unref(doc->id_name);
- doc->id_name = lwc_string_ref(name);
-}
-
+ dom_string_unref(doc->id_name);
+ doc->id_name = dom_string_ref(name);
+}
+
Modified: branches/jmb/dom-alloc-purge/src/core/document.h
URL: http://source.netsurf-browser.org/branches/jmb/dom-alloc-purge/src/core/d...
==============================================================================
--- branches/jmb/dom-alloc-purge/src/core/document.h (original)
+++ branches/jmb/dom-alloc-purge/src/core/document.h Tue Jun 28 18:28:50 2011
@@ -12,7 +12,16 @@
#include <stddef.h>
#include <dom/core/node.h>
+#include <dom/core/attr.h>
+#include <dom/core/cdatasection.h>
+#include <dom/core/comment.h>
#include <dom/core/document.h>
+#include <dom/core/document_type.h>
+#include <dom/core/doc_fragment.h>
+#include <dom/core/element.h>
+#include <dom/core/entity_ref.h>
+#include <dom/core/pi.h>
+#include <dom/core/text.h>
#include <dom/core/implementation.h>
#include "core/string.h"
@@ -23,21 +32,6 @@
#include "utils/list.h"
#include "events/document_event.h"
-
-struct dom_document;
-struct dom_namednodemap;
-struct dom_node;
-struct dom_nodelist;
-struct dom_document_type;
-struct dom_element;
-struct dom_document_fragment;
-struct dom_text;
-struct dom_comment;
-struct dom_cdata_section;
-struct dom_processing_instruction;
-struct dom_attr;
-struct dom_entity_reference;
-struct dom_configuration;
struct dom_doc_nl;
@@ -47,7 +41,7 @@
* this.
*/
struct dom_document {
- struct dom_node_internal base; /**< Base node */
+ dom_node_internal base; /**< Base node */
struct dom_doc_nl *nodelists; /**< List of active nodelists */
@@ -64,100 +58,85 @@
/* Create a DOM document */
dom_exception _dom_document_create(dom_events_default_action_fetcher daf,
- struct dom_document **doc);
+ dom_document **doc);
/* Initialise the document */
-dom_exception _dom_document_initialise(struct dom_document *doc,
+dom_exception _dom_document_initialise(dom_document *doc,
dom_events_default_action_fetcher daf);
/* Finalise the document */
-bool _dom_document_finalise(struct dom_document *doc);
-
-/* Create a dom_string from C string */
-dom_exception _dom_document_create_string(struct dom_document *doc,
- const uint8_t *data, size_t len, dom_string **result);
-/* Create a lwc_string from C string */
-dom_exception _dom_document_create_lwcstring(struct dom_document *doc,
- const uint8_t *data, size_t len, struct lwc_string_s **result);
-/* Unref a lwc_string of this document */
-void _dom_document_unref_lwcstring(struct dom_document *doc,
- struct lwc_string_s *str);
-/* Create a dom_string from a lwc_string */
-dom_exception _dom_document_create_string_from_lwcstring(
- struct dom_document *doc, struct lwc_string_s *str,
- dom_string **result);
-
+bool _dom_document_finalise(dom_document *doc);
/* Begin the virtual functions */
-dom_exception _dom_document_get_doctype(struct dom_document *doc,
- struct dom_document_type **result);
-dom_exception _dom_document_get_implementation(struct dom_document *doc,
+dom_exception _dom_document_get_doctype(dom_document *doc,
+ dom_document_type **result);
+dom_exception _dom_document_get_implementation(dom_document *doc,
dom_implementation **result);
-dom_exception _dom_document_get_document_element(struct dom_document *doc,
- struct dom_element **result);
-dom_exception _dom_document_create_element(struct dom_document *doc,
- dom_string *tag_name, struct dom_element **result);
-dom_exception _dom_document_create_document_fragment(struct dom_document *doc,
- struct dom_document_fragment **result);
-dom_exception _dom_document_create_text_node(struct dom_document *doc,
- dom_string *data, struct dom_text **result);
-dom_exception _dom_document_create_comment(struct dom_document *doc,
- dom_string *data, struct dom_comment **result);
-dom_exception _dom_document_create_cdata_section(struct dom_document *doc,
- dom_string *data, struct dom_cdata_section **result);
+dom_exception _dom_document_get_document_element(dom_document *doc,
+ dom_element **result);
+dom_exception _dom_document_create_element(dom_document *doc,
+ dom_string *tag_name, dom_element **result);
+dom_exception _dom_document_create_document_fragment(dom_document *doc,
+ dom_document_fragment **result);
+dom_exception _dom_document_create_text_node(dom_document *doc,
+ dom_string *data, dom_text **result);
+dom_exception _dom_document_create_comment(dom_document *doc,
+ dom_string *data, dom_comment **result);
+dom_exception _dom_document_create_cdata_section(dom_document *doc,
+ dom_string *data, dom_cdata_section **result);
dom_exception _dom_document_create_processing_instruction(
- struct dom_document *doc, dom_string *target,
+ dom_document *doc, dom_string *target,
dom_string *data,
- struct dom_processing_instruction **result);
-dom_exception _dom_document_create_attribute(struct dom_document *doc,
- dom_string *name, struct dom_attr **result);
-dom_exception _dom_document_create_entity_reference(struct dom_document *doc,
+ dom_processing_instruction **result);
+dom_exception _dom_document_create_attribute(dom_document *doc,
+ dom_string *name, dom_attr **result);
+dom_exception _dom_document_create_entity_reference(dom_document *doc,
dom_string *name,
- struct dom_entity_reference **result);
-dom_exception _dom_document_get_elements_by_tag_name(struct dom_document *doc,
- dom_string *tagname, struct dom_nodelist **result);
-dom_exception _dom_document_import_node(struct dom_document *doc,
- struct dom_node *node, bool deep, struct dom_node **result);
-dom_exception _dom_document_create_element_ns(struct dom_document *doc,
+ dom_entity_reference **result);
+dom_exception _dom_document_get_elements_by_tag_name(dom_document *doc,
+ dom_string *tagname, dom_nodelist **result);
+dom_exception _dom_document_import_node(dom_document *doc,
+ dom_node *node, bool deep, dom_node **result);
+dom_exception _dom_document_create_element_ns(dom_document *doc,
dom_string *namespace, dom_string *qname,
- struct dom_element **result);
-dom_exception _dom_document_create_attribute_ns(struct dom_document *doc,
+ dom_element **result);
+dom_exception _dom_document_create_attribute_ns(dom_document *doc,
dom_string *namespace, dom_string *qname,
- struct dom_attr **result);
+ dom_attr **result);
dom_exception _dom_document_get_elements_by_tag_name_ns(
- struct dom_document *doc, dom_string *namespace,
- dom_string *localname, struct dom_nodelist **result);
-dom_exception _dom_document_get_element_by_id(struct dom_document *doc,
- dom_string *id, struct dom_element **result);
-dom_exception _dom_document_get_input_encoding(struct dom_document *doc,
- dom_string **result);
-dom_exception _dom_document_get_xml_encoding(struct dom_document *doc,
- dom_string **result);
-dom_exception _dom_document_get_xml_standalone(struct dom_document *doc,
+ dom_document *doc, dom_string *namespace,
+ dom_string *localname, dom_nodelist **result);
+dom_exception _dom_document_get_element_by_id(dom_document *doc,
+ dom_string *id, dom_element **result);
+dom_exception _dom_document_get_input_encoding(dom_document *doc,
+ dom_string **result);
+dom_exception _dom_document_get_xml_encoding(dom_document *doc,
+ dom_string **result);
+dom_exception _dom_document_get_xml_standalone(dom_document *doc,
bool *result);
-dom_exception _dom_document_set_xml_standalone(struct dom_document *doc,
+dom_exception _dom_document_set_xml_standalone(dom_document *doc,
bool standalone);
-dom_exception _dom_document_get_xml_version(struct dom_document *doc,
- dom_string **result);
-dom_exception _dom_document_set_xml_version(struct dom_document *doc,
+dom_exception _dom_document_get_xml_version(dom_document *doc,
+ dom_string **result);
+dom_exception _dom_document_set_xml_version(dom_document *doc,
dom_string *version);
dom_exception _dom_document_get_strict_error_checking(
- struct dom_document *doc, bool *result);
+ dom_document *doc, bool *result);
dom_exception _dom_document_set_strict_error_checking(
- struct dom_document *doc, bool strict);
-dom_exception _dom_document_get_uri(struct dom_document *doc,
- dom_string **result);
-dom_exception _dom_document_set_uri(struct dom_document *doc,
+ dom_document *doc, bool strict);
+dom_exception _dom_document_get_uri(dom_document *doc,
+ dom_string **result);
+dom_exception _dom_document_set_uri(dom_document *doc,
dom_string *uri);
-dom_exception _dom_document_adopt_node(struct dom_document *doc,
- struct dom_node *node, struct dom_node **result);
-dom_exception _dom_document_get_dom_config(struct dom_document *doc,
+dom_exception _dom_document_adopt_node(dom_document *doc,
+ dom_node *node, dom_node **result);
+dom_exception _dom_document_get_dom_config(dom_document *doc,
struct dom_configuration **result);
-dom_exception _dom_document_normalize(struct dom_document *doc);
-dom_exception _dom_document_rename_node(struct dom_document *doc,
- struct dom_node *node,
+dom_exception _dom_document_normalize(dom_document *doc);
+dom_exception _dom_document_rename_node(dom_document *doc,
+ dom_node *node,
dom_string *namespace, dom_string *qname,
- struct dom_node **result);
+ dom_node **result);
#define DOM_DOCUMENT_VTABLE \
_dom_document_get_doctype, \
@@ -209,7 +188,7 @@
static inline dom_exception dom_document_get_base(dom_document *doc,
dom_string **base_uri)
{
- struct dom_node_internal *node = (struct dom_node_internal *) doc;
+ dom_node_internal *node = (dom_node_internal *) doc;
return ((dom_document_protected_vtable *) node->vtable)->
dom_document_get_base(doc, base_uri);
}
@@ -217,9 +196,9 @@
(dom_document *) (d), (dom_string **) (b))
/* Following comes the protected vtable */
-void _dom_document_destroy(struct dom_node_internal *node);
-dom_exception _dom_document_copy(struct dom_node_internal *new,
- struct dom_node_internal *old);
+void _dom_document_destroy(dom_node_internal *node);
+dom_exception _dom_document_copy(dom_node_internal *old,
+ dom_node_internal **copy);
#define DOM_DOCUMENT_PROTECT_VTABLE \
_dom_document_destroy, \
@@ -231,28 +210,22 @@
/* Try to destroy the document:
* When the refcnt is zero and the pending list is empty, we can destroy this
* document. */
-void _dom_document_try_destroy(struct dom_document *doc);
-
-/* Create a hash_table */
-dom_exception _dom_document_create_hashtable(struct dom_document *doc,
- size_t chains, dom_hash_func f, struct dom_hash_table **ht);
+void _dom_document_try_destroy(dom_document *doc);
/* Get a nodelist, creating one if necessary */
-dom_exception _dom_document_get_nodelist(struct dom_document *doc,
- nodelist_type type, struct dom_node_internal *root,
+dom_exception _dom_document_get_nodelist(dom_document *doc,
+ nodelist_type type, dom_node_internal *root,
dom_string *tagname, dom_string *namespace,
- dom_string *localname, struct dom_nodelist **list);
+ dom_string *localname, dom_nodelist **list);
/* Remove a nodelist */
-void _dom_document_remove_nodelist(struct dom_document *doc,
- struct dom_nodelist *list);
+void _dom_document_remove_nodelist(dom_document *doc, dom_nodelist *list);
/* Find element with certain ID in the subtree rooted at root */
dom_exception _dom_find_element_by_id(dom_node_internal *root,
- struct lwc_string_s *id, struct dom_element **result);
+ dom_string *id, dom_element **result);
/* Set the ID attribute name of this document */
-void _dom_document_set_id_name(struct dom_document *doc,
- struct lwc_string_s *name);
+void _dom_document_set_id_name(dom_document *doc, dom_string *name);
#define _dom_document_get_id_name(d) (d->id_name)
Modified: branches/jmb/dom-alloc-purge/src/core/element.c
URL: http://source.netsurf-browser.org/branches/jmb/dom-alloc-purge/src/core/e...
==============================================================================
--- branches/jmb/dom-alloc-purge/src/core/element.c (original)
+++ branches/jmb/dom-alloc-purge/src/core/element.c Tue Jun 28 18:28:50 2011
@@ -179,20 +179,21 @@
assert(doc != NULL);
- err = _dom_document_create_hashtable(doc, CHAINS_ATTRIBUTES,
- (dom_hash_func) dom_string_hash, &el->attributes);
- if (err != DOM_NO_ERR) {
+ el->attributes = _dom_hash_create(CHAINS_ATTRIBUTES,
+ (dom_hash_func) dom_string_hash);
+ if (el->attributes == NULL) {
free(el);
- return err;
- }
-
- err = _dom_document_create_hashtable(doc, CHAINS_NAMESPACE,
- (dom_hash_func) dom_string_hash, &el->ns_attributes);
- if (err != DOM_NO_ERR) {
+ return DOM_NO_MEM_ERR;;
+ }
+
+ el->ns_attributes = _dom_hash_create(CHAINS_NAMESPACE,
+ (dom_hash_func) dom_string_hash);
+ if (el->ns_attributes == NULL) {
free(el->attributes);
free(el);
- return err;
- }
+ return DOM_NO_MEM_ERR;
+ }
+
/* Initialise the base class */
err = _dom_node_initialise(&el->base, doc, DOM_ELEMENT_NODE,
name, NULL, namespace, prefix);
@@ -519,10 +520,10 @@
dom_document *doc;
doc = dom_node_get_owner(element);
assert(doc != NULL);
- err = _dom_document_create_hashtable(doc, CHAINS_NS_ATTRIBUTES,
- (dom_hash_func) dom_string_hash, &attrs);
- if (err != DOM_NO_ERR)
- return err;
+ attrs = _dom_hash_create(CHAINS_NS_ATTRIBUTES,
+ (dom_hash_func) dom_string_hash);
+ if (attrs == NULL)
+ return DOM_NO_MEM_ERR;
added = _dom_hash_add(element->ns_attributes, namespace, attrs,
false);
@@ -645,10 +646,10 @@
dom_document *doc;
doc = dom_node_get_owner(element);
assert(doc != NULL);
- err = _dom_document_create_hashtable(doc, CHAINS_NS_ATTRIBUTES,
- (dom_hash_func) dom_string_hash, &attrs);
- if (err != DOM_NO_ERR)
- return err;
+ attrs = _dom_hash_create(CHAINS_NS_ATTRIBUTES,
+ (dom_hash_func) dom_string_hash);
+ if (attrs == NULL)
+ return DOM_NO_MEM_ERR;
added = _dom_hash_add(element->ns_attributes, namespace, attrs,
false);
11 years, 11 months
r12537 jmb - in /branches/jmb/dom-alloc-purge/src/core: doc_fragment.c doc_fragment.h
by netsurf@semichrome.net
Author: jmb
Date: Tue Jun 28 16:52:06 2011
New Revision: 12537
URL: http://source.netsurf-browser.org?rev=12537&view=rev
Log:
Fix up DocumentFragment
Modified:
branches/jmb/dom-alloc-purge/src/core/doc_fragment.c
branches/jmb/dom-alloc-purge/src/core/doc_fragment.h
Modified: branches/jmb/dom-alloc-purge/src/core/doc_fragment.c
URL: http://source.netsurf-browser.org/branches/jmb/dom-alloc-purge/src/core/d...
==============================================================================
--- branches/jmb/dom-alloc-purge/src/core/doc_fragment.c (original)
+++ branches/jmb/dom-alloc-purge/src/core/doc_fragment.c Tue Jun 28 16:52:06 2011
@@ -6,7 +6,7 @@
* Copyright 2009 Bo Yang <struggleyb.nku(a)gmail.com>
*/
-#include <libwapcaplet/libwapcaplet.h>
+#include <stdlib.h>
#include <dom/core/node.h>
@@ -19,7 +19,7 @@
* A DOM document fragment
*/
struct dom_document_fragment {
- struct dom_node_internal base; /**< Base node */
+ dom_node_internal base; /**< Base node */
};
static struct dom_node_vtable df_vtable = {
@@ -44,19 +44,16 @@
*
* The returned node will already be referenced.
*/
-dom_exception _dom_document_fragment_create(struct dom_document *doc,
- struct lwc_string_s *name, dom_string *value,
- struct dom_document_fragment **result)
+dom_exception _dom_document_fragment_create(dom_document *doc,
+ dom_string *name, dom_string *value,
+ dom_document_fragment **result)
{
- struct dom_document_fragment *f;
+ dom_document_fragment *f;
dom_exception err;
- /* Allocate the comment node */
- f = _dom_document_alloc(doc, NULL,
- sizeof(struct dom_document_fragment));
+ f = malloc(sizeof(dom_document_fragment));
if (f == NULL)
return DOM_NO_MEM_ERR;
-
f->base.base.vtable = &df_vtable;
f->base.vtable = &df_protect_vtable;
@@ -65,7 +62,7 @@
err = _dom_document_fragment_initialise(&f->base, doc,
DOM_DOCUMENT_FRAGMENT_NODE, name, value, NULL, NULL);
if (err != DOM_NO_ERR) {
- _dom_document_alloc(doc, f, 0);
+ free(f);
return err;
}
@@ -77,19 +74,17 @@
/**
* Destroy a document fragment
*
- * \param doc The owning document
* \param frag The document fragment to destroy
*
* The contents of ::frag will be destroyed and ::frag will be freed.
*/
-void _dom_document_fragment_destroy(struct dom_document *doc,
- struct dom_document_fragment *frag)
+void _dom_document_fragment_destroy(dom_document_fragment *frag)
{
/* Finalise base class */
- _dom_document_fragment_finalise(doc, &frag->base);
+ _dom_document_fragment_finalise(&frag->base);
/* Destroy fragment */
- _dom_document_alloc(doc, frag, 0);
+ free(frag);
}
/*-----------------------------------------------------------------------*/
@@ -97,34 +92,29 @@
/* Overload protected functions */
/* The virtual destroy function of this class */
-void _dom_df_destroy(struct dom_node_internal *node)
+void _dom_df_destroy(dom_node_internal *node)
{
- _dom_document_fragment_destroy(node->owner,
- (struct dom_document_fragment *) node);
+ _dom_document_fragment_destroy((dom_document_fragment *) node);
}
-/* The memory allocator of this class */
-dom_exception _dom_df_alloc(struct dom_document *doc,
- struct dom_node_internal *n, struct dom_node_internal **ret)
+/* The copy constructor of this class */
+dom_exception _dom_df_copy(dom_node_internal *old, dom_node_internal **copy)
{
- UNUSED(n);
- struct dom_document_fragment *a;
-
- a = _dom_document_alloc(doc, NULL,
- sizeof(struct dom_document_fragment));
- if (a == NULL)
+ dom_document_fragment *new_f;
+ dom_exception err;
+
+ new_f = malloc(sizeof(dom_document_fragment));
+ if (new_f == NULL)
return DOM_NO_MEM_ERR;
-
- *ret = (dom_node_internal *) a;
- dom_node_set_owner(*ret, doc);
+
+ err = dom_node_copy_internal(old, new_f);
+ if (err != DOM_NO_ERR) {
+ free(new_f);
+ return err;
+ }
+
+ *copy = (dom_node_internal *) new_f;
return DOM_NO_ERR;
}
-/* The copy constructor of this class */
-dom_exception _dom_df_copy(struct dom_node_internal *new,
- struct dom_node_internal *old)
-{
- return _dom_node_copy(new, old);
-}
-
Modified: branches/jmb/dom-alloc-purge/src/core/doc_fragment.h
URL: http://source.netsurf-browser.org/branches/jmb/dom-alloc-purge/src/core/d...
==============================================================================
--- branches/jmb/dom-alloc-purge/src/core/doc_fragment.h (original)
+++ branches/jmb/dom-alloc-purge/src/core/doc_fragment.h Tue Jun 28 16:52:06 2011
@@ -9,32 +9,24 @@
#define dom_internal_core_documentfragment_h_
#include <dom/core/exceptions.h>
+#include <dom/core/doc_fragment.h>
-struct dom_document_fragment;
-struct dom_document;
-struct lwc_string_s;
+dom_exception _dom_document_fragment_create(dom_document *doc,
+ dom_string *name, dom_string *value,
+ dom_document_fragment **result);
-dom_exception _dom_document_fragment_create(struct dom_document *doc,
- struct lwc_string_s *name, dom_string *value,
- struct dom_document_fragment **result);
-
-void _dom_document_fragment_destroy(struct dom_document *doc,
- struct dom_document_fragment *frag);
+void _dom_document_fragment_destroy(dom_document_fragment *frag);
#define _dom_document_fragment_initialise _dom_node_initialise
#define _dom_document_fragment_finalise _dom_node_finalise
/* Following comes the protected vtable */
-void _dom_df_destroy(struct dom_node_internal *node);
-dom_exception _dom_df_alloc(struct dom_document *doc,
- struct dom_node_internal *n, struct dom_node_internal **ret);
-dom_exception _dom_df_copy(struct dom_node_internal *new,
- struct dom_node_internal *old);
+void _dom_df_destroy(dom_node_internal *node);
+dom_exception _dom_df_copy(dom_node_internal *old, dom_node_internal **copy);
#define DOM_DF_PROTECT_VTABLE \
_dom_df_destroy, \
- _dom_df_alloc, \
_dom_df_copy
#endif
11 years, 11 months
r12536 tlsa - /trunk/netsurf/riscos/content-handlers/artworks.c
by netsurf@semichrome.net
Author: tlsa
Date: Tue Jun 28 16:49:46 2011
New Revision: 12536
URL: http://source.netsurf-browser.org?rev=12536&view=rev
Log:
Fix up Artworks content handler.
Modified:
trunk/netsurf/riscos/content-handlers/artworks.c
Modified: trunk/netsurf/riscos/content-handlers/artworks.c
URL: http://source.netsurf-browser.org/trunk/netsurf/riscos/content-handlers/a...
==============================================================================
--- trunk/netsurf/riscos/content-handlers/artworks.c (original)
+++ trunk/netsurf/riscos/content-handlers/artworks.c Tue Jun 28 16:49:46 2011
@@ -377,12 +377,12 @@
info.ditherx = ro_plot_origin_x;
info.dithery = ro_plot_origin_y;
- clip_x0 -= x;
- clip_y0 -= y;
- clip_x1 -= x;
- clip_y1 -= y;
-
- if (scale == 1.0) {
+ clip_x0 -= data->x;
+ clip_y0 -= data->y;
+ clip_x1 -= data->x;
+ clip_y1 -= data->y;
+
+ if (data->scale == 1.0) {
info.clip_x0 = (clip_x0 * 512) + aw->x0 - 511;
info.clip_y0 = ((c->height - clip_y1) * 512) + aw->y0 - 511;
info.clip_x1 = (clip_x1 * 512) + aw->x0 + 511;
11 years, 11 months
r12535 jmb - in /branches/jmb/dom-alloc-purge/src/core: entity_ref.c entity_ref.h pi.c pi.h
by netsurf@semichrome.net
Author: jmb
Date: Tue Jun 28 16:47:41 2011
New Revision: 12535
URL: http://source.netsurf-browser.org?rev=12535&view=rev
Log:
Fix up EntityReference and ProcessingInstruction nodes
Modified:
branches/jmb/dom-alloc-purge/src/core/entity_ref.c
branches/jmb/dom-alloc-purge/src/core/entity_ref.h
branches/jmb/dom-alloc-purge/src/core/pi.c
branches/jmb/dom-alloc-purge/src/core/pi.h
Modified: branches/jmb/dom-alloc-purge/src/core/entity_ref.c
URL: http://source.netsurf-browser.org/branches/jmb/dom-alloc-purge/src/core/e...
==============================================================================
--- branches/jmb/dom-alloc-purge/src/core/entity_ref.c (original)
+++ branches/jmb/dom-alloc-purge/src/core/entity_ref.c Tue Jun 28 16:47:41 2011
@@ -6,7 +6,7 @@
* Copyright 2009 Bo Yang <struggleyb.nku(a)gmail.com>
*/
-#include <libwapcaplet/libwapcaplet.h>
+#include <stdlib.h>
#include "core/document.h"
#include "core/entity_ref.h"
@@ -17,7 +17,7 @@
* A DOM entity reference
*/
struct dom_entity_reference {
- struct dom_node_internal base; /**< Base node */
+ dom_node_internal base; /**< Base node */
};
static struct dom_node_vtable er_vtable = {
@@ -42,16 +42,15 @@
*
* The returned node will already be referenced.
*/
-dom_exception _dom_entity_reference_create(struct dom_document *doc,
- struct lwc_string_s *name, dom_string *value,
- struct dom_entity_reference **result)
+dom_exception _dom_entity_reference_create(dom_document *doc,
+ dom_string *name, dom_string *value,
+ dom_entity_reference **result)
{
- struct dom_entity_reference *e;
+ dom_entity_reference *e;
dom_exception err;
/* Allocate the comment node */
- e = _dom_document_alloc(doc, NULL,
- sizeof(struct dom_entity_reference));
+ e = malloc(sizeof(dom_entity_reference));
if (e == NULL)
return DOM_NO_MEM_ERR;
@@ -62,7 +61,7 @@
err = _dom_entity_reference_initialise(&e->base, doc,
DOM_ENTITY_REFERENCE_NODE, name, value, NULL, NULL);
if (err != DOM_NO_ERR) {
- _dom_document_alloc(doc, e, 0);
+ free(e);
return err;
}
@@ -74,19 +73,17 @@
/**
* Destroy an entity reference
*
- * \param doc The owning document
* \param entity The entity reference to destroy
*
* The contents of ::entity will be destroyed and ::entity will be freed.
*/
-void _dom_entity_reference_destroy(struct dom_document *doc,
- struct dom_entity_reference *entity)
+void _dom_entity_reference_destroy(dom_entity_reference *entity)
{
/* Finalise base class */
- _dom_entity_reference_finalise(doc, &entity->base);
+ _dom_entity_reference_finalise(&entity->base);
/* Destroy fragment */
- _dom_document_alloc(doc, entity, 0);
+ free(entity);
}
/**
@@ -101,7 +98,7 @@
* finished with it.
*/
dom_exception _dom_entity_reference_get_textual_representation(
- struct dom_entity_reference *entity, dom_string **result)
+ dom_entity_reference *entity, dom_string **result)
{
UNUSED(entity);
UNUSED(result);
@@ -114,34 +111,29 @@
/* Following comes the protected vtable */
/* The virtual destroy function of this class */
-void _dom_er_destroy(struct dom_node_internal *node)
+void _dom_er_destroy(dom_node_internal *node)
{
- _dom_entity_reference_destroy(node->owner,
- (struct dom_entity_reference *) node);
-}
-
-/* The memory allocator of this class */
-dom_exception _dom_er_alloc(struct dom_document *doc,
- struct dom_node_internal *n, struct dom_node_internal **ret)
-{
- UNUSED(n);
- dom_entity_reference *a;
-
- a = _dom_document_alloc(doc, NULL, sizeof(struct dom_entity_reference));
- if (a == NULL)
- return DOM_NO_MEM_ERR;
-
- *ret = (dom_node_internal *) a;
- dom_node_set_owner(*ret, doc);
-
- return DOM_NO_ERR;
-
+ _dom_entity_reference_destroy((dom_entity_reference *) node);
}
/* The copy constructor of this class */
-dom_exception _dom_er_copy(struct dom_node_internal *new,
- struct dom_node_internal *old)
+dom_exception _dom_er_copy(dom_node_internal *old, dom_node_internal **copy)
{
- return _dom_node_copy(new, old);
+ dom_entity_reference *new_er;
+ dom_exception err;
+
+ new_er = malloc(sizeof(dom_entity_reference));
+ if (new_er == NULL)
+ return DOM_NO_MEM_ERR;
+
+ err = dom_node_copy_internal(old, new_er);
+ if (err != DOM_NO_ERR) {
+ free(new_er);
+ return err;
+ }
+
+ *copy = (dom_node_internal *) new_er;
+
+ return DOM_NO_ERR;
}
Modified: branches/jmb/dom-alloc-purge/src/core/entity_ref.h
URL: http://source.netsurf-browser.org/branches/jmb/dom-alloc-purge/src/core/e...
==============================================================================
--- branches/jmb/dom-alloc-purge/src/core/entity_ref.h (original)
+++ branches/jmb/dom-alloc-purge/src/core/entity_ref.h Tue Jun 28 16:47:41 2011
@@ -11,35 +11,26 @@
#include <dom/core/exceptions.h>
#include <dom/core/entity_ref.h>
-struct dom_document;
-struct dom_entity_reference;
-struct lwc_string_s;
+dom_exception _dom_entity_reference_create(dom_document *doc,
+ dom_string *name, dom_string *value,
+ dom_entity_reference **result);
-dom_exception _dom_entity_reference_create(struct dom_document *doc,
- struct lwc_string_s *name, dom_string *value,
- struct dom_entity_reference **result);
-
-void _dom_entity_reference_destroy(struct dom_document *doc,
- struct dom_entity_reference *entity);
+void _dom_entity_reference_destroy(dom_entity_reference *entity);
#define _dom_entity_reference_initialise _dom_node_initialise
#define _dom_entity_reference_finalise _dom_node_finalise
/* Following comes the protected vtable */
-void _dom_er_destroy(struct dom_node_internal *node);
-dom_exception _dom_er_alloc(struct dom_document *doc,
- struct dom_node_internal *n, struct dom_node_internal **ret);
-dom_exception _dom_er_copy(struct dom_node_internal *new,
- struct dom_node_internal *old);
+void _dom_er_destroy(dom_node_internal *node);
+dom_exception _dom_er_copy(dom_node_internal *old, dom_node_internal **copy);
#define DOM_ER_PROTECT_VTABLE \
_dom_er_destroy, \
- _dom_er_alloc, \
_dom_er_copy
/* Helper functions */
dom_exception _dom_entity_reference_get_textual_representation(
- struct dom_entity_reference *entity,
+ dom_entity_reference *entity,
dom_string **result);
#endif
Modified: branches/jmb/dom-alloc-purge/src/core/pi.c
URL: http://source.netsurf-browser.org/branches/jmb/dom-alloc-purge/src/core/p...
==============================================================================
--- branches/jmb/dom-alloc-purge/src/core/pi.c (original)
+++ branches/jmb/dom-alloc-purge/src/core/pi.c Tue Jun 28 16:47:41 2011
@@ -4,6 +4,8 @@
* http://www.opensource.org/licenses/mit-license.php
* Copyright 2007 John-Mark Bell <jmb(a)netsurf-browser.org>
*/
+
+#include <stdlib.h>
#include "core/document.h"
#include "core/node.h"
@@ -15,7 +17,7 @@
* A DOM processing instruction
*/
struct dom_processing_instruction {
- struct dom_node_internal base; /**< Base node */
+ dom_node_internal base; /**< Base node */
};
static struct dom_node_vtable pi_vtable = {
@@ -39,16 +41,15 @@
*
* The returned node will already be referenced.
*/
-dom_exception _dom_processing_instruction_create(struct dom_document *doc,
- struct lwc_string_s *name, dom_string *value,
- struct dom_processing_instruction **result)
+dom_exception _dom_processing_instruction_create(dom_document *doc,
+ dom_string *name, dom_string *value,
+ dom_processing_instruction **result)
{
- struct dom_processing_instruction *p;
+ dom_processing_instruction *p;
dom_exception err;
/* Allocate the comment node */
- p = _dom_document_alloc(doc, NULL,
- sizeof(struct dom_processing_instruction));
+ p = malloc(sizeof(dom_processing_instruction));
if (p == NULL)
return DOM_NO_MEM_ERR;
@@ -60,7 +61,7 @@
DOM_PROCESSING_INSTRUCTION_NODE,
name, value, NULL, NULL);
if (err != DOM_NO_ERR) {
- _dom_document_alloc(doc, p, 0);
+ free(p);
return err;
}
@@ -72,19 +73,17 @@
/**
* Destroy a processing instruction
*
- * \param doc The owning document
* \param pi The processing instruction to destroy
*
* The contents of ::pi will be destroyed and ::pi will be freed.
*/
-void _dom_processing_instruction_destroy(struct dom_document *doc,
- struct dom_processing_instruction *pi)
+void _dom_processing_instruction_destroy(dom_processing_instruction *pi)
{
/* Finalise base class */
- _dom_processing_instruction_finalise(doc, &pi->base);
+ _dom_processing_instruction_finalise(&pi->base);
/* Free processing instruction */
- _dom_document_alloc(doc, pi, 0);
+ free(pi);
}
/*-----------------------------------------------------------------------*/
@@ -92,34 +91,30 @@
/* Following comes the protected vtable */
/* The virtual destroy function of this class */
-void _dom_pi_destroy(struct dom_node_internal *node)
+void _dom_pi_destroy(dom_node_internal *node)
{
- _dom_processing_instruction_destroy(node->owner,
- (struct dom_processing_instruction *) node);
+ _dom_processing_instruction_destroy(
+ (dom_processing_instruction *) node);
}
-/* The memory allocator of this class */
-dom_exception _dom_pi_alloc(struct dom_document *doc,
- struct dom_node_internal *n, struct dom_node_internal **ret)
+/* The copy constructor of this class */
+dom_exception _dom_pi_copy(dom_node_internal *old, dom_node_internal **copy)
{
- UNUSED(n);
- struct dom_processing_instruction *a;
-
- a = _dom_document_alloc(doc, NULL,
- sizeof(struct dom_processing_instruction));
- if (a == NULL)
+ dom_processing_instruction *new_pi;
+ dom_exception err;
+
+ new_pi = malloc(sizeof(dom_processing_instruction));
+ if (new_pi == NULL)
return DOM_NO_MEM_ERR;
-
- *ret = (dom_node_internal *) a;
- dom_node_set_owner(*ret, doc);
+
+ err = dom_node_copy_internal(old, new_pi);
+ if (err != DOM_NO_ERR) {
+ free(new_pi);
+ return err;
+ }
+
+ *copy = (dom_node_internal *) copy;
return DOM_NO_ERR;
}
-/* The copy constructor of this class */
-dom_exception _dom_pi_copy(struct dom_node_internal *new,
- struct dom_node_internal *old)
-{
- return _dom_node_copy(new, old);
-}
-
Modified: branches/jmb/dom-alloc-purge/src/core/pi.h
URL: http://source.netsurf-browser.org/branches/jmb/dom-alloc-purge/src/core/p...
==============================================================================
--- branches/jmb/dom-alloc-purge/src/core/pi.h (original)
+++ branches/jmb/dom-alloc-purge/src/core/pi.h Tue Jun 28 16:47:41 2011
@@ -9,31 +9,23 @@
#define dom_internal_core_processinginstruction_h_
#include <dom/core/exceptions.h>
+#include <dom/core/pi.h>
-struct dom_document;
-struct dom_processing_instruction;
-struct lwc_string_s;
+dom_exception _dom_processing_instruction_create(dom_document *doc,
+ dom_string *name, dom_string *value,
+ dom_processing_instruction **result);
-dom_exception _dom_processing_instruction_create(struct dom_document *doc,
- struct lwc_string_s *name, dom_string *value,
- struct dom_processing_instruction **result);
-
-void _dom_processing_instruction_destroy(struct dom_document *doc,
- struct dom_processing_instruction *pi);
+void _dom_processing_instruction_destroy(dom_processing_instruction *pi);
#define _dom_processing_instruction_initialise _dom_node_initialise
#define _dom_processing_instruction_finalise _dom_node_finalise
/* Following comes the protected vtable */
-void _dom_pi_destroy(struct dom_node_internal *node);
-dom_exception _dom_pi_alloc(struct dom_document *doc,
- struct dom_node_internal *n, struct dom_node_internal **ret);
-dom_exception _dom_pi_copy(struct dom_node_internal *new,
- struct dom_node_internal *old);
+void _dom_pi_destroy(dom_node_internal *node);
+dom_exception _dom_pi_copy(dom_node_internal *old, dom_node_internal **copy);
#define DOM_PI_PROTECT_VTABLE \
_dom_pi_destroy, \
- _dom_pi_alloc, \
_dom_pi_copy
#endif
11 years, 11 months
r12534 jmb - in /branches/jmb/dom-alloc-purge/src/core: document_type.c document_type.h
by netsurf@semichrome.net
Author: jmb
Date: Tue Jun 28 16:27:43 2011
New Revision: 12534
URL: http://source.netsurf-browser.org?rev=12534&view=rev
Log:
Fix up DocumentType
Modified:
branches/jmb/dom-alloc-purge/src/core/document_type.c
branches/jmb/dom-alloc-purge/src/core/document_type.h
Modified: branches/jmb/dom-alloc-purge/src/core/document_type.c
URL: http://source.netsurf-browser.org/branches/jmb/dom-alloc-purge/src/core/d...
==============================================================================
--- branches/jmb/dom-alloc-purge/src/core/document_type.c (original)
+++ branches/jmb/dom-alloc-purge/src/core/document_type.c Tue Jun 28 16:27:43 2011
@@ -8,26 +8,23 @@
*/
#include <assert.h>
-
-#include <dom/core/document_type.h>
+#include <stdlib.h>
#include "core/string.h"
#include "core/document_type.h"
+#include "core/namednodemap.h"
#include "core/node.h"
#include "utils/utils.h"
#include "utils/namespace.h"
-#include "utils/resource_mgr.h"
/**
* DOM DocumentType node
*/
struct dom_document_type {
- struct dom_node_internal base; /**< Base node */
+ dom_node_internal base; /**< Base node */
dom_string *public_id; /**< Doctype public ID */
dom_string *system_id; /**< Doctype system ID */
-
- struct dom_resource_mgr res; /**< resource_mgr of this node */
};
static struct dom_document_type_vtable document_type_vtable = {
@@ -63,14 +60,13 @@
*/
dom_exception _dom_document_type_create(dom_string *qname,
dom_string *public_id, dom_string *system_id,
- dom_alloc alloc, void *pw,
- struct dom_document_type **doctype)
-{
- struct dom_document_type *result;
+ dom_document_type **doctype)
+{
+ dom_document_type *result;
dom_exception err;
/* Create node */
- result = alloc(NULL, sizeof(struct dom_document_type), pw);
+ result = malloc(sizeof(dom_document_type));
if (result == NULL)
return DOM_NO_MEM_ERR;
@@ -78,8 +74,12 @@
result->base.base.vtable = &document_type_vtable;
result->base.vtable = &dt_protect_vtable;
- err = _dom_document_type_initialise(result, qname, public_id, system_id,
- alloc, pw);
+ err = _dom_document_type_initialise(result, qname,
+ public_id, system_id);
+ if (err != DOM_NO_ERR) {
+ free(result);
+ return err;
+ }
*doctype = result;
@@ -93,62 +93,37 @@
*
* The contents of ::doctype will be destroyed and ::doctype will be freed.
*/
-void _dom_document_type_destroy(struct dom_node_internal *doctypenode)
-{
- struct dom_document_type *doctype =
- (struct dom_document_type *)doctypenode;
+void _dom_document_type_destroy(dom_node_internal *doctypenode)
+{
+ dom_document_type *doctype = (dom_document_type *) doctypenode;
/* Finalise base class */
_dom_document_type_finalise(doctype);
/* Free doctype */
- doctype->res.alloc(doctype, 0, doctype->res.pw);
+ free(doctype);
}
/* Initialise this document_type */
-dom_exception _dom_document_type_initialise(struct dom_document_type *doctype,
+dom_exception _dom_document_type_initialise(dom_document_type *doctype,
dom_string *qname, dom_string *public_id,
- dom_string *system_id, dom_alloc alloc, void *pw)
-{
+ dom_string *system_id)
+{
+ dom_string *prefix, *localname;
dom_exception err;
- dom_string *prefix, *localname;
err = _dom_namespace_split_qname(qname, &prefix, &localname);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ /* TODO: I should figure out how the namespaceURI can be got */
+
+ /* Initialise base node */
+ err = _dom_node_initialise(&doctype->base, NULL,
+ DOM_DOCUMENT_TYPE_NODE, localname, NULL, NULL, prefix);
if (err != DOM_NO_ERR) {
- alloc(doctype, 0, pw);
- return err;
- }
-
- lwc_string *lprefix = NULL, *lname = NULL;
- if (prefix != NULL) {
- err = _dom_string_intern(prefix, &lprefix);
- if (err != DOM_NO_ERR) {
- dom_string_unref(prefix);
- dom_string_unref(localname);
- alloc(doctype, 0, pw);
- return err;
- }
- }
-
- if (localname != NULL) {
- err = _dom_string_intern(localname, &lname);
- if (err != DOM_NO_ERR) {
- dom_string_unref(prefix);
- dom_string_unref(localname);
- if (lprefix != NULL)
- lwc_string_unref(lprefix);
- alloc(doctype, 0, pw);
- return err;
- }
- }
-
- /* TODO: I should figure out how the namespaceURI can be got */
-
- /* Initialise base node */
- err = _dom_node_initialise_generic(&doctype->base, NULL, alloc, pw,
- DOM_DOCUMENT_TYPE_NODE, lname, NULL, NULL, lprefix);
- if (err != DOM_NO_ERR) {
- alloc(doctype, 0, pw);
+ dom_string_unref(prefix);
+ dom_string_unref(localname);
return err;
}
@@ -166,15 +141,11 @@
if (localname != NULL)
dom_string_unref(localname);
- /* Fill in allocation information */
- doctype->res.alloc = alloc;
- doctype->res.pw = pw;
-
return DOM_NO_ERR;
}
/* The destructor function of dom_document_type */
-void _dom_document_type_finalise(struct dom_document_type *doctype)
+void _dom_document_type_finalise(dom_document_type *doctype)
{
if (doctype->public_id != NULL)
dom_string_unref(doctype->public_id);
@@ -183,8 +154,7 @@
assert(doctype->base.owner != NULL || doctype->base.user_data == NULL);
- _dom_node_finalise_generic(&doctype->base, doctype->res.alloc,
- doctype->res.pw);
+ _dom_node_finalise(&doctype->base);
}
@@ -206,7 +176,7 @@
* We don't support this API now, so this function call should always
* return DOM_NOT_SUPPORTED_ERR.
*/
-dom_exception _dom_document_type_get_name(struct dom_document_type *doc_type,
+dom_exception _dom_document_type_get_name(dom_document_type *doc_type,
dom_string **result)
{
return dom_node_get_node_name(doc_type, result);
@@ -227,8 +197,8 @@
* return DOM_NOT_SUPPORTED_ERR.
*/
dom_exception _dom_document_type_get_entities(
- struct dom_document_type *doc_type,
- struct dom_namednodemap **result)
+ dom_document_type *doc_type,
+ dom_namednodemap **result)
{
UNUSED(doc_type);
UNUSED(result);
@@ -251,8 +221,8 @@
* return DOM_NOT_SUPPORTED_ERR.
*/
dom_exception _dom_document_type_get_notations(
- struct dom_document_type *doc_type,
- struct dom_namednodemap **result)
+ dom_document_type *doc_type,
+ dom_namednodemap **result)
{
UNUSED(doc_type);
UNUSED(result);
@@ -275,7 +245,7 @@
* return DOM_NOT_SUPPORTED_ERR.
*/
dom_exception _dom_document_type_get_public_id(
- struct dom_document_type *doc_type,
+ dom_document_type *doc_type,
dom_string **result)
{
UNUSED(doc_type);
@@ -299,7 +269,7 @@
* return DOM_NOT_SUPPORTED_ERR.
*/
dom_exception _dom_document_type_get_system_id(
- struct dom_document_type *doc_type,
+ dom_document_type *doc_type,
dom_string **result)
{
UNUSED(doc_type);
@@ -323,7 +293,7 @@
* return DOM_NOT_SUPPORTED_ERR.
*/
dom_exception _dom_document_type_get_internal_subset(
- struct dom_document_type *doc_type,
+ dom_document_type *doc_type,
dom_string **result)
{
UNUSED(doc_type);
@@ -337,42 +307,17 @@
/* Overload protected virtual functions */
/* The virtual destroy function of this class */
-void _dom_dt_destroy(struct dom_node_internal *node)
+void _dom_dt_destroy(dom_node_internal *node)
{
_dom_document_type_destroy(node);
}
-/* The memory allocator of this class */
-dom_exception _dom_dt_alloc(struct dom_document *doc,
- struct dom_node_internal *n, struct dom_node_internal **ret)
-{
- UNUSED(doc);
- UNUSED(n);
- UNUSED(ret);
-
- return DOM_NOT_SUPPORTED_ERR;
-}
-
/* The copy constructor of this class */
-dom_exception _dom_dt_copy(struct dom_node_internal *new,
- struct dom_node_internal *old)
-{
- UNUSED(new);
+dom_exception _dom_dt_copy(dom_node_internal *old, dom_node_internal **copy)
+{
UNUSED(old);
-
- return DOM_NOT_SUPPORTED_ERR;
-}
-
-
-/*----------------------------------------------------------------------*/
-
-/* Helper functions */
-
-/* Get the resource manager of this object */
-void _dom_document_type_get_resource_mgr(
- struct dom_document_type *dt, struct dom_resource_mgr *rm)
-{
- rm->alloc = dt->res.alloc;
- rm->pw = dt->res.pw;
-}
-
+ UNUSED(copy);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
Modified: branches/jmb/dom-alloc-purge/src/core/document_type.h
URL: http://source.netsurf-browser.org/branches/jmb/dom-alloc-purge/src/core/d...
==============================================================================
--- branches/jmb/dom-alloc-purge/src/core/document_type.h (original)
+++ branches/jmb/dom-alloc-purge/src/core/document_type.h Tue Jun 28 16:27:43 2011
@@ -8,37 +8,39 @@
#ifndef dom_internal_core_document_type_h_
#define dom_internal_core_document_type_h_
-struct dom_document_type;
+#include <dom/core/document_type.h>
+
+struct dom_namednodemap;
/* Create a DOM document type */
dom_exception _dom_document_type_create(dom_string *qname,
dom_string *public_id,
dom_string *system_id,
- struct dom_document_type **doctype);
+ dom_document_type **doctype);
/* Destroy a document type */
-void _dom_document_type_destroy(struct dom_node_internal *doctypenode);
-dom_exception _dom_document_type_initialise(struct dom_document_type *doctype,
+void _dom_document_type_destroy(dom_node_internal *doctypenode);
+dom_exception _dom_document_type_initialise(dom_document_type *doctype,
dom_string *qname, dom_string *public_id,
dom_string *system_id);
-void _dom_document_type_finalise(struct dom_document_type *doctype);
+void _dom_document_type_finalise(dom_document_type *doctype);
/* The virtual functions of DocumentType */
-dom_exception _dom_document_type_get_name(struct dom_document_type *doc_type,
+dom_exception _dom_document_type_get_name(dom_document_type *doc_type,
dom_string **result);
dom_exception _dom_document_type_get_entities(
- struct dom_document_type *doc_type,
+ dom_document_type *doc_type,
struct dom_namednodemap **result);
dom_exception _dom_document_type_get_notations(
- struct dom_document_type *doc_type,
+ dom_document_type *doc_type,
struct dom_namednodemap **result);
dom_exception _dom_document_type_get_public_id(
- struct dom_document_type *doc_type,
+ dom_document_type *doc_type,
dom_string **result);
dom_exception _dom_document_type_get_system_id(
- struct dom_document_type *doc_type,
+ dom_document_type *doc_type,
dom_string **result);
dom_exception _dom_document_type_get_internal_subset(
- struct dom_document_type *doc_type,
+ dom_document_type *doc_type,
dom_string **result);
#define DOM_DOCUMENT_TYPE_VTABLE \
@@ -50,9 +52,8 @@
_dom_document_type_get_internal_subset
/* Following comes the protected vtable */
-void _dom_dt_destroy(struct dom_node_internal *node);
-dom_exception _dom_dt_copy(struct dom_node_internal *new,
- struct dom_node_internal *old);
+void _dom_dt_destroy(dom_node_internal *node);
+dom_exception _dom_dt_copy(dom_node_internal *old, dom_node_internal **copy);
#define DOM_DT_PROTECT_VTABLE \
_dom_dt_destroy, \
11 years, 11 months
r12533 tlsa - in /trunk/netsurf/render: form.c html_interaction.c
by netsurf@semichrome.net
Author: tlsa
Date: Tue Jun 28 16:16:37 2011
New Revision: 12533
URL: http://source.netsurf-browser.org?rev=12533&view=rev
Log:
Front end gets root browser window on notification of scrollbar widget drag start.
Modified:
trunk/netsurf/render/form.c
trunk/netsurf/render/html_interaction.c
Modified: trunk/netsurf/render/form.c
URL: http://source.netsurf-browser.org/trunk/netsurf/render/form.c?rev=12533&r...
==============================================================================
--- trunk/netsurf/render/form.c (original)
+++ trunk/netsurf/render/form.c Tue Jun 28 16:16:37 2011
@@ -1286,6 +1286,7 @@
struct form_control *control = client_data;
struct form_select_menu *menu = control->data.select.menu;
html_content *html = (html_content *)menu->c;
+ struct browser_window *root_bw;
switch (scrollbar_data->msg) {
case SCROLLBAR_MSG_REDRAW:
@@ -1306,7 +1307,9 @@
browser_window_set_drag_type(html->bw, DRAGGING_OTHER);
menu->scroll_capture = true;
- gui_window_box_scroll_start(html->bw->window,
+
+ root_bw = browser_window_get_root(html->bw);
+ gui_window_box_scroll_start(root_bw->window,
scrollbar_data->x0, scrollbar_data->y0,
scrollbar_data->x1, scrollbar_data->y1);
break;
Modified: trunk/netsurf/render/html_interaction.c
URL: http://source.netsurf-browser.org/trunk/netsurf/render/html_interaction.c...
==============================================================================
--- trunk/netsurf/render/html_interaction.c (original)
+++ trunk/netsurf/render/html_interaction.c Tue Jun 28 16:16:37 2011
@@ -774,6 +774,7 @@
html_content *html = (html_content *)data->c;
struct box *box = data->box;
int x, y, box_x, box_y, diff_x, diff_y;
+ struct browser_window *root_bw;
switch(scrollbar_data->msg) {
@@ -807,7 +808,9 @@
browser_window_set_drag_type(html->bw, DRAGGING_OTHER);
html->scrollbar = scrollbar_data->scrollbar;
- gui_window_box_scroll_start(html->bw->window,
+
+ root_bw = browser_window_get_root(html->bw);
+ gui_window_box_scroll_start(root_bw->window,
scrollbar_data->x0, scrollbar_data->y0,
scrollbar_data->x1, scrollbar_data->y1);
break;
11 years, 11 months
r12532 jmb - in /branches/jmb/dom-alloc-purge/src/core: cdatasection.c cdatasection.h characterdata.c characterdata.h text.c text.h
by netsurf@semichrome.net
Author: jmb
Date: Tue Jun 28 16:12:03 2011
New Revision: 12532
URL: http://source.netsurf-browser.org?rev=12532&view=rev
Log:
Fix up CDATASection
Modified:
branches/jmb/dom-alloc-purge/src/core/cdatasection.c
branches/jmb/dom-alloc-purge/src/core/cdatasection.h
branches/jmb/dom-alloc-purge/src/core/characterdata.c
branches/jmb/dom-alloc-purge/src/core/characterdata.h
branches/jmb/dom-alloc-purge/src/core/text.c
branches/jmb/dom-alloc-purge/src/core/text.h
Modified: branches/jmb/dom-alloc-purge/src/core/cdatasection.c
URL: http://source.netsurf-browser.org/branches/jmb/dom-alloc-purge/src/core/c...
==============================================================================
--- branches/jmb/dom-alloc-purge/src/core/cdatasection.c (original)
+++ branches/jmb/dom-alloc-purge/src/core/cdatasection.c Tue Jun 28 16:12:03 2011
@@ -5,6 +5,8 @@
* Copyright 2007 John-Mark Bell <jmb(a)netsurf-browser.org>
* Copyright 2009 Bo Yang <struggleyb.nku(a)gmail.com>
*/
+
+#include <stdlib.h>
#include "core/cdatasection.h"
#include "core/document.h"
@@ -15,7 +17,7 @@
* A DOM CDATA section
*/
struct dom_cdata_section {
- struct dom_text base; /**< Base node */
+ dom_text base; /**< Base node */
};
static struct dom_node_protect_vtable cdata_section_protect_vtable = {
@@ -36,15 +38,15 @@
*
* The returned node will already be referenced.
*/
-dom_exception _dom_cdata_section_create(struct dom_document *doc,
- struct lwc_string_s *name, dom_string *value,
- struct dom_cdata_section **result)
+dom_exception _dom_cdata_section_create(dom_document *doc,
+ dom_string *name, dom_string *value,
+ dom_cdata_section **result)
{
- struct dom_cdata_section *c;
+ dom_cdata_section *c;
dom_exception err;
/* Allocate the comment node */
- c = _dom_document_alloc(doc, NULL, sizeof(struct dom_cdata_section));
+ c = malloc(sizeof(dom_cdata_section));
if (c == NULL)
return DOM_NO_MEM_ERR;
@@ -56,7 +58,7 @@
err = _dom_cdata_section_initialise(&c->base, doc,
DOM_CDATA_SECTION_NODE, name, value);
if (err != DOM_NO_ERR) {
- _dom_document_alloc(doc, c, 0);
+ free(c);
return err;
}
@@ -68,19 +70,17 @@
/**
* Destroy a CDATA section
*
- * \param doc The owning document
* \param cdata The cdata section to destroy
*
* The contents of ::cdata will be destroyed and ::cdata will be freed.
*/
-void _dom_cdata_section_destroy(struct dom_document *doc,
- struct dom_cdata_section *cdata)
+void _dom_cdata_section_destroy(dom_cdata_section *cdata)
{
/* Clean up base node contents */
- _dom_cdata_section_finalise(doc, &cdata->base);
+ _dom_cdata_section_finalise(&cdata->base);
/* Destroy the node */
- _dom_document_alloc(doc, cdata, 0);
+ free(cdata);
}
/*--------------------------------------------------------------------------*/
@@ -88,35 +88,30 @@
/* The protected virtual functions */
/* The virtual destroy function of this class */
-void __dom_cdata_section_destroy(struct dom_node_internal *node)
+void __dom_cdata_section_destroy(dom_node_internal *node)
{
- struct dom_document *doc;
- doc = dom_node_get_owner(node);
-
- _dom_cdata_section_destroy(doc, (struct dom_cdata_section *) node);
-}
-
-/* The memory allocator of this class */
-dom_exception _dom_cdata_section_alloc(struct dom_document *doc,
- struct dom_node_internal *n, struct dom_node_internal **ret)
-{
- UNUSED(n);
- dom_cdata_section *a;
-
- a = _dom_document_alloc(doc, NULL, sizeof(struct dom_cdata_section));
- if (a == NULL)
- return DOM_NO_MEM_ERR;
-
- *ret = (dom_node_internal *) a;
- dom_node_set_owner(*ret, doc);
-
- return DOM_NO_ERR;
+ _dom_cdata_section_destroy((dom_cdata_section *) node);
}
/* The copy constructor of this class */
-dom_exception _dom_cdata_section_copy(struct dom_node_internal *new,
- struct dom_node_internal *old)
+dom_exception _dom_cdata_section_copy(dom_node_internal *old,
+ dom_node_internal **copy)
{
- return _dom_characterdata_copy(new, old);
+ dom_cdata_section *new_cdata;
+ dom_exception err;
+
+ new_cdata = malloc(sizeof(dom_cdata_section));
+ if (new_cdata == NULL)
+ return DOM_NO_MEM_ERR;
+
+ err = dom_text_copy_internal(old, new_cdata);
+ if (err != DOM_NO_ERR) {
+ free(new_cdata);
+ return err;
+ }
+
+ *copy = (dom_node_internal *) new_cdata;
+
+ return DOM_NO_ERR;
}
Modified: branches/jmb/dom-alloc-purge/src/core/cdatasection.h
URL: http://source.netsurf-browser.org/branches/jmb/dom-alloc-purge/src/core/c...
==============================================================================
--- branches/jmb/dom-alloc-purge/src/core/cdatasection.h (original)
+++ branches/jmb/dom-alloc-purge/src/core/cdatasection.h Tue Jun 28 16:12:03 2011
@@ -13,30 +13,24 @@
#include <dom/core/string.h>
struct dom_node_internal;
-struct dom_cdata_section;
struct dom_document;
-struct lwc_string_s;
dom_exception _dom_cdata_section_create(struct dom_document *doc,
- struct lwc_string_s *name, dom_string *value,
- struct dom_cdata_section **result);
+ dom_string *name, dom_string *value,
+ dom_cdata_section **result);
-void _dom_cdata_section_destroy(struct dom_document *doc,
- struct dom_cdata_section *cdata);
+void _dom_cdata_section_destroy(dom_cdata_section *cdata);
#define _dom_cdata_section_initialise _dom_text_initialise
#define _dom_cdata_section_finalise _dom_text_finalise
/* Following comes the protected vtable */
void __dom_cdata_section_destroy(struct dom_node_internal *node);
-dom_exception _dom_cdata_section_alloc(struct dom_document *doc,
- struct dom_node_internal *n, struct dom_node_internal **ret);
-dom_exception _dom_cdata_section_copy(struct dom_node_internal *new,
- struct dom_node_internal *old);
+dom_exception _dom_cdata_section_copy(struct dom_node_internal *old,
+ struct dom_node_internal **copy);
#define DOM_CDATA_SECTION_PROTECT_VTABLE \
__dom_cdata_section_destroy, \
- _dom_cdata_section_alloc, \
_dom_cdata_section_copy
#endif
Modified: branches/jmb/dom-alloc-purge/src/core/characterdata.c
URL: http://source.netsurf-browser.org/branches/jmb/dom-alloc-purge/src/core/c...
==============================================================================
--- branches/jmb/dom-alloc-purge/src/core/characterdata.c (original)
+++ branches/jmb/dom-alloc-purge/src/core/characterdata.c Tue Jun 28 16:12:03 2011
@@ -477,8 +477,8 @@
return DOM_NO_ERR;
}
-dom_exception _dom_characterdata_copy_internal(dom_node_internal *old,
- dom_node_internal *new)
+dom_exception _dom_characterdata_copy_internal(dom_characterdata *old,
+ dom_characterdata *new)
{
return dom_node_copy_internal(old, new);
}
Modified: branches/jmb/dom-alloc-purge/src/core/characterdata.h
URL: http://source.netsurf-browser.org/branches/jmb/dom-alloc-purge/src/core/c...
==============================================================================
--- branches/jmb/dom-alloc-purge/src/core/characterdata.h (original)
+++ branches/jmb/dom-alloc-purge/src/core/characterdata.h Tue Jun 28 16:12:03 2011
@@ -72,10 +72,10 @@
extern struct dom_characterdata_vtable characterdata_vtable;
-dom_exception _dom_characterdata_copy_internal(dom_node_internal *old,
- dom_node_internal *new);
+dom_exception _dom_characterdata_copy_internal(dom_characterdata *old,
+ dom_characterdata *new);
#define dom_characterdata_copy_internal(o, n) \
_dom_characterdata_copy_internal( \
- (dom_node_internal *) (o), (dom_node_internal *) (n))
+ (dom_characterdata *) (o), (dom_characterdata *) (n))
#endif
Modified: branches/jmb/dom-alloc-purge/src/core/text.c
URL: http://source.netsurf-browser.org/branches/jmb/dom-alloc-purge/src/core/t...
==============================================================================
--- branches/jmb/dom-alloc-purge/src/core/text.c (original)
+++ branches/jmb/dom-alloc-purge/src/core/text.c Tue Jun 28 16:12:03 2011
@@ -69,15 +69,15 @@
*
* The returned node will already be referenced.
*/
-dom_exception _dom_text_create(struct dom_document *doc,
+dom_exception _dom_text_create(dom_document *doc,
dom_string *name, dom_string *value,
- struct dom_text **result)
-{
- struct dom_text *t;
+ dom_text **result)
+{
+ dom_text *t;
dom_exception err;
/* Allocate the text node */
- t = malloc(sizeof(struct dom_text));
+ t = malloc(sizeof(dom_text));
if (t == NULL)
return DOM_NO_MEM_ERR;
@@ -89,8 +89,8 @@
}
/* Compose the vtable */
- ((struct dom_node *) t)->vtable = &text_vtable;
- ((struct dom_node_internal *) t)->vtable = &text_protect_vtable;
+ ((dom_node *) t)->vtable = &text_vtable;
+ ((dom_node_internal *) t)->vtable = &text_protect_vtable;
*result = t;
@@ -105,7 +105,7 @@
*
* The contents of ::text will be destroyed and ::text will be freed.
*/
-void _dom_text_destroy(struct dom_text *text)
+void _dom_text_destroy(dom_text *text)
{
/* Finalise node */
_dom_text_finalise(text);
@@ -126,8 +126,8 @@
*
* ::doc, ::name and ::value will have their reference counts increased.
*/
-dom_exception _dom_text_initialise(struct dom_text *text,
- struct dom_document *doc, dom_node_type type,
+dom_exception _dom_text_initialise(dom_text *text,
+ dom_document *doc, dom_node_type type,
dom_string *name, dom_string *value)
{
dom_exception err;
@@ -152,7 +152,7 @@
*
* The contents of ::text will be cleaned up. ::text will not be freed.
*/
-void _dom_text_finalise(struct dom_text *text)
+void _dom_text_finalise(dom_text *text)
{
_dom_characterdata_finalise(&text->base);
}
@@ -174,12 +174,12 @@
* The returned node will be referenced. The client should unref the node
* once it has finished with it.
*/
-dom_exception _dom_text_split_text(struct dom_text *text,
- unsigned long offset, struct dom_text **result)
-{
- struct dom_node_internal *t = (struct dom_node_internal *) text;
+dom_exception _dom_text_split_text(dom_text *text,
+ unsigned long offset, dom_text **result)
+{
+ dom_node_internal *t = (dom_node_internal *) text;
dom_string *value;
- struct dom_text *res;
+ dom_text *res;
unsigned long len;
dom_exception err;
@@ -234,7 +234,7 @@
* \return DOM_NO_ERR.
*/
dom_exception _dom_text_get_is_element_content_whitespace(
- struct dom_text *text, bool *result)
+ dom_text *text, bool *result)
{
*result = text->element_content_whitespace;
@@ -248,7 +248,7 @@
* \param result Pointer to location to receive result
* \return DOM_NO_ERR.
*/
-dom_exception _dom_text_get_whole_text(struct dom_text *text,
+dom_exception _dom_text_get_whole_text(dom_text *text,
dom_string **result)
{
return walk_logic_adjacent_text(text, COLLECT, result);
@@ -267,8 +267,8 @@
* The returned node will be referenced. The client should unref the node
* once it has finished with it.
*/
-dom_exception _dom_text_replace_whole_text(struct dom_text *text,
- dom_string *content, struct dom_text **result)
+dom_exception _dom_text_replace_whole_text(dom_text *text,
+ dom_string *content, dom_text **result)
{
dom_exception err;
dom_string *ret;
@@ -291,15 +291,14 @@
/* The protected virtual functions */
/* The destroy function of this class */
-void __dom_text_destroy(struct dom_node_internal *node)
-{
- _dom_text_destroy((struct dom_text *) node);
+void __dom_text_destroy(dom_node_internal *node)
+{
+ _dom_text_destroy((dom_text *) node);
}
/* The copy constructor of this class */
dom_exception _dom_text_copy(dom_node_internal *old, dom_node_internal **copy)
{
- dom_text *ot = (dom_text *) old;
dom_text *new_text;
dom_exception err;
@@ -307,15 +306,26 @@
if (new_text == NULL)
return DOM_NO_MEM_ERR;
- err = dom_characterdata_copy_internal(old, new_text);
+ err = dom_text_copy_internal(old, new_text);
if (err != DOM_NO_ERR) {
free(new_text);
return err;
}
- new_text->element_content_whitespace = ot->element_content_whitespace;
-
*copy = (dom_node_internal *) new_text;
+
+ return DOM_NO_ERR;
+}
+
+dom_exception _dom_text_copy_internal(dom_text *old, dom_text *new)
+{
+ dom_exception err;
+
+ err = dom_characterdata_copy_internal(old, new);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ new->element_content_whitespace = old->element_content_whitespace;
return DOM_NO_ERR;
}
Modified: branches/jmb/dom-alloc-purge/src/core/text.h
URL: http://source.netsurf-browser.org/branches/jmb/dom-alloc-purge/src/core/t...
==============================================================================
--- branches/jmb/dom-alloc-purge/src/core/text.h (original)
+++ branches/jmb/dom-alloc-purge/src/core/text.h Tue Jun 28 16:12:03 2011
@@ -11,17 +11,17 @@
#include <stdbool.h>
#include <dom/core/exceptions.h>
+#include <dom/core/text.h>
#include "core/characterdata.h"
struct dom_document;
-struct lwc_string_s;
/**
* A DOM text node
*/
struct dom_text {
- struct dom_characterdata base; /**< Base node */
+ dom_characterdata base; /**< Base node */
bool element_content_whitespace; /**< This node is element
* content whitespace */
@@ -30,26 +30,26 @@
/* Constructor and Destructor */
dom_exception _dom_text_create(struct dom_document *doc,
dom_string *name, dom_string *value,
- struct dom_text **result);
+ dom_text **result);
-void _dom_text_destroy(struct dom_text *text);
+void _dom_text_destroy(dom_text *text);
-dom_exception _dom_text_initialise(struct dom_text *text,
+dom_exception _dom_text_initialise(dom_text *text,
struct dom_document *doc, dom_node_type type,
dom_string *name, dom_string *value);
-void _dom_text_finalise(struct dom_text *text);
+void _dom_text_finalise(dom_text *text);
/* Virtual functions for dom_text */
-dom_exception _dom_text_split_text(struct dom_text *text,
- unsigned long offset, struct dom_text **result);
+dom_exception _dom_text_split_text(dom_text *text,
+ unsigned long offset, dom_text **result);
dom_exception _dom_text_get_is_element_content_whitespace(
- struct dom_text *text, bool *result);
-dom_exception _dom_text_get_whole_text(struct dom_text *text,
+ dom_text *text, bool *result);
+dom_exception _dom_text_get_whole_text(dom_text *text,
dom_string **result);
-dom_exception _dom_text_replace_whole_text(struct dom_text *text,
- dom_string *content, struct dom_text **result);
+dom_exception _dom_text_replace_whole_text(dom_text *text,
+ dom_string *content, dom_text **result);
#define DOM_TEXT_VTABLE \
_dom_text_split_text, \
@@ -60,15 +60,16 @@
/* Following comes the protected vtable */
void __dom_text_destroy(struct dom_node_internal *node);
-dom_exception _dom_text_alloc(struct dom_document *doc,
- struct dom_node_internal *n, struct dom_node_internal **ret);
dom_exception _dom_text_copy(dom_node_internal *old, dom_node_internal **copy);
#define DOM_TEXT_PROTECT_VTABLE \
__dom_text_destroy, \
_dom_text_copy
-
extern struct dom_text_vtable text_vtable;
+dom_exception _dom_text_copy_internal(dom_text *old, dom_text *new);
+#define dom_text_copy_internal(o, n) \
+ _dom_text_copy_internal((dom_text *) (o), (dom_text *) (n))
+
#endif
11 years, 11 months
r12531 tlsa - in /trunk/netsurf/desktop: browser.c browser.h
by netsurf@semichrome.net
Author: tlsa
Date: Tue Jun 28 16:09:57 2011
New Revision: 12531
URL: http://source.netsurf-browser.org?rev=12531&view=rev
Log:
Function to get root browser window.
Modified:
trunk/netsurf/desktop/browser.c
trunk/netsurf/desktop/browser.h
Modified: trunk/netsurf/desktop/browser.c
URL: http://source.netsurf-browser.org/trunk/netsurf/desktop/browser.c?rev=125...
==============================================================================
--- trunk/netsurf/desktop/browser.c (original)
+++ trunk/netsurf/desktop/browser.c Tue Jun 28 16:09:57 2011
@@ -244,6 +244,15 @@
bw->drag_type = type;
}
+/* exported interface, documented in browser.h */
+struct browser_window * browser_window_get_root(struct browser_window *bw)
+{
+ while (bw && !bw->window && bw->parent) {
+ bw = bw->parent;
+ }
+ return bw;
+}
+
/**
* Create and open a new root browser window with the given page.
*
@@ -283,10 +292,7 @@
/* gui window */
/* from the front end's pov, it clones the top level browser window,
* so find that. */
- top = clone;
- while (top && !top->window && top->parent) {
- top = top->parent;
- }
+ top = browser_window_get_root(clone);
bw->window = gui_create_browser_window(bw, top, new_tab);
@@ -1051,10 +1057,7 @@
case BROWSER_WINDOW_IFRAME:
browser_window_get_position(bw, true, &pos_x, &pos_y);
- top = bw;
- while (top && !top->window && top->parent) {
- top = top->parent;
- }
+ top = browser_window_get_root(bw);
/* TODO: update gui_window_update_box so it takes a struct rect
* instead of msg data. */
@@ -1213,11 +1216,7 @@
void browser_window_set_pointer(struct browser_window *bw,
gui_pointer_shape shape)
{
- struct browser_window *root = bw;
-
- while (root && !root->window && root->parent) {
- root = root->parent;
- }
+ struct browser_window *root = browser_window_get_root(bw);
assert(root);
assert(root->window);
@@ -1291,10 +1290,7 @@
/* If this brower window is not the root window, and has focus, unset
* the root browser window's focus pointer. */
if (!bw->window) {
- struct browser_window *top = bw;
-
- while (top && !top->window && top->parent)
- top = top->parent;
+ struct browser_window *top = browser_window_get_root(bw);
if (top->focus == bw)
top->focus = top;
@@ -1737,9 +1733,7 @@
return;
/* Set focus browser window */
- top = bw;
- while (top && !top->window && top->parent)
- top = top->parent;
+ top = browser_window_get_root(bw);
top->focus = bw;
selection_set_browser_window(bw->sel, bw);
Modified: trunk/netsurf/desktop/browser.h
URL: http://source.netsurf-browser.org/trunk/netsurf/desktop/browser.h?rev=125...
==============================================================================
--- trunk/netsurf/desktop/browser.h (original)
+++ trunk/netsurf/desktop/browser.h Tue Jun 28 16:09:57 2011
@@ -330,6 +330,14 @@
void browser_window_set_drag_type(struct browser_window *bw,
browser_drag_type type);
+/*
+ * Get the root level browser window
+ *
+ * \param bw browser window to set the type of the current drag for
+ * \return root browser window
+ */
+struct browser_window * browser_window_get_root(struct browser_window *bw);
+
/* In platform specific hotlist.c. */
void hotlist_visited(struct hlcache_handle *c);
11 years, 11 months