r3390 rjek - in /trunk/netsurf/gtk: gtk_scaffolding.c gtk_scaffolding.h gtk_window.c res/netsurf.glade
by netsurf@semichrome.net
Author: rjek
Date: Mon Jul 9 14:49:58 2007
New Revision: 3390
URL: http://source.netsurf-browser.org?rev=3390&view=rev
Log:
Add popup version of main menu bar to nsgtk, accessable via right-mouse button
Modified:
trunk/netsurf/gtk/gtk_scaffolding.c
trunk/netsurf/gtk/gtk_scaffolding.h
trunk/netsurf/gtk/gtk_window.c
trunk/netsurf/gtk/res/netsurf.glade
Modified: trunk/netsurf/gtk/gtk_scaffolding.c
URL: http://source.netsurf-browser.org/trunk/netsurf/gtk/gtk_scaffolding.c?rev...
==============================================================================
--- trunk/netsurf/gtk/gtk_scaffolding.c (original)
+++ trunk/netsurf/gtk/gtk_scaffolding.c Mon Jul 9 14:49:58 2007
@@ -59,6 +59,9 @@
GladeXML *xml;
+ GladeXML *popup_xml;
+ GtkMenu *popup_menu;
+
struct gtk_history_window *history_window;
int throb_frame;
@@ -757,6 +760,22 @@
g->being_destroyed = 0;
g->fullscreen = false;
+
+ /* create the popup version of the menu */
+ g->popup_xml = glade_xml_new(glade_file_location, "menuPopup", NULL);
+ g->popup_menu = GTK_MENU(glade_xml_get_widget(g->popup_xml, "menuPopup"));
+
+#define POPUP_ATTACH(x, y) gtk_menu_item_set_submenu( \
+ GTK_MENU_ITEM(glade_xml_get_widget(g->popup_xml, x)),\
+ GTK_WIDGET(glade_xml_get_widget(g->xml, y)))
+
+ POPUP_ATTACH("menupopup_file", "menumain_file");
+ POPUP_ATTACH("menupopup_edit", "menumain_edit");
+ POPUP_ATTACH("menupopup_view", "menumain_view");
+ POPUP_ATTACH("menupopup_navigate", "menumain_navigate");
+ POPUP_ATTACH("menupopup_help", "menumain_help");
+
+#undef POPUP_ATTACH
/* finally, show the window. */
gtk_widget_show(GTK_WIDGET(g->window));
@@ -833,3 +852,9 @@
/* We are considered "busy" if the stop button is sensitive */
return GTK_WIDGET_SENSITIVE((GTK_WIDGET(scaffold->stop_button)));
}
+
+void nsgtk_scaffolding_popup_menu(nsgtk_scaffolding *g, guint button)
+{
+ printf("foo.\n");
+ gtk_menu_popup(g->popup_menu, NULL, NULL, NULL, NULL, button, 0);
+}
Modified: trunk/netsurf/gtk/gtk_scaffolding.h
URL: http://source.netsurf-browser.org/trunk/netsurf/gtk/gtk_scaffolding.h?rev...
==============================================================================
--- trunk/netsurf/gtk/gtk_scaffolding.h (original)
+++ trunk/netsurf/gtk/gtk_scaffolding.h Mon Jul 9 14:49:58 2007
@@ -22,4 +22,6 @@
void nsgtk_scaffolding_destroy(nsgtk_scaffolding *scaffold);
+void nsgtk_scaffolding_popup_menu(nsgtk_scaffolding *g, guint button);
+
#endif /* NETSURF_GTK_SCAFFOLDING_H */
Modified: trunk/netsurf/gtk/gtk_window.c
URL: http://source.netsurf-browser.org/trunk/netsurf/gtk/gtk_window.c?rev=3390...
==============================================================================
--- trunk/netsurf/gtk/gtk_window.c (original)
+++ trunk/netsurf/gtk/gtk_window.c Mon Jul 9 14:49:58 2007
@@ -334,8 +334,11 @@
if (event->button == 2) /* 2 == middle button on X */
button = BROWSER_MOUSE_CLICK_2;
- if (event->button == 3) /* 3 == right button on X */
- return TRUE; /* Do nothing for right click for now */
+ if (event->button == 3) {
+ /* 3 == right button on X */
+ nsgtk_scaffolding_popup_menu(g->scaffold, event->button);
+ return TRUE;
+ }
browser_window_mouse_click(g->bw, button,
event->x / g->scale, event->y / g->scale);
Modified: trunk/netsurf/gtk/res/netsurf.glade
URL: http://source.netsurf-browser.org/trunk/netsurf/gtk/res/netsurf.glade?rev...
==============================================================================
--- trunk/netsurf/gtk/res/netsurf.glade (original)
+++ trunk/netsurf/gtk/res/netsurf.glade Mon Jul 9 14:49:58 2007
@@ -37,7 +37,7 @@
<property name="use_underline">True</property>
<child>
- <widget class="GtkMenu" id="menuitem4_menu">
+ <widget class="GtkMenu" id="menumain_file">
<child>
<widget class="GtkImageMenuItem" id="new_window">
@@ -262,7 +262,7 @@
<property name="use_underline">True</property>
<child>
- <widget class="GtkMenu" id="menuitem5_menu">
+ <widget class="GtkMenu" id="menumain_edit">
<child>
<widget class="GtkImageMenuItem" id="cut">
@@ -372,7 +372,7 @@
<property name="use_underline">True</property>
<child>
- <widget class="GtkMenu" id="menuitem6_menu">
+ <widget class="GtkMenu" id="menumain_view">
<child>
<widget class="GtkImageMenuItem" id="stop">
@@ -667,13 +667,13 @@
</child>
<child>
- <widget class="GtkMenuItem" id="navigate">
+ <widget class="GtkMenuItem" id="menuitem7">
<property name="visible">True</property>
<property name="label" translatable="yes">_Navigate</property>
<property name="use_underline">True</property>
<child>
- <widget class="GtkMenu" id="navigate_menu">
+ <widget class="GtkMenu" id="menumain_navigate">
<child>
<widget class="GtkImageMenuItem" id="back">
@@ -796,13 +796,13 @@
</child>
<child>
- <widget class="GtkMenuItem" id="help">
+ <widget class="GtkMenuItem" id="menuitem8">
<property name="visible">True</property>
<property name="label" translatable="yes">_Help</property>
<property name="use_underline">True</property>
<child>
- <widget class="GtkMenu" id="help_menu">
+ <widget class="GtkMenu" id="menumain_help">
<child>
<widget class="GtkImageMenuItem" id="contents">
@@ -5545,4 +5545,57 @@
</child>
</widget>
+<widget class="GtkMenu" id="menuPopup">
+
+ <child>
+ <widget class="GtkMenuItem" id="menupopup_file">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">File</property>
+ <property name="use_underline">True</property>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkMenuItem" id="menupopup_object">
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="label" translatable="yes">Object</property>
+ <property name="use_underline">True</property>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkMenuItem" id="menupopup_edit">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Edit</property>
+ <property name="use_underline">True</property>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkMenuItem" id="menupopup_view">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">View</property>
+ <property name="use_underline">True</property>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkMenuItem" id="menupopup_navigate">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Navigate</property>
+ <property name="use_underline">True</property>
+ <signal name="activate" handler="on_menupopup_navigate_activate" last_modification_time="Mon, 09 Jul 2007 13:07:30 GMT"/>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkMenuItem" id="menupopup_help">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Help</property>
+ <property name="use_underline">True</property>
+ </widget>
+ </child>
+</widget>
+
</glade-interface>
16 years, 2 months
r3389 jmb - in /trunk/netsurf/gtk: gtk_scaffolding.c res/netsurf.glade
by netsurf@semichrome.net
Author: jmb
Date: Mon Jul 9 13:49:22 2007
New Revision: 3389
URL: http://source.netsurf-browser.org?rev=3389&view=rev
Log:
Ctrl+F11 -> fullscreen (nsgtk only)
Modified:
trunk/netsurf/gtk/gtk_scaffolding.c
trunk/netsurf/gtk/res/netsurf.glade
Modified: trunk/netsurf/gtk/gtk_scaffolding.c
URL: http://source.netsurf-browser.org/trunk/netsurf/gtk/gtk_scaffolding.c?rev...
==============================================================================
--- trunk/netsurf/gtk/gtk_scaffolding.c (original)
+++ trunk/netsurf/gtk/gtk_scaffolding.c Mon Jul 9 13:49:22 2007
@@ -64,6 +64,8 @@
int throb_frame;
struct gui_window *top_level;
int being_destroyed;
+
+ bool fullscreen;
};
struct gtk_history_window {
@@ -121,6 +123,7 @@
MENUPROTO(zoom_in);
MENUPROTO(normal_size);
MENUPROTO(zoom_out);
+MENUPROTO(full_screen);
MENUPROTO(save_window_size);
MENUPROTO(toggle_debug_rendering);
@@ -154,6 +157,7 @@
MENUEVENT(zoom_in),
MENUEVENT(normal_size),
MENUEVENT(zoom_out),
+ MENUEVENT(full_screen),
MENUEVENT(save_window_size),
MENUEVENT(toggle_debug_rendering),
@@ -437,6 +441,21 @@
float old_scale = nsgtk_get_scale_for_gui(gw->top_level);
browser_window_set_scale(bw, old_scale - 0.05, true);
+
+ return TRUE;
+}
+
+MENUHANDLER(full_screen)
+{
+ struct gtk_scaffolding *gw = (struct gtk_scaffolding *)g;
+
+ if (gw->fullscreen) {
+ gtk_window_unfullscreen(gw->window);
+ } else {
+ gtk_window_fullscreen(gw->window);
+ }
+
+ gw->fullscreen = !gw->fullscreen;
return TRUE;
}
@@ -737,6 +756,8 @@
g->being_destroyed = 0;
+ g->fullscreen = false;
+
/* finally, show the window. */
gtk_widget_show(GTK_WIDGET(g->window));
Modified: trunk/netsurf/gtk/res/netsurf.glade
URL: http://source.netsurf-browser.org/trunk/netsurf/gtk/res/netsurf.glade?rev...
==============================================================================
--- trunk/netsurf/gtk/res/netsurf.glade (original)
+++ trunk/netsurf/gtk/res/netsurf.glade Mon Jul 9 13:49:22 2007
@@ -48,7 +48,7 @@
<accelerator key="N" modifiers="GDK_CONTROL_MASK" signal="activate"/>
<child internal-child="image">
- <widget class="GtkImage" id="image501">
+ <widget class="GtkImage" id="image520">
<property name="visible">True</property>
<property name="stock">gtk-new</property>
<property name="icon_size">1</property>
@@ -80,7 +80,7 @@
<accelerator key="F" modifiers="GDK_CONTROL_MASK" signal="activate"/>
<child internal-child="image">
- <widget class="GtkImage" id="image502">
+ <widget class="GtkImage" id="image521">
<property name="visible">True</property>
<property name="stock">gtk-open</property>
<property name="icon_size">1</property>
@@ -102,7 +102,7 @@
<accelerator key="W" modifiers="GDK_CONTROL_MASK | GDK_SHIFT_MASK" signal="activate"/>
<child internal-child="image">
- <widget class="GtkImage" id="image503">
+ <widget class="GtkImage" id="image522">
<property name="visible">True</property>
<property name="stock">gtk-close</property>
<property name="icon_size">1</property>
@@ -131,7 +131,7 @@
<accelerator key="S" modifiers="GDK_CONTROL_MASK" signal="activate"/>
<child internal-child="image">
- <widget class="GtkImage" id="image504">
+ <widget class="GtkImage" id="image523">
<property name="visible">True</property>
<property name="stock">gtk-save-as</property>
<property name="icon_size">1</property>
@@ -201,7 +201,7 @@
<property name="use_underline">True</property>
<child internal-child="image">
- <widget class="GtkImage" id="image505">
+ <widget class="GtkImage" id="image524">
<property name="visible">True</property>
<property name="stock">gtk-print-preview</property>
<property name="icon_size">1</property>
@@ -224,7 +224,7 @@
<accelerator key="P" modifiers="GDK_CONTROL_MASK" signal="activate"/>
<child internal-child="image">
- <widget class="GtkImage" id="image506">
+ <widget class="GtkImage" id="image525">
<property name="visible">True</property>
<property name="stock">gtk-print</property>
<property name="icon_size">1</property>
@@ -348,7 +348,7 @@
<property name="use_underline">True</property>
<child internal-child="image">
- <widget class="GtkImage" id="image507">
+ <widget class="GtkImage" id="image526">
<property name="visible">True</property>
<property name="stock">gtk-preferences</property>
<property name="icon_size">1</property>
@@ -382,7 +382,7 @@
<accelerator key="Escape" modifiers="0" signal="activate"/>
<child internal-child="image">
- <widget class="GtkImage" id="image508">
+ <widget class="GtkImage" id="image527">
<property name="visible">True</property>
<property name="stock">gtk-stop</property>
<property name="icon_size">1</property>
@@ -403,7 +403,7 @@
<accelerator key="F5" modifiers="0" signal="activate"/>
<child internal-child="image">
- <widget class="GtkImage" id="image509">
+ <widget class="GtkImage" id="image528">
<property name="visible">True</property>
<property name="stock">gtk-refresh</property>
<property name="icon_size">1</property>
@@ -431,7 +431,7 @@
<accelerator key="F11" modifiers="0" signal="activate"/>
<child internal-child="image">
- <widget class="GtkImage" id="image510">
+ <widget class="GtkImage" id="image529">
<property name="visible">True</property>
<property name="stock">gtk-zoom-in</property>
<property name="icon_size">1</property>
@@ -453,7 +453,7 @@
<accelerator key="plus" modifiers="GDK_CONTROL_MASK" signal="activate"/>
<child internal-child="image">
- <widget class="GtkImage" id="image511">
+ <widget class="GtkImage" id="image530">
<property name="visible">True</property>
<property name="stock">gtk-zoom-in</property>
<property name="icon_size">1</property>
@@ -474,7 +474,7 @@
<accelerator key="0" modifiers="GDK_CONTROL_MASK" signal="activate"/>
<child internal-child="image">
- <widget class="GtkImage" id="image512">
+ <widget class="GtkImage" id="image531">
<property name="visible">True</property>
<property name="stock">gtk-zoom-100</property>
<property name="icon_size">1</property>
@@ -495,7 +495,7 @@
<accelerator key="minus" modifiers="GDK_CONTROL_MASK" signal="activate"/>
<child internal-child="image">
- <widget class="GtkImage" id="image513">
+ <widget class="GtkImage" id="image532">
<property name="visible">True</property>
<property name="stock">gtk-zoom-out</property>
<property name="icon_size">1</property>
@@ -513,6 +513,33 @@
</child>
<child>
+ <widget class="GtkImageMenuItem" id="full_screen">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Fullscreen</property>
+ <property name="use_underline">True</property>
+ <accelerator key="F11" modifiers="GDK_CONTROL_MASK" signal="activate"/>
+
+ <child internal-child="image">
+ <widget class="GtkImage" id="image533">
+ <property name="visible">True</property>
+ <property name="stock">gtk-fullscreen</property>
+ <property name="icon_size">1</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ </child>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkSeparatorMenuItem" id="separator12">
+ <property name="visible">True</property>
+ </widget>
+ </child>
+
+ <child>
<widget class="GtkMenuItem" id="images">
<property name="visible">True</property>
<property name="sensitive">False</property>
@@ -656,7 +683,7 @@
<accelerator key="Left" modifiers="GDK_MOD1_MASK" signal="activate"/>
<child internal-child="image">
- <widget class="GtkImage" id="image514">
+ <widget class="GtkImage" id="image534">
<property name="visible">True</property>
<property name="stock">gtk-go-back</property>
<property name="icon_size">1</property>
@@ -677,7 +704,7 @@
<accelerator key="Right" modifiers="GDK_MOD1_MASK" signal="activate"/>
<child internal-child="image">
- <widget class="GtkImage" id="image515">
+ <widget class="GtkImage" id="image535">
<property name="visible">True</property>
<property name="stock">gtk-go-forward</property>
<property name="icon_size">1</property>
@@ -698,7 +725,7 @@
<accelerator key="Home" modifiers="GDK_MOD1_MASK" signal="activate"/>
<child internal-child="image">
- <widget class="GtkImage" id="image516">
+ <widget class="GtkImage" id="image536">
<property name="visible">True</property>
<property name="stock">gtk-home</property>
<property name="icon_size">1</property>
@@ -787,7 +814,7 @@
<accelerator key="F1" modifiers="0" signal="activate"/>
<child internal-child="image">
- <widget class="GtkImage" id="image517">
+ <widget class="GtkImage" id="image537">
<property name="visible">True</property>
<property name="stock">gtk-help</property>
<property name="icon_size">1</property>
16 years, 2 months
r3388 tlsa - in /trunk/netsurfweb: builds/top.de download/index.de index.de info.de
by netsurf@semichrome.net
Author: tlsa
Date: Mon Jul 9 09:08:54 2007
New Revision: 3388
URL: http://source.netsurf-browser.org?rev=3388&view=rev
Log:
Update German translations. Thanks to Sebastian Barthel.
Modified:
trunk/netsurfweb/builds/top.de
trunk/netsurfweb/download/index.de
trunk/netsurfweb/index.de
trunk/netsurfweb/info.de
Modified: trunk/netsurfweb/builds/top.de
URL: http://source.netsurf-browser.org/trunk/netsurfweb/builds/top.de?rev=3388...
==============================================================================
--- trunk/netsurfweb/builds/top.de (original)
+++ trunk/netsurfweb/builds/top.de Mon Jul 9 09:08:54 2007
@@ -15,7 +15,8 @@
<p>Diese Dateien werden automatisch aus dem SVN Quellcode erzeugt.
<strong>Sie sind als instabil anzusehen und können jederzeit zum Absturz des Computers führen.</strong></p>
-<p id="newtonetsurf"><strong>Ganz neu bei NetSurf ?</strong> Lade <span class="highlight">NetSurf</span> von hier und dazu die <span class="highlight">fünf unten aufgeführten Dateien</span>.</p>
+<p id="newtonetsurf"><strong>Ganz neu bei NetSurf ?</strong> Lade <span class="highlight">NetSurf</span> von hier und lies die <a
+href="/info#GettingStartedInstallation">Installationsanweisungen</a>.</p>
<table class="download">
<tr><th class="highlight"><a href="netsurf.zip"><img src="netsurf.png" alt=""><br>NetSurf</a></th>
@@ -44,16 +45,23 @@
<h2>Zusätzlich wird benötigt:</h2>
+<p>NetSurf verwendet verschiedene Zusatzprogramme. Diese müssen auf dem System vorhanden sein, um NetSurf zu starten.</p>
+
<ul>
<li>WindowManager 3.80 (oder höher). Ist ab RISC OS 4 Betriebssystembestandteil, für Systeme mit RISC OS 3 sollte die <a href="http://acorn.riscos.com/riscos/releases/UniBoot/" class="highlight">Universal Boot Sequence</a> installiert werden.</li>
+</ul>
+
+<p>Die folgenden Module werden mit NetSurf 'mitgeliefert' :</p>
+
+<ul>
+<li><a href="http://sudden.recoil.org/others/"
+ class="highlight">AcornURI</a> v1.04, Christian Ludlam.</li>
+<li><a href="/iconv/"
+ class="highlight">Iconv</a> v0.08, John-Mark Bell.</li>
<li><a href="http://www.riscos.info/downloads/gccsdk/sharedunixlib/system.zip"
- class="highlight">SharedUnixLibrary</a>.</li>
-<li><a href="http://sudden.recoil.org/others/"
- class="highlight">AcornURI</a>.</li>
-<li><a href="/iconv/"
- class="highlight">Iconv</a>. (Bitte die Installationsanleitung beachten.)</li>
+ class="highlight">SharedUnixLibrary</a> v1.10, GCCSDK Team.</li>
<li><a href="http://www.tinct.net/tinct.asp"
- class="highlight">Tinct</a>.</li>
+ class="highlight">Tinct</a> v0.13, Richard Wilson.</li>
</ul>
<p><strong>Optional:</strong> Eine <a href="http://www.beebware.com/software/mappings/">MimeMap Datei</a> sollte installiert werden, wenn noch keine auf dem Rechner vorhanden ist und Netsurf dies meldet.</p>
Modified: trunk/netsurfweb/download/index.de
URL: http://source.netsurf-browser.org/trunk/netsurfweb/download/index.de?rev=...
==============================================================================
--- trunk/netsurfweb/download/index.de (original)
+++ trunk/netsurfweb/download/index.de Mon Jul 9 09:08:54 2007
@@ -10,7 +10,7 @@
<p class="banner"><a href="/"><img src="/netsurf.png" alt="NetSurf: Web Browser for RISC OS"></a></p>
<p class="languages">Deutsch · <a href="index.en">English</a></p>
-<h1>Download NetSurf</h1>
+<h1>NetSurf herunterladen</h1>
<p id="newtonetsurf"><strong>Neu bei NetSurf?</strong> Lade
<span class="highlight">NetSurf</span> von hier herunter und lies die <a
Modified: trunk/netsurfweb/index.de
URL: http://source.netsurf-browser.org/trunk/netsurfweb/index.de?rev=3388&r1=3...
==============================================================================
--- trunk/netsurfweb/index.de (original)
+++ trunk/netsurfweb/index.de Mon Jul 9 09:08:54 2007
@@ -7,7 +7,7 @@
</head>
<body>
-<h1 class="banner"><img src="netsurf.png" alt="NetSurf"></h1>
+<h1 class="banner"><img src="netsurf.png" alt="NetSurf: Web-Browser für RISC OS"></h1>
<p class="languages">Deutsch · <a href="index.en">English</a> · <a href="index.fr">Français</a> · <a href="index.nl">Nederlands</a></p>
<div class="main">
@@ -16,10 +16,10 @@
<p>NetSurf ist ein Open-Source Web-Browser für RISC OS und wird unter der <a href="licence">GPL</a> lizensiert. Ziel dieses Projektes ist es, die Standards HTML 4 und CSS auf der RISC OS Plattform zur Verfügung zu stellen. NetSurf ist ein schlankes, schnelles und einfach zu bedienendes Programm.</p>
-<p>Die aktuelle Programmversion ist Version 1.0 .<strong>
-<a href="download/">Downloaden von NetSurf 1.0 für RISC OS</a>.</strong></p>
+<p>Die aktuelle Programmversion ist Version 1.0.<strong>
+<a href="download/">Herunterladen von NetSurf 1.0 für RISC OS</a>.</strong></p>
-<p>NetSurf befindet sich in stetiger Entwicklung auch wenn bisher noch keine Vollversion veröffentlicht wurde. Testversionen stehen zum <a href="builds/">Download</a> bereit. Diese werden automatisch aller 15 Minuten aus dem Quellcode auf <a href="http://source.netsurf-browser.org/trunk/netsurf/">Subversion</a> erzeugt.</p>
+<p><a href="builds/">Testversionen</a> stehen ebenfalls zum Download bereit. Diese werden automatisch aller 15 Minuten aus dem Quellcode auf <a href="http://source.netsurf-browser.org/trunk/netsurf/">Subversion</a> erzeugt.</p>
<p>Bitte probiere NetSurf regelmäßig aus und gib uns ein <a href="info#ContactDevelopers">Feedback</a>. Genaue Informationen zum <a href="progress">Stand der Entwicklung</a> gibt es auf der gleichnamigen Seite.</p>
Modified: trunk/netsurfweb/info.de
URL: http://source.netsurf-browser.org/trunk/netsurfweb/info.de?rev=3388&r1=33...
==============================================================================
--- trunk/netsurfweb/info.de (original)
+++ trunk/netsurfweb/info.de Mon Jul 9 09:08:54 2007
@@ -31,7 +31,7 @@
<li><a href="#JavaScript">JavaScript</a></li>
</ul>
-<p class="updated">aktualisiert am 6. Mai 2006</p>
+<p class="updated">aktualisiert am 3. Juli 2007</p>
<h2 id="GettingStarted">Einfach beginnen</h2>
@@ -39,25 +39,43 @@
<p>Die jeweils aktuellste Version kann von der <a href="http://netsurf-browser.org/">Webseite des Projektes</a> geladen werden. Es gibt verschiedene Varianten des Programmes. Für die allermeisten Benutzer ist "NetSurf" der empfehlenswerteste Download. Daneben gibt es mit "NetSurf small build" eine für Systeme mit geringem Speicherplatz geeignete Programmversion. Diese bietet jedoch nur einen eingeschränkten Funktionsumfang.</p>
-<p>Zur Installation von "NetSurf" oder "NetSurf small build" wird die heruntergeladene Datei mit einem Entpacker geöffnet und die enthaltene Applikation !Netsurf per Drag&Drop in das gewünschte Zielverzeichnis kopiert. Von dort aus kann das Programm dann mit Doppelklick gestartet werden.</p>
+<p>Die Installation von "NetSurf" und "NetSurf small" ist ein dreistufiger Vorgang:</p>
+
+<ol>
+<li>Das mitgelieferte !Boot Verzeichnis wird mithilfe der Funktion <strong>Boot Merge</strong> der Systemkonfiguration in den Bootordner des Rechners eingebunden.<br>Existiert keine solche Merge-Funktion auf dem System, wird das mitgelieferte !Boot einfach über das vorhandene kopiert.</li>
+<li>Das mitgelieferte !System Verzeichnis wird mithilfe der Funktion <strong>System Merge</strong> der Systemkonfiguration ins System eingespielt.</li>
+<li>Die Applikation !Netsurf wird aus dem Archiv heraus in das gewünschte Zielverzeichnis kopiert.</li>
+</ol>
+
+<p>Durch Doppelklick wird !NetSurf vom selbstgewählten Ort aus gestartet.</p>
<h3 id="GettingStartedRequirements">Systemvoraussetzungen</h3>
<p>Für NetSurf wird mindestens RISC OS 3.5 benötigt. Beim Starten von NetSurf sucht das Programm nach allen Dateien und Systemfunktionen, die für ein korrektes Funktionieren notwendig sind. Wird dabei eine benötigte Resource nicht gefunden, wird eine Fehlermeldung ausgegeben. Oft ist in so einem Fall eines der folgenden, notwendigen Module nicht im System vorhanden.</p>
<dl>
+<dt>Module die in den Verzeichnissen !Boot und !System mit NetSurf geliefert werden :</dt>
+<dd>
+<dl>
<dt><a href="http://sudden.recoil.org/others/">Acorn URI</a></dt>
<dd>Das Acorn URI Modul kontrolliert und steuert die Übermittlung von URIs (zum Beispiel URL-Adressen) zwischen Applikationen.</dd>
<dt><a href="http://netsurf-browser.org/iconv/">Iconv</a></dt>
<dd>Dieses Modul bietet eine verbesserte Unterstützung bei der Zeichencodierung.</dd>
-<dt><a href="http://www.beebware.com/software/mappings/">MimeMap Datei</a></dt>
-<dd>Eine Liste mit verschiedenen MIME Typen und den ihnen zugeordneten RISC OS Filetypen.</dd>
<dt><a href="http://www.riscos.info/downloads/gccsdk/sharedunixlib/system.zip">SharedUnixLibrary</a></dt>
<dd>Dies ist ein Zusatzmodul für Programme, die unter Verwendung der UnixLib Library kompiliert wurden.</dd>
<dt><a href="http://www.tinct.net/tinct.asp">Tinct</a></dt>
<dd>Tinct wird zur Bilddarstellung benötigt. Es unterstützt die Ausgabe von Sprites mit Alpha-Channels.</dd>
+</dl>
+</dd>
+
+<dl>
+<dt>Module die nicht bei NetSurf mitgeliefert werden (nur für RISC OS 3.5, 3.6 und 3.7 benötigt) :</dt>
+<dd>
+<dl>
<dt>Window Manager 3.80 (oder höher)</dt>
<dd>NetSurf nutzt Funktionen des Nested Wimp, welches Teil des Window Managers ist. Bei RISC OS 4 oder höher ist dies ein Systembestandteil. Auf Systemen mit RISC OS 3 sollte die <a href="http://acorn.riscos.com/riscos/releases/UniBoot/">Universal Boot Sequence</a> installiert werden.</dd>
+</dl>
+</dd>
</dl>
<p>Wenn NetSurf ohne Probleme startet, sind alle nötigen Resourcen vorhanden. Es besteht dann keine Notwendigkeit zum Upgraden von Systemresourcen.</p>
@@ -69,6 +87,8 @@
<dl>
<dt><a href="http://www.ecs.soton.ac.uk/~jmb202/">Flash Plugin</a></dt>
<dd>Dieses Plugin ermöglicht die Anzeige von Flash Dateien auf Webseiten.</dd>
+<dt><a href="http://www.beebware.com/software/mappings/">MimeMap Datei</a></dt>
+<dd>Eine Liste mit verschiedenen MIME Typen und den ihnen zugeordneten RISC OS Filetypen.</dd>
</dl>
<h2 id="Upgrading">NetSurf upgraden</h2>
16 years, 2 months
r3387 jmb - /trunk/netsurf/content/fetch.c
by netsurf@semichrome.net
Author: jmb
Date: Sun Jul 8 12:35:53 2007
New Revision: 3387
URL: http://source.netsurf-browser.org?rev=3387&view=rev
Log:
Fix uninitialised fetch structure entries.
This was causing the Referer header to be sent regardless (assuming the referer string was non-NULL).
Modified:
trunk/netsurf/content/fetch.c
Modified: trunk/netsurf/content/fetch.c
URL: http://source.netsurf-browser.org/trunk/netsurf/content/fetch.c?rev=3387&...
==============================================================================
--- trunk/netsurf/content/fetch.c (original)
+++ trunk/netsurf/content/fetch.c Sun Jul 8 12:35:53 2007
@@ -261,6 +261,8 @@
fetch->r_prev = 0;
fetch->r_next = 0;
fetch->referer = 0;
+ fetch->send_referer = false;
+ fetch->fetcher_handle = NULL;
fetch->ops = 0;
fetch->fetch_is_active = false;
16 years, 2 months
r3385 jmb - in /trunk/dom: docs/ include/dom/ include/dom/core/ src/core/
by netsurf@semichrome.net
Author: jmb
Date: Fri Jul 6 22:42:18 2007
New Revision: 3385
URL: http://source.netsurf-browser.org?rev=3385&view=rev
Log:
Purge all trace of the ballache that was dom_ctx.
Document the functions in document.c
Added:
trunk/dom/include/dom/functypes.h
Removed:
trunk/dom/include/dom/ctx.h
Modified:
trunk/dom/docs/Todo
trunk/dom/include/dom/core/attr.h
trunk/dom/include/dom/core/document.h
trunk/dom/include/dom/core/exceptions.h
trunk/dom/include/dom/core/node.h
trunk/dom/include/dom/core/string.h
trunk/dom/src/core/attr.c
trunk/dom/src/core/document.c
trunk/dom/src/core/document.h
trunk/dom/src/core/node.c
trunk/dom/src/core/node.h
trunk/dom/src/core/string.c
Modified: trunk/dom/docs/Todo
URL: http://source.netsurf-browser.org/trunk/dom/docs/Todo?rev=3385&r1=3384&r2...
==============================================================================
--- trunk/dom/docs/Todo (original)
+++ trunk/dom/docs/Todo Fri Jul 6 22:42:18 2007
@@ -1,13 +1,6 @@
TODO list
=========
- + Sort out the mess that is dom_ctx - I really don't like it; everything (except dom_strings)
- should be allocated in the context of a document and, thus, the context is easily found
- through foo->owner->blah. dom_strings are somewhat awkward here, as they aren't necessarily
- allocated in the context of a document, but they still need access to an allocator. Perhaps
- the simplest solution is for the string constructors to take an allocator and private word
- as parameters, then store them within the string. This does, however, add an overhead of
- 8 (or 16 on 64bit platforms) bytes per dom_string, which isn't exactly great.
+ Fill out stub functions for DOM3 core
+ Rest of DOM level 3
+ DOM level 2
Modified: trunk/dom/include/dom/core/attr.h
URL: http://source.netsurf-browser.org/trunk/dom/include/dom/core/attr.h?rev=3...
==============================================================================
--- trunk/dom/include/dom/core/attr.h (original)
+++ trunk/dom/include/dom/core/attr.h Fri Jul 6 22:42:18 2007
@@ -12,26 +12,23 @@
#include <dom/core/exceptions.h>
-struct dom_ctx;
struct dom_element;
struct dom_typeinfo;
struct dom_node;
struct dom_attr;
struct dom_string;
-dom_exception dom_attr_get_name(struct dom_ctx *ctx,
- struct dom_attr *attr, struct dom_string **result);
-dom_exception dom_attr_get_specified(struct dom_ctx *ctx,
- struct dom_attr *attr, bool *result);
-dom_exception dom_attr_get_value(struct dom_ctx *ctx,
- struct dom_attr *attr, struct dom_string **result);
-dom_exception dom_attr_set_value(struct dom_ctx *ctx,
- struct dom_attr *attr, struct dom_string *value);
-dom_exception dom_attr_get_owner(struct dom_ctx *ctx,
- struct dom_attr *attr, struct dom_element **result);
-dom_exception dom_attr_get_typeinfo(struct dom_ctx *ctx,
- struct dom_attr *attr, struct dom_typeinfo **result);
-dom_exception dom_attr_is_id(struct dom_ctx *ctx,
- struct dom_attr *attr, bool *result);
+dom_exception dom_attr_get_name(struct dom_attr *attr,
+ struct dom_string **result);
+dom_exception dom_attr_get_specified(struct dom_attr *attr, bool *result);
+dom_exception dom_attr_get_value(struct dom_attr *attr,
+ struct dom_string **result);
+dom_exception dom_attr_set_value(struct dom_attr *attr,
+ struct dom_string *value);
+dom_exception dom_attr_get_owner(struct dom_attr *attr,
+ struct dom_element **result);
+dom_exception dom_attr_get_typeinfo(struct dom_attr *attr,
+ struct dom_typeinfo **result);
+dom_exception dom_attr_is_id(struct dom_attr *attr, bool *result);
#endif
Modified: trunk/dom/include/dom/core/document.h
URL: http://source.netsurf-browser.org/trunk/dom/include/dom/core/document.h?r...
==============================================================================
--- trunk/dom/include/dom/core/document.h (original)
+++ trunk/dom/include/dom/core/document.h Fri Jul 6 22:42:18 2007
@@ -14,7 +14,6 @@
struct dom_attr;
struct dom_configuration;
-struct dom_ctx;
struct dom_document;
struct dom_document_type;
struct dom_element;
@@ -24,81 +23,69 @@
struct dom_string;
struct dom_text;
-dom_exception dom_document_get_doctype(struct dom_ctx *ctx,
- struct dom_document *doc, struct dom_document_type **result);
-dom_exception dom_document_get_implementation(struct dom_ctx *ctx,
- struct dom_document *doc,
+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,
struct dom_implementation **result);
-dom_exception dom_document_get_element(struct dom_ctx *ctx,
- struct dom_document *doc, struct dom_element **result);
-dom_exception dom_document_create_element(struct dom_ctx *ctx,
- struct dom_document *doc, struct dom_string *tag_name,
+dom_exception dom_document_get_element(struct dom_document *doc,
struct dom_element **result);
-dom_exception dom_document_create_document_fragment(struct dom_ctx *ctx,
- struct dom_document *doc, struct dom_node **result);
-dom_exception dom_document_create_text_node(struct dom_ctx *ctx,
- struct dom_document *doc, struct dom_string *data,
- struct dom_text **result);
-dom_exception dom_document_create_cdata_section(struct dom_ctx *ctx,
- struct dom_document *doc, struct dom_string *data,
- struct dom_text **result);
-dom_exception dom_document_create_processing_instruction(struct dom_ctx *ctx,
+dom_exception dom_document_create_element(struct dom_document *doc,
+ struct dom_string *tag_name, struct dom_element **result);
+dom_exception dom_document_create_document_fragment(struct dom_document *doc,
+ struct dom_node **result);
+dom_exception dom_document_create_text_node(struct dom_document *doc,
+ struct dom_string *data, struct dom_text **result);
+dom_exception dom_document_create_cdata_section(struct dom_document *doc,
+ struct dom_string *data, struct dom_text **result);
+dom_exception dom_document_create_processing_instruction(
struct dom_document *doc, struct dom_string *target,
- struct dom_string *data,
- struct dom_node **result);
-dom_exception dom_document_create_attribute(struct dom_ctx *ctx,
- struct dom_document *doc, struct dom_string *name,
+ struct dom_string *data, struct dom_node **result);
+dom_exception dom_document_create_attribute(struct dom_document *doc,
+ struct dom_string *name, struct dom_attr **result);
+dom_exception dom_document_create_entity_reference(struct dom_document *doc,
+ struct dom_string *name, struct dom_node **result);
+dom_exception dom_document_get_elements_by_tag_name(struct dom_document *doc,
+ struct 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,
+ struct dom_string *namespace, struct dom_string *qname,
+ struct dom_element **result);
+dom_exception dom_document_create_attribute_ns(struct dom_document *doc,
+ struct dom_string *namespace, struct dom_string *qname,
struct dom_attr **result);
-dom_exception dom_document_create_entity_reference(struct dom_ctx *ctx,
- struct dom_document *doc, struct dom_string *name,
- struct dom_node **result);
-dom_exception dom_document_get_elements_by_tag_name(struct dom_ctx *ctx,
- struct dom_document *doc, struct dom_string *tagname,
- struct dom_nodelist **result);
-dom_exception dom_document_import_node(struct dom_ctx *ctx,
- struct dom_document *doc, struct dom_node *node,
- bool deep, struct dom_node **result);
-dom_exception dom_document_create_element_ns(struct dom_ctx *ctx,
- struct dom_document *doc, struct dom_string *namespace,
- struct dom_string *qname, struct dom_element **result);
-dom_exception dom_document_create_attribute_ns(struct dom_ctx *ctx,
- struct dom_document *doc, struct dom_string *namespace,
- struct dom_string *qname, struct dom_attr **result);
-dom_exception dom_document_get_elements_by_tag_name_ns(struct dom_ctx *ctx,
+dom_exception dom_document_get_elements_by_tag_name_ns(
struct dom_document *doc, struct dom_string *namespace,
struct dom_string *localname, struct dom_nodelist **result);
-dom_exception dom_document_get_element_by_id(struct dom_ctx *ctx,
- struct dom_document *doc, struct dom_string *id,
- struct dom_element **result);
-dom_exception dom_document_get_input_encoding(struct dom_ctx *ctx,
- struct dom_document *doc, struct dom_string **result);
-dom_exception dom_document_get_xml_encoding(struct dom_ctx *ctx,
- struct dom_document *doc, struct dom_string **result);
-dom_exception dom_document_get_xml_standalone(struct dom_ctx *ctx,
+dom_exception dom_document_get_element_by_id(struct dom_document *doc,
+ struct dom_string *id, struct dom_element **result);
+dom_exception dom_document_get_input_encoding(struct dom_document *doc,
+ struct dom_string **result);
+dom_exception dom_document_get_xml_encoding(struct dom_document *doc,
+ struct dom_string **result);
+dom_exception dom_document_get_xml_standalone(struct dom_document *doc,
+ bool *result);
+dom_exception dom_document_set_xml_standalone(struct dom_document *doc,
+ bool standalone);
+dom_exception dom_document_get_xml_version(struct dom_document *doc,
+ struct dom_string **result);
+dom_exception dom_document_set_xml_version(struct dom_document *doc,
+ struct dom_string *version);
+dom_exception dom_document_get_strict_error_checking(
struct dom_document *doc, bool *result);
-dom_exception dom_document_set_xml_standalone(struct dom_ctx *ctx,
- struct dom_document *doc, bool standalone);
-dom_exception dom_document_get_xml_version(struct dom_ctx *ctx,
- struct dom_document *doc, struct dom_string **result);
-dom_exception dom_document_set_xml_version(struct dom_ctx *ctx,
- struct dom_document *doc, struct dom_string *version);
-dom_exception dom_document_get_strict_error_checking(struct dom_ctx *ctx,
- struct dom_document *doc, bool *result);
-dom_exception dom_document_set_strict_error_checking(struct dom_ctx *ctx,
+dom_exception dom_document_set_strict_error_checking(
struct dom_document *doc, bool strict);
-dom_exception dom_document_get_uri(struct dom_ctx *ctx,
- struct dom_document *doc, struct dom_string **result);
-dom_exception dom_document_set_uri(struct dom_ctx *ctx,
- struct dom_document *doc, struct dom_string *uri);
-dom_exception dom_document_adopt_node(struct dom_ctx *ctx,
- struct dom_document *doc, struct dom_node *node,
- struct dom_node **result);
-dom_exception dom_document_get_dom_config(struct dom_ctx *ctx,
- struct dom_document *doc, struct dom_configuration **result);
-dom_exception dom_document_normalize(struct dom_ctx *ctx,
- struct dom_document *doc);
-dom_exception dom_document_rename_node(struct dom_ctx *ctx,
- struct dom_document *doc, struct dom_node *node,
+dom_exception dom_document_get_uri(struct dom_document *doc,
+ struct dom_string **result);
+dom_exception dom_document_set_uri(struct dom_document *doc,
+ struct 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,
+ 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,
struct dom_string *namespace, struct dom_string *qname,
struct dom_node **result);
Modified: trunk/dom/include/dom/core/exceptions.h
URL: http://source.netsurf-browser.org/trunk/dom/include/dom/core/exceptions.h...
==============================================================================
--- trunk/dom/include/dom/core/exceptions.h (original)
+++ trunk/dom/include/dom/core/exceptions.h Fri Jul 6 22:42:18 2007
@@ -5,8 +5,8 @@
* Copyright 2007 John-Mark Bell <jmb(a)netsurf-browser.org>
*/
-#ifndef dom_errors_h_
-#define dom_errors_h_
+#ifndef dom_core_exceptions_h_
+#define dom_core_exceptions_h_
/* The DOM spec says that this is actually an unsigned short */
typedef enum {
Modified: trunk/dom/include/dom/core/node.h
URL: http://source.netsurf-browser.org/trunk/dom/include/dom/core/node.h?rev=3...
==============================================================================
--- trunk/dom/include/dom/core/node.h (original)
+++ trunk/dom/include/dom/core/node.h Fri Jul 6 22:42:18 2007
@@ -13,7 +13,6 @@
#include <dom/core/exceptions.h>
-struct dom_ctx;
struct dom_document;
struct dom_node;
struct dom_node_list;
@@ -69,102 +68,86 @@
} dom_node_type;
-void dom_node_ref(struct dom_ctx *ctx, struct dom_node *node);
-void dom_node_unref(struct dom_ctx *ctx, struct dom_node *node);
+void dom_node_ref(struct dom_node *node);
+void dom_node_unref(struct dom_node *node);
-dom_exception dom_node_get_name(struct dom_ctx *ctx,
- struct dom_node *node, struct dom_string **result);
-dom_exception dom_node_get_value(struct dom_ctx *ctx,
- struct dom_node *node, struct dom_string **result);
-dom_exception dom_node_set_value(struct dom_ctx *ctx,
- struct dom_node *node, struct dom_string *value);
-dom_exception dom_node_get_type(struct dom_ctx *ctx,
- struct dom_node *node, dom_node_type *result);
-dom_exception dom_node_get_parent(struct dom_ctx *ctx,
- struct dom_node *node, struct dom_node **result);
-dom_exception dom_node_get_children(struct dom_ctx *ctx,
- struct dom_node *node, struct dom_node_list **result);
-dom_exception dom_node_get_first_child(struct dom_ctx *ctx,
- struct dom_node *node, struct dom_node **result);
-dom_exception dom_node_get_last_child(struct dom_ctx *ctx,
- struct dom_node *node, struct dom_node **result);
-dom_exception dom_node_get_previous(struct dom_ctx *ctx,
- struct dom_node *node, struct dom_node **result);
-dom_exception dom_node_get_next(struct dom_ctx *ctx,
- struct dom_node *node, struct dom_node **result);
-dom_exception dom_node_get_attributes(struct dom_ctx *ctx,
- struct dom_node *node, struct dom_named_node_map **result);
-dom_exception dom_node_get_owner(struct dom_ctx *ctx,
- struct dom_node *node, struct dom_document **result);
-dom_exception dom_node_insert_before(struct dom_ctx *ctx,
- struct dom_node *node,
+dom_exception dom_node_get_name(struct dom_node *node,
+ struct dom_string **result);
+dom_exception dom_node_get_value(struct dom_node *node,
+ struct dom_string **result);
+dom_exception dom_node_set_value(struct dom_node *node,
+ struct dom_string *value);
+dom_exception dom_node_get_type(struct dom_node *node,
+ dom_node_type *result);
+dom_exception dom_node_get_parent(struct dom_node *node,
+ struct dom_node **result);
+dom_exception dom_node_get_children(struct dom_node *node,
+ struct dom_node_list **result);
+dom_exception dom_node_get_first_child(struct dom_node *node,
+ struct dom_node **result);
+dom_exception dom_node_get_last_child(struct dom_node *node,
+ struct dom_node **result);
+dom_exception dom_node_get_previous(struct dom_node *node,
+ struct dom_node **result);
+dom_exception dom_node_get_next(struct dom_node *node,
+ struct dom_node **result);
+dom_exception dom_node_get_attributes(struct dom_node *node,
+ struct dom_named_node_map **result);
+dom_exception dom_node_get_owner(struct dom_node *node,
+ struct dom_document **result);
+dom_exception dom_node_insert_before(struct dom_node *node,
struct dom_node *new_child, struct dom_node *ref_child,
struct dom_node **result);
-dom_exception dom_node_replace_child(struct dom_ctx *ctx,
- struct dom_node *node,
+dom_exception dom_node_replace_child(struct dom_node *node,
struct dom_node *new_child, struct dom_node *old_child,
struct dom_node **result);
-dom_exception dom_node_remove_child(struct dom_ctx *ctx,
- struct dom_node *node,
+dom_exception dom_node_remove_child(struct dom_node *node,
struct dom_node *old_child,
struct dom_node **result);
-dom_exception dom_node_append_child(struct dom_ctx *ctx,
- struct dom_node *node,
+dom_exception dom_node_append_child(struct dom_node *node,
struct dom_node *new_child,
struct dom_node **result);
-dom_exception dom_node_has_children(struct dom_ctx *ctx,
- struct dom_node *node, bool *result);
-dom_exception dom_node_clone(struct dom_ctx *ctx,
- struct dom_node *node, bool deep,
+dom_exception dom_node_has_children(struct dom_node *node, bool *result);
+dom_exception dom_node_clone(struct dom_node *node, bool deep,
struct dom_node **result);
-dom_exception dom_node_normalize(struct dom_ctx *ctx,
- struct dom_node *node);
-dom_exception dom_node_is_supported(struct dom_ctx *ctx,
- struct dom_node *node, struct dom_string *feature,
- struct dom_node *version, bool *result);
-dom_exception dom_node_get_namespace(struct dom_ctx *ctx,
- struct dom_node *node, struct dom_string **result);
-dom_exception dom_node_get_prefix(struct dom_ctx *ctx,
- struct dom_node *node, struct dom_string **result);
-dom_exception dom_node_set_prefix(struct dom_ctx *ctx,
- struct dom_node *node, struct dom_string *prefix);
-dom_exception dom_node_get_local_name(struct dom_ctx *ctx,
- struct dom_node *node, struct dom_string **result);
-dom_exception dom_node_has_attributes(struct dom_ctx *ctx,
- struct dom_node *node, bool *result);
-dom_exception dom_node_get_base(struct dom_ctx *ctx,
- struct dom_node *node, struct dom_string **result);
-dom_exception dom_node_compare_document_position(struct dom_ctx *ctx,
- struct dom_node *node, struct dom_node *other,
- uint16_t *result);
-dom_exception dom_node_get_text_content(struct dom_ctx *ctx,
- struct dom_node *node, struct dom_string **result);
-dom_exception dom_node_set_text_content(struct dom_ctx *ctx,
- struct dom_node *node, struct dom_string *content);
-dom_exception dom_node_is_same(struct dom_ctx *ctx,
- struct dom_node *node, struct dom_node *other,
+dom_exception dom_node_normalize(struct dom_node *node);
+dom_exception dom_node_is_supported(struct dom_node *node,
+ struct dom_string *feature, struct dom_node *version,
bool *result);
-dom_exception dom_node_lookup_prefix(struct dom_ctx *ctx,
- struct dom_node *node, struct dom_string *namespace,
+dom_exception dom_node_get_namespace(struct dom_node *node,
struct dom_string **result);
-dom_exception dom_node_is_default_namespace(struct dom_ctx *ctx,
- struct dom_node *node, struct dom_string *namespace,
+dom_exception dom_node_get_prefix(struct dom_node *node,
+ struct dom_string **result);
+dom_exception dom_node_set_prefix(struct dom_node *node,
+ struct dom_string *prefix);
+dom_exception dom_node_get_local_name(struct dom_node *node,
+ struct dom_string **result);
+dom_exception dom_node_has_attributes(struct dom_node *node, bool *result);
+dom_exception dom_node_get_base(struct dom_node *node,
+ struct dom_string **result);
+dom_exception dom_node_compare_document_position(struct dom_node *node,
+ struct dom_node *other, uint16_t *result);
+dom_exception dom_node_get_text_content(struct dom_node *node,
+ struct dom_string **result);
+dom_exception dom_node_set_text_content(struct dom_node *node,
+ struct dom_string *content);
+dom_exception dom_node_is_same(struct dom_node *node, struct dom_node *other,
bool *result);
-dom_exception dom_node_lookup_namespace(struct dom_ctx *ctx,
- struct dom_node *node, struct dom_string *prefix,
- struct dom_string **result);
-dom_exception dom_node_is_equal(struct dom_ctx *ctx,
- struct dom_node *node, struct dom_node *other,
- bool *result);
-dom_exception dom_node_get_feature(struct dom_ctx *ctx,
- struct dom_node *node, struct dom_string *feature,
- struct dom_string *version, void **result);
-dom_exception dom_node_set_user_data(struct dom_ctx *ctx,
- struct dom_node *node, struct dom_string *key,
- void *data, dom_user_data_handler handler,
+dom_exception dom_node_lookup_prefix(struct dom_node *node,
+ struct dom_string *namespace, struct dom_string **result);
+dom_exception dom_node_is_default_namespace(struct dom_node *node,
+ struct dom_string *namespace, bool *result);
+dom_exception dom_node_lookup_namespace(struct dom_node *node,
+ struct dom_string *prefix, struct dom_string **result);
+dom_exception dom_node_is_equal(struct dom_node *node,
+ struct dom_node *other, bool *result);
+dom_exception dom_node_get_feature(struct dom_node *node,
+ struct dom_string *feature, struct dom_string *version,
void **result);
-dom_exception dom_node_get_user_data(struct dom_ctx *ctx,
- struct dom_node *node, struct dom_string *key,
- void **result);
+dom_exception dom_node_set_user_data(struct dom_node *node,
+ struct dom_string *key, void *data,
+ dom_user_data_handler handler, void **result);
+dom_exception dom_node_get_user_data(struct dom_node *node,
+ struct dom_string *key, void **result);
#endif
Modified: trunk/dom/include/dom/core/string.h
URL: http://source.netsurf-browser.org/trunk/dom/include/dom/core/string.h?rev...
==============================================================================
--- trunk/dom/include/dom/core/string.h (original)
+++ trunk/dom/include/dom/core/string.h Fri Jul 6 22:42:18 2007
@@ -13,28 +13,26 @@
#include <dom/core/exceptions.h>
-struct dom_ctx;
struct dom_document;
struct dom_string;
/* Claim a reference on a DOM string */
-void dom_string_ref(struct dom_ctx *ctx, struct dom_string *str);
+void dom_string_ref(struct dom_string *str);
/* Release a reference on a DOM string */
-void dom_string_unref(struct dom_ctx *ctx, struct dom_string *str);
+void dom_string_unref(struct dom_string *str);
/* Create a DOM string from an offset into the document buffer */
-dom_exception dom_string_create_from_off(struct dom_ctx *ctx,
- struct dom_document *doc, uint32_t off, size_t len,
- struct dom_string **str);
+dom_exception dom_string_create_from_off(struct dom_document *doc,
+ uint32_t off, size_t len, struct dom_string **str);
/* Create a DOM string from a string of characters */
-dom_exception dom_string_create_from_ptr(struct dom_ctx *ctx,
+dom_exception dom_string_create_from_ptr(struct dom_document *doc,
const uint8_t *ptr, size_t len, struct dom_string **str);
/* Create a DOM string from a constant string of characters */
-dom_exception dom_string_create_from_const_ptr(struct dom_ctx *ctx,
+dom_exception dom_string_create_from_const_ptr(struct dom_document *doc,
const uint8_t *ptr, size_t len, struct dom_string **str);
/* Get a pointer to the string of characters within a DOM string */
-dom_exception dom_string_get_data(struct dom_ctx *ctx,
- struct dom_string *str, const uint8_t **data, size_t *len);
+dom_exception dom_string_get_data(struct dom_string *str,
+ const uint8_t **data, size_t *len);
#endif
Removed: trunk/dom/include/dom/ctx.h
URL: http://source.netsurf-browser.org/trunk/dom/include/dom/ctx.h?rev=3384&vi...
==============================================================================
--- trunk/dom/include/dom/ctx.h (original)
+++ trunk/dom/include/dom/ctx.h (removed)
@@ -1,26 +1,0 @@
-/*
- * This file is part of libdom.
- * Licensed under the MIT License,
- * http://www.opensource.org/licenses/mit-license.php
- * Copyright 2007 John-Mark Bell <jmb(a)netsurf-browser.org>
- */
-
-#ifndef dom_ctx_h_
-#define dom_ctx_h_
-
-#include <stddef.h>
-
-/**
- * Type of allocation function for DOM implementation
- */
-typedef void *(*dom_alloc)(void *ptr, size_t size, void *pw);
-
-/**
- * DOM allocation context
- */
-struct dom_ctx {
- dom_alloc alloc; /**< Memory (de)allocation function */
- void *pw; /**< Pointer to client data */
-};
-
-#endif
Added: trunk/dom/include/dom/functypes.h
URL: http://source.netsurf-browser.org/trunk/dom/include/dom/functypes.h?rev=3...
==============================================================================
--- trunk/dom/include/dom/functypes.h (added)
+++ trunk/dom/include/dom/functypes.h Fri Jul 6 22:42:18 2007
@@ -1,0 +1,18 @@
+/*
+ * This file is part of libdom.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2007 John-Mark Bell <jmb(a)netsurf-browser.org>
+ */
+
+#ifndef dom_functypes_h_
+#define dom_functypes_h_
+
+#include <stddef.h>
+
+/**
+ * Type of allocation function for DOM implementation
+ */
+typedef void *(*dom_alloc)(void *ptr, size_t size, void *pw);
+
+#endif
Modified: trunk/dom/src/core/attr.c
URL: http://source.netsurf-browser.org/trunk/dom/src/core/attr.c?rev=3385&r1=3...
==============================================================================
--- trunk/dom/src/core/attr.c (original)
+++ trunk/dom/src/core/attr.c Fri Jul 6 22:42:18 2007
@@ -32,7 +32,6 @@
/**
* Retrieve an attribute's name
*
- * \param ctx The context in which the attribute resides
* \param attr Attribute to retrieve name from
* \param result Pointer to location to receive result
* \return DOM_NO_ERR.
@@ -41,10 +40,9 @@
* the responsibility of the caller to unref the string once it has
* finished with it.
*/
-dom_exception dom_attr_get_name(struct dom_ctx *ctx,
- struct dom_attr *attr, struct dom_string **result)
+dom_exception dom_attr_get_name(struct dom_attr *attr,
+ struct dom_string **result)
{
- UNUSED(ctx);
UNUSED(attr);
UNUSED(result);
@@ -54,15 +52,12 @@
/**
* Determine if attribute was specified or defaulted
*
- * \param ctx The context in which the attribute resides
* \param attr Attribute to inspect
* \param result Pointer to location to receive result
* \return DOM_NO_ERR.
*/
-dom_exception dom_attr_get_specified(struct dom_ctx *ctx,
- struct dom_attr *attr, bool *result)
+dom_exception dom_attr_get_specified(struct dom_attr *attr, bool *result)
{
- UNUSED(ctx);
*result = attr->specified;
@@ -72,7 +67,6 @@
/**
* Retrieve an attribute's value
*
- * \param ctx The context in which the attribute resides
* \param attr Attribute to retrieve value from
* \param result Pointer to location to receive result
* \return DOM_NO_ERR.
@@ -81,10 +75,9 @@
* the responsibility of the caller to unref the string once it has
* finished with it.
*/
-dom_exception dom_attr_get_value(struct dom_ctx *ctx,
- struct dom_attr *attr, struct dom_string **result)
+dom_exception dom_attr_get_value(struct dom_attr *attr,
+ struct dom_string **result)
{
- UNUSED(ctx);
UNUSED(attr);
UNUSED(result);
@@ -94,16 +87,14 @@
/**
* Set an attribute's value
*
- * \param ctx The context in which the attribute resides
* \param attr Attribute to retrieve value from
* \param value New value for attribute
* \return DOM_NO_ERR on success,
* DOM_NO_MODIFICATION_ALLOWED_ERR if attribute is readonly.
*/
-dom_exception dom_attr_set_value(struct dom_ctx *ctx,
- struct dom_attr *attr, struct dom_string *value)
+dom_exception dom_attr_set_value(struct dom_attr *attr,
+ struct dom_string *value)
{
- UNUSED(ctx);
UNUSED(attr);
UNUSED(value);
@@ -113,7 +104,6 @@
/**
* Retrieve the owning element of an attribute
*
- * \param ctx The context in which the attribute resides
* \param attr The attribute to extract owning element from
* \param result Pointer to location to receive result
* \return DOM_NO_ERR.
@@ -121,12 +111,12 @@
* The returned node will have its reference count increased. The caller
* should unref it once it has finished with it.
*/
-dom_exception dom_attr_get_owner(struct dom_ctx *ctx,
- struct dom_attr *attr, struct dom_element **result)
+dom_exception dom_attr_get_owner(struct dom_attr *attr,
+ struct dom_element **result)
{
/* If there is an owning element, increase its reference count */
if (attr->owner != NULL)
- dom_node_ref(ctx, (struct dom_node *) attr->owner);
+ dom_node_ref((struct dom_node *) attr->owner);
*result = attr->owner;
@@ -136,18 +126,16 @@
/**
* Retrieve an attribute's type information
*
- * \param ctx The context in which the attribute resides
- * \param attr The attribute to extract type information from
+ * \param attr The attribute to extract type information from
* \param result Pointer to location to receive result
* \return DOM_NO_ERR.
*
* The returned typeinfo will have its reference count increased. The caller
* should unref it once it has finished with it.
*/
-dom_exception dom_attr_get_typeinfo(struct dom_ctx *ctx,
- struct dom_attr *attr, struct dom_typeinfo **result)
+dom_exception dom_attr_get_typeinfo(struct dom_attr *attr,
+ struct dom_typeinfo **result)
{
- UNUSED(ctx);
UNUSED(attr);
UNUSED(result);
@@ -157,16 +145,12 @@
/**
* Determine if an attribute if of type ID
*
- * \param ctx The context in which the attribute resides
* \param attr The attribute to inspect
* \param result Pointer to location to receive result
* \return DOM_NO_ERR.
*/
-dom_exception dom_attr_is_id(struct dom_ctx *ctx,
- struct dom_attr *attr, bool *result)
+dom_exception dom_attr_is_id(struct dom_attr *attr, bool *result)
{
- UNUSED(ctx);
-
*result = attr->is_id;
return DOM_NO_ERR;
Modified: trunk/dom/src/core/document.c
URL: http://source.netsurf-browser.org/trunk/dom/src/core/document.c?rev=3385&...
==============================================================================
--- trunk/dom/src/core/document.c (original)
+++ trunk/dom/src/core/document.c Fri Jul 6 22:42:18 2007
@@ -5,8 +5,10 @@
* Copyright 2007 John-Mark Bell <jmb(a)netsurf-browser.org>
*/
+#include <dom/functypes.h>
#include <dom/core/document.h>
+#include "core/document.h"
#include "core/node.h"
#include "utils/utils.h"
@@ -15,45 +17,83 @@
*/
struct dom_document {
struct dom_node base; /**< Base node */
+
+ dom_alloc alloc; /**< Memory (de)allocation function */
+ void *pw; /**< Pointer to client data */
};
-
-dom_exception dom_document_get_doctype(struct dom_ctx *ctx,
- struct dom_document *doc, struct dom_document_type **result)
-{
- UNUSED(ctx);
- UNUSED(doc);
- UNUSED(result);
-
- return DOM_NOT_SUPPORTED_ERR;
-}
-
-dom_exception dom_document_get_implementation(struct dom_ctx *ctx,
- struct dom_document *doc,
+/**
+ * Retrieve the doctype of a document
+ *
+ * \param doc The document to retrieve the doctype from
+ * \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_get_doctype(struct dom_document *doc,
+ struct dom_document_type **result)
+{
+ UNUSED(doc);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Retrieve the DOM implementation that handles this document
+ *
+ * \param doc The document to retrieve the implementation from
+ * \param result Pointer to location to receive result
+ * \return DOM_NO_ERR.
+ */
+dom_exception dom_document_get_implementation(struct dom_document *doc,
struct dom_implementation **result)
{
- UNUSED(ctx);
- UNUSED(doc);
- UNUSED(result);
-
- return DOM_NOT_SUPPORTED_ERR;
-}
-
-dom_exception dom_document_get_element(struct dom_ctx *ctx,
- struct dom_document *doc, struct dom_element **result)
-{
- UNUSED(ctx);
- UNUSED(doc);
- UNUSED(result);
-
- return DOM_NOT_SUPPORTED_ERR;
-}
-
-dom_exception dom_document_create_element(struct dom_ctx *ctx,
- struct dom_document *doc, struct dom_string *tag_name,
+ UNUSED(doc);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Retrieve the document element of a document
+ *
+ * \param doc The document to retrieve the document element from
+ * \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_get_element(struct dom_document *doc,
struct dom_element **result)
{
- UNUSED(ctx);
+ UNUSED(doc);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Create an element
+ *
+ * \param doc The document owning the element
+ * \param tag_name The name of the element
+ * \param result Pointer to location to receive result
+ * \return DOM_NO_ERR on success,
+ * DOM_INVALID_CHARACTER_ERR if ::tag_name is invalid.
+ *
+ * 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_element(struct dom_document *doc,
+ struct dom_string *tag_name, struct dom_element **result)
+{
UNUSED(doc);
UNUSED(tag_name);
UNUSED(result);
@@ -61,21 +101,41 @@
return DOM_NOT_SUPPORTED_ERR;
}
-dom_exception dom_document_create_document_fragment(struct dom_ctx *ctx,
- struct dom_document *doc, struct dom_node **result)
-{
- UNUSED(ctx);
- UNUSED(doc);
- UNUSED(result);
-
- return DOM_NOT_SUPPORTED_ERR;
-}
-
-dom_exception dom_document_create_text_node(struct dom_ctx *ctx,
- struct dom_document *doc, struct dom_string *data,
- struct dom_text **result)
-{
- UNUSED(ctx);
+/**
+ * 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_node **result)
+{
+ UNUSED(doc);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Create a text node
+ *
+ * \param doc The document owning the node
+ * \param data The data for the node
+ * \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_text_node(struct dom_document *doc,
+ struct dom_string *data, struct dom_text **result)
+{
UNUSED(doc);
UNUSED(data);
UNUSED(result);
@@ -83,11 +143,22 @@
return DOM_NOT_SUPPORTED_ERR;
}
-dom_exception dom_document_create_cdata_section(struct dom_ctx *ctx,
- struct dom_document *doc, struct dom_string *data,
- struct dom_text **result)
-{
- UNUSED(ctx);
+/**
+ * Create a CDATA section
+ *
+ * \param doc The document owning the section
+ * \param data The data for the section contents
+ * \param result Pointer to location to receive result
+ * \return DOM_NO_ERR on success,
+ * DOM_NOT_SUPPORTED_ERR if this is an HTML document.
+ *
+ * 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_cdata_section(struct dom_document *doc,
+ struct dom_string *data, struct dom_text **result)
+{
UNUSED(doc);
UNUSED(data);
UNUSED(result);
@@ -95,12 +166,26 @@
return DOM_NOT_SUPPORTED_ERR;
}
-dom_exception dom_document_create_processing_instruction(struct dom_ctx *ctx,
+/**
+ * Create a processing instruction
+ *
+ * \param doc The document owning the instruction
+ * \param target The instruction target
+ * \param data The data for the node
+ * \param result Pointer to location to receive result
+ * \return DOM_NO_ERR on success,
+ * DOM_INVALID_CHARACTER_ERR if ::target is invalid,
+ * DOM_NOT_SUPPORTED_ERR if this is an HTML document.
+ *
+ * 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_processing_instruction(
struct dom_document *doc, struct dom_string *target,
struct dom_string *data,
struct dom_node **result)
{
- UNUSED(ctx);
UNUSED(doc);
UNUSED(target);
UNUSED(data);
@@ -109,11 +194,22 @@
return DOM_NOT_SUPPORTED_ERR;
}
-dom_exception dom_document_create_attribute(struct dom_ctx *ctx,
- struct dom_document *doc, struct dom_string *name,
- struct dom_attr **result)
-{
- UNUSED(ctx);
+/**
+ * Create an attribute
+ *
+ * \param doc The document owning the attribute
+ * \param name The name of the attribute
+ * \param result Pointer to location to receive result
+ * \return DOM_NO_ERR on success,
+ * DOM_INVALID_CHARACTER_ERR if ::name is invalid.
+ *
+ * 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_attribute(struct dom_document *doc,
+ struct dom_string *name, struct dom_attr **result)
+{
UNUSED(doc);
UNUSED(name);
UNUSED(result);
@@ -121,11 +217,23 @@
return DOM_NOT_SUPPORTED_ERR;
}
-dom_exception dom_document_create_entity_reference(struct dom_ctx *ctx,
- struct dom_document *doc, struct dom_string *name,
- struct dom_node **result)
-{
- UNUSED(ctx);
+/**
+ * Create an entity reference
+ *
+ * \param doc The document owning the reference
+ * \param name The name of the entity to reference
+ * \param result Pointer to location to receive result
+ * \return DOM_NO_ERR on success,
+ * DOM_INVALID_CHARACTER_ERR if ::name is invalid,
+ * DOM_NOT_SUPPORTED_ERR if this is an HTML document.
+ *
+ * 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_entity_reference(struct dom_document *doc,
+ struct dom_string *name, struct dom_node **result)
+{
UNUSED(doc);
UNUSED(name);
UNUSED(result);
@@ -133,11 +241,21 @@
return DOM_NOT_SUPPORTED_ERR;
}
-dom_exception dom_document_get_elements_by_tag_name(struct dom_ctx *ctx,
- struct dom_document *doc, struct dom_string *tagname,
- struct dom_nodelist **result)
-{
- UNUSED(ctx);
+/**
+ * Retrieve a list of all elements with a given tag name
+ *
+ * \param doc The document to search in
+ * \param tagname The tag name to search for ("*" for all)
+ * \param result Pointer to location to receive result
+ * \return DOM_NO_ERR.
+ *
+ * The returned list will have its reference count increased. It is
+ * 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,
+ struct dom_string *tagname, struct dom_nodelist **result)
+{
UNUSED(doc);
UNUSED(tagname);
UNUSED(result);
@@ -145,11 +263,24 @@
return DOM_NOT_SUPPORTED_ERR;
}
-dom_exception dom_document_import_node(struct dom_ctx *ctx,
- struct dom_document *doc, struct dom_node *node,
- bool deep, struct dom_node **result)
-{
- UNUSED(ctx);
+/**
+ * Import a node from another document into this one
+ *
+ * \param doc The document to import into
+ * \param node The node to import
+ * \param deep Whether to copy the node's subtree
+ * \param result Pointer to location to receive imported node in this document.
+ * \return DOM_NO_ERR on success,
+ * DOM_INVALID_CHARACTER_ERR if any of the names are invalid,
+ * DOM_NOT_SUPPORTED_ERR if the type of ::node is unsupported
+ *
+ * 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_import_node(struct dom_document *doc,
+ struct dom_node *node, bool deep, struct dom_node **result)
+{
UNUSED(doc);
UNUSED(node);
UNUSED(deep);
@@ -158,11 +289,38 @@
return DOM_NOT_SUPPORTED_ERR;
}
-dom_exception dom_document_create_element_ns(struct dom_ctx *ctx,
- struct dom_document *doc, struct dom_string *namespace,
- struct dom_string *qname, struct dom_element **result)
-{
- UNUSED(ctx);
+/**
+ * Create an element from the qualified name and namespace URI
+ *
+ * \param doc The document owning the element
+ * \param namespace The namespace URI to use
+ * \param qname The qualified name of the element
+ * \param result Pointer to location to receive result
+ * \return DOM_NO_ERR on success,
+ * DOM_INVALID_CHARACTER_ERR if ::tag_name is invalid,
+ * DOM_NAMESPACE_ERR if ::qname is malformed, or it has a
+ * prefix and ::namespace is NULL, or
+ * ::qname has a prefix "xml" and
+ * ::namespace is not
+ * "http://www.w3.org/XML/1998/namespace",
+ * or ::qname has a prefix "xmlns" and
+ * ::namespace is not
+ * "http://www.w3.org/2000/xmlns", or
+ * ::namespace is
+ * "http://www.w3.org/2000/xmlns" and
+ * ::qname is not (or is not prefixed by)
+ * "xmlns",
+ * DOM_NOT_SUPPORTED_ERR if ::doc does not support the "XML"
+ * feature.
+ *
+ * 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_element_ns(struct dom_document *doc,
+ struct dom_string *namespace, struct dom_string *qname,
+ struct dom_element **result)
+{
UNUSED(doc);
UNUSED(namespace);
UNUSED(qname);
@@ -171,11 +329,38 @@
return DOM_NOT_SUPPORTED_ERR;
}
-dom_exception dom_document_create_attribute_ns(struct dom_ctx *ctx,
- struct dom_document *doc, struct dom_string *namespace,
- struct dom_string *qname, struct dom_attr **result)
-{
- UNUSED(ctx);
+/**
+ * Create an attribute from the qualified name and namespace URI
+ *
+ * \param doc The document owning the attribute
+ * \param namespace The namespace URI to use
+ * \param qname The qualified name of the attribute
+ * \param result Pointer to location to receive result
+ * \return DOM_NO_ERR on success,
+ * DOM_INVALID_CHARACTER_ERR if ::tag_name is invalid,
+ * DOM_NAMESPACE_ERR if ::qname is malformed, or it has a
+ * prefix and ::namespace is NULL, or
+ * ::qname has a prefix "xml" and
+ * ::namespace is not
+ * "http://www.w3.org/XML/1998/namespace",
+ * or ::qname has a prefix "xmlns" and
+ * ::namespace is not
+ * "http://www.w3.org/2000/xmlns", or
+ * ::namespace is
+ * "http://www.w3.org/2000/xmlns" and
+ * ::qname is not (or is not prefixed by)
+ * "xmlns",
+ * DOM_NOT_SUPPORTED_ERR if ::doc does not support the "XML"
+ * feature.
+ *
+ * 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_attribute_ns(struct dom_document *doc,
+ struct dom_string *namespace, struct dom_string *qname,
+ struct dom_attr **result)
+{
UNUSED(doc);
UNUSED(namespace);
UNUSED(qname);
@@ -184,11 +369,23 @@
return DOM_NOT_SUPPORTED_ERR;
}
-dom_exception dom_document_get_elements_by_tag_name_ns(struct dom_ctx *ctx,
+/**
+ * Retrieve a list of all elements with a given local name and namespace URI
+ *
+ * \param doc The document to search in
+ * \param namespace The namespace URI
+ * \param localname The local name
+ * \param result Pointer to location to receive result
+ * \return DOM_NO_ERR.
+ *
+ * The returned list will have its reference count increased. It is
+ * the responsibility of the caller to unref the list once it has
+ * finished with it.
+ */
+dom_exception dom_document_get_elements_by_tag_name_ns(
struct dom_document *doc, struct dom_string *namespace,
struct dom_string *localname, struct dom_nodelist **result)
{
- UNUSED(ctx);
UNUSED(doc);
UNUSED(namespace);
UNUSED(localname);
@@ -197,11 +394,21 @@
return DOM_NOT_SUPPORTED_ERR;
}
-dom_exception dom_document_get_element_by_id(struct dom_ctx *ctx,
- struct dom_document *doc, struct dom_string *id,
- struct dom_element **result)
-{
- UNUSED(ctx);
+/**
+ * Retrieve the element that matches the specified ID
+ *
+ * \param doc The document to search in
+ * \param id The ID to search for
+ * \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_get_element_by_id(struct dom_document *doc,
+ struct dom_string *id, struct dom_element **result)
+{
UNUSED(doc);
UNUSED(id);
UNUSED(result);
@@ -209,111 +416,208 @@
return DOM_NOT_SUPPORTED_ERR;
}
-dom_exception dom_document_get_input_encoding(struct dom_ctx *ctx,
- struct dom_document *doc, struct dom_string **result)
-{
- UNUSED(ctx);
- UNUSED(doc);
- UNUSED(result);
-
- return DOM_NOT_SUPPORTED_ERR;
-}
-
-dom_exception dom_document_get_xml_encoding(struct dom_ctx *ctx,
- struct dom_document *doc, struct dom_string **result)
-{
- UNUSED(ctx);
- UNUSED(doc);
- UNUSED(result);
-
- return DOM_NOT_SUPPORTED_ERR;
-}
-
-dom_exception dom_document_get_xml_standalone(struct dom_ctx *ctx,
+/**
+ * Retrieve the input encoding of the document
+ *
+ * \param doc The document to query
+ * \param result Pointer to location to receive result
+ * \return DOM_NO_ERR.
+ *
+ * The returned string will have its reference count increased. It is
+ * the responsibility of the caller to unref the string once it has
+ * finished with it.
+ */
+dom_exception dom_document_get_input_encoding(struct dom_document *doc,
+ struct dom_string **result)
+{
+ UNUSED(doc);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Retrieve the XML encoding of the document
+ *
+ * \param doc The document to query
+ * \param result Pointer to location to receive result
+ * \return DOM_NO_ERR.
+ *
+ * The returned string will have its reference count increased. It is
+ * the responsibility of the caller to unref the string once it has
+ * finished with it.
+ */
+dom_exception dom_document_get_xml_encoding(struct dom_document *doc,
+ struct dom_string **result)
+{
+ UNUSED(doc);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Retrieve the standalone status of the document
+ *
+ * \param doc The document to query
+ * \param result Pointer to location to receive result
+ * \return DOM_NO_ERR.
+ */
+dom_exception dom_document_get_xml_standalone(struct dom_document *doc,
+ bool *result)
+{
+ UNUSED(doc);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Set the standalone status of the document
+ *
+ * \param doc The document to query
+ * \param standalone Standalone status to use
+ * \return DOM_NO_ERR on success,
+ * DOM_NOT_SUPPORTED_ERR if the document does not support the "XML"
+ * feature.
+ */
+dom_exception dom_document_set_xml_standalone(struct dom_document *doc,
+ bool standalone)
+{
+ UNUSED(doc);
+ UNUSED(standalone);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Retrieve the XML version of the document
+ *
+ * \param doc The document to query
+ * \param result Pointer to location to receive result
+ * \return DOM_NO_ERR.
+ *
+ * The returned string will have its reference count increased. It is
+ * the responsibility of the caller to unref the string once it has
+ * finished with it.
+ */
+dom_exception dom_document_get_xml_version(struct dom_document *doc,
+ struct dom_string **result)
+{
+ UNUSED(doc);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Set the XML version of the document
+ *
+ * \param doc The document to query
+ * \param version XML version to use
+ * \return DOM_NO_ERR on success,
+ * DOM_NOT_SUPPORTED_ERR if the document does not support the "XML"
+ * feature.
+ */
+dom_exception dom_document_set_xml_version(struct dom_document *doc,
+ struct dom_string *version)
+{
+ UNUSED(doc);
+ UNUSED(version);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Retrieve the error checking mode of the document
+ *
+ * \param doc The document to query
+ * \param result Pointer to location to receive result
+ * \return DOM_NO_ERR.
+ */
+dom_exception dom_document_get_strict_error_checking(
struct dom_document *doc, bool *result)
{
- UNUSED(ctx);
- UNUSED(doc);
- UNUSED(result);
-
- return DOM_NOT_SUPPORTED_ERR;
-}
-
-dom_exception dom_document_set_xml_standalone(struct dom_ctx *ctx,
- struct dom_document *doc, bool standalone)
-{
- UNUSED(ctx);
- UNUSED(doc);
- UNUSED(standalone);
-
- return DOM_NOT_SUPPORTED_ERR;
-}
-
-dom_exception dom_document_get_xml_version(struct dom_ctx *ctx,
- struct dom_document *doc, struct dom_string **result)
-{
- UNUSED(ctx);
- UNUSED(doc);
- UNUSED(result);
-
- return DOM_NOT_SUPPORTED_ERR;
-}
-
-dom_exception dom_document_set_xml_version(struct dom_ctx *ctx,
- struct dom_document *doc, struct dom_string *version)
-{
- UNUSED(ctx);
- UNUSED(doc);
- UNUSED(version);
-
- return DOM_NOT_SUPPORTED_ERR;
-}
-
-dom_exception dom_document_get_strict_error_checking(struct dom_ctx *ctx,
- struct dom_document *doc, bool *result)
-{
- UNUSED(ctx);
- UNUSED(doc);
- UNUSED(result);
-
- return DOM_NOT_SUPPORTED_ERR;
-}
-
-dom_exception dom_document_set_strict_error_checking(struct dom_ctx *ctx,
+ UNUSED(doc);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Set the error checking mode of the document
+ *
+ * \param doc The document to query
+ * \param strict Whether to use strict error checking
+ * \return DOM_NO_ERR.
+ */
+dom_exception dom_document_set_strict_error_checking(
struct dom_document *doc, bool strict)
{
- UNUSED(ctx);
UNUSED(doc);
UNUSED(strict);
return DOM_NOT_SUPPORTED_ERR;
}
-dom_exception dom_document_get_uri(struct dom_ctx *ctx,
- struct dom_document *doc, struct dom_string **result)
-{
- UNUSED(ctx);
- UNUSED(doc);
- UNUSED(result);
-
- return DOM_NOT_SUPPORTED_ERR;
-}
-
-dom_exception dom_document_set_uri(struct dom_ctx *ctx,
- struct dom_document *doc, struct dom_string *uri)
-{
- UNUSED(ctx);
+/**
+ * Retrieve the URI of the document
+ *
+ * \param doc The document to query
+ * \param result Pointer to location to receive result
+ * \return DOM_NO_ERR.
+ *
+ * The returned string will have its reference count increased. It is
+ * the responsibility of the caller to unref the string once it has
+ * finished with it.
+ */
+dom_exception dom_document_get_uri(struct dom_document *doc,
+ struct dom_string **result)
+{
+ UNUSED(doc);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Set the URI of the document
+ *
+ * \param doc The document to query
+ * \param uri The URI to use
+ * \return DOM_NO_ERR.
+ *
+ * The returned string will have its reference count increased. It is
+ * the responsibility of the caller to unref the string once it has
+ * finished with it.
+ */
+dom_exception dom_document_set_uri(struct dom_document *doc,
+ struct dom_string *uri)
+{
UNUSED(doc);
UNUSED(uri);
return DOM_NOT_SUPPORTED_ERR;
}
-dom_exception dom_document_adopt_node(struct dom_ctx *ctx,
- struct dom_document *doc, struct dom_node *node,
- struct dom_node **result)
-{
- UNUSED(ctx);
+/**
+ * Attempt to adopt a node from another document into this document
+ *
+ * \param doc The document to adopt into
+ * \param node The node to adopt
+ * \param result Pointer to location to receive adopted node
+ * \return DOM_NO_ERR on success,
+ * DOM_NO_MODIFICATION_ALLOWED_ERR if ::node is readonly,
+ * DOM_NOT_SUPPORTED_ERR if ::node is of type Document or
+ * DocumentType
+ *
+ * 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_adopt_node(struct dom_document *doc,
+ struct dom_node *node, struct dom_node **result)
+{
UNUSED(doc);
UNUSED(node);
UNUSED(result);
@@ -321,31 +625,75 @@
return DOM_NOT_SUPPORTED_ERR;
}
-dom_exception dom_document_get_dom_config(struct dom_ctx *ctx,
- struct dom_document *doc, struct dom_configuration **result)
-{
- UNUSED(ctx);
- UNUSED(doc);
- UNUSED(result);
-
- return DOM_NOT_SUPPORTED_ERR;
-}
-
-dom_exception dom_document_normalize(struct dom_ctx *ctx,
- struct dom_document *doc)
-{
- UNUSED(ctx);
- UNUSED(doc);
-
- return DOM_NOT_SUPPORTED_ERR;
-}
-
-dom_exception dom_document_rename_node(struct dom_ctx *ctx,
- struct dom_document *doc, struct dom_node *node,
+/**
+ * Retrieve the DOM configuration associated with a document
+ *
+ * \param doc The document to query
+ * \param result Pointer to location to receive result
+ * \return DOM_NO_ERR.
+ *
+ * The returned object will have its reference count increased. It is
+ * 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,
+ struct dom_configuration **result)
+{
+ UNUSED(doc);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Normalize a document
+ *
+ * \param doc The document to normalize
+ * \return DOM_NO_ERR.
+ */
+dom_exception dom_document_normalize(struct dom_document *doc)
+{
+ UNUSED(doc);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Rename a node in a document
+ *
+ * \param doc The document containing the node
+ * \param node The node to rename
+ * \param namespace The new namespace for the node
+ * \param qname The new qualified name for the node
+ * \param result Pointer to location to receive renamed node
+ * \return DOM_NO_ERR on success,
+ * DOM_INVALID_CHARACTER_ERR if ::tag_name is invalid,
+ * DOM_WRONG_DOCUMENT_ERR if ::node was created in a different
+ * document
+ * DOM_NAMESPACE_ERR if ::qname is malformed, or it has a
+ * prefix and ::namespace is NULL, or
+ * ::qname has a prefix "xml" and
+ * ::namespace is not
+ * "http://www.w3.org/XML/1998/namespace",
+ * or ::qname has a prefix "xmlns" and
+ * ::namespace is not
+ * "http://www.w3.org/2000/xmlns", or
+ * ::namespace is
+ * "http://www.w3.org/2000/xmlns" and
+ * ::qname is not (or is not prefixed by)
+ * "xmlns",
+ * DOM_NOT_SUPPORTED_ERR if ::doc does not support the "XML"
+ * feature.
+ *
+ * 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_rename_node(struct dom_document *doc,
+ struct dom_node *node,
struct dom_string *namespace, struct dom_string *qname,
struct dom_node **result)
{
- UNUSED(ctx);
UNUSED(doc);
UNUSED(node);
UNUSED(namespace);
@@ -354,3 +702,36 @@
return DOM_NOT_SUPPORTED_ERR;
}
+
+/**
+ * Acquire a pointer to the base of the document buffer
+ *
+ * \param doc Document to retrieve pointer from
+ * \return Pointer to document buffer
+ *
+ * The document buffer is _not_ reference counted (as it is an implicit part
+ * of the document). It is destroyed with the document, and thus after all
+ * users have been destroyed.
+ */
+const uint8_t *dom_document_get_base(struct dom_document *doc)
+{
+ UNUSED(doc);
+
+ return NULL;
+}
+
+/**
+ * (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);
+}
Modified: trunk/dom/src/core/document.h
URL: http://source.netsurf-browser.org/trunk/dom/src/core/document.h?rev=3385&...
==============================================================================
--- trunk/dom/src/core/document.h (original)
+++ trunk/dom/src/core/document.h Fri Jul 6 22:42:18 2007
@@ -9,11 +9,11 @@
#define dom_internal_document_h_
#include <inttypes.h>
+#include <stddef.h>
-struct dom_ctx;
struct dom_document;
-const uint8_t *dom_document_get_base(struct dom_ctx *ctx,
- struct dom_document *doc);
+const uint8_t *dom_document_get_base(struct dom_document *doc);
+void *dom_document_alloc(struct dom_document *doc, void *ptr, size_t size);
#endif
Modified: trunk/dom/src/core/node.c
URL: http://source.netsurf-browser.org/trunk/dom/src/core/node.c?rev=3385&r1=3...
==============================================================================
--- trunk/dom/src/core/node.c (original)
+++ trunk/dom/src/core/node.c Fri Jul 6 22:42:18 2007
@@ -5,15 +5,13 @@
* Copyright 2007 John-Mark Bell <jmb(a)netsurf-browser.org>
*/
-#include <dom/ctx.h>
-
+#include "core/document.h"
#include "core/node.h"
#include "utils/utils.h"
/**
* Create a DOM node
*
- * \param ctx The context in which the node resides
* \param doc The document which owns the node
* \param type The node type required
* \param name The node name, or NULL
@@ -24,23 +22,22 @@
* The returned node will be referenced, so there is no need for the caller
* to explicitly reference it.
*/
-dom_exception dom_node_create(struct dom_ctx *ctx,
- struct dom_document *doc, dom_node_type type,
+dom_exception dom_node_create(struct dom_document *doc, dom_node_type type,
struct dom_string *name, struct dom_string *value,
struct dom_node **node)
{
struct dom_node *n;
- n = ctx->alloc(NULL, sizeof(struct dom_node), ctx->pw);
+ n = dom_document_alloc(doc, NULL, sizeof(struct dom_node));
if (n == NULL)
return DOM_NO_MEM_ERR;
if (name != NULL)
- dom_string_ref(ctx, name);
+ dom_string_ref(name);
n->name = name;
if (value != NULL)
- dom_string_ref(ctx, value);
+ dom_string_ref(value);
n->value = value;
n->type = type;
@@ -52,7 +49,7 @@
n->next = NULL;
n->attributes = NULL;
- dom_node_ref(ctx, (struct dom_node *) doc);
+ dom_node_ref((struct dom_node *) doc);
n->owner = doc;
/** \todo Namespace handling */
@@ -72,29 +69,23 @@
/**
* Claim a reference on a DOM node
*
- * \param ctx The context in which the node resides
* \param node The node to claim a reference on
*/
-void dom_node_ref(struct dom_ctx *ctx, struct dom_node *node)
-{
- UNUSED(ctx);
-
+void dom_node_ref(struct dom_node *node)
+{
node->refcnt++;
}
/**
* Release a reference on a DOM node
*
- * \param ctx The context in which the node resides
* \param node The node to release the reference from
*
* If the reference count reaches zero, any memory claimed by the
* node will be released
*/
-void dom_node_unref(struct dom_ctx *ctx, struct dom_node *node)
-{
- UNUSED(ctx);
-
+void dom_node_unref(struct dom_node *node)
+{
if (--node->refcnt == 0) {
/** \todo implement */
}
@@ -103,7 +94,6 @@
/**
* Retrieve the name of a DOM node
*
- * \param ctx The context in which the node resides
* \param node The node to retrieve the name of
* \param result Pointer to location to receive node name
* \return DOM_NO_ERR.
@@ -112,10 +102,9 @@
* the responsibility of the caller to unref the string once it has
* finished with it.
*/
-dom_exception dom_node_get_name(struct dom_ctx *ctx,
- struct dom_node *node, struct dom_string **result)
-{
- UNUSED(ctx);
+dom_exception dom_node_get_name(struct dom_node *node,
+ struct dom_string **result)
+{
UNUSED(node);
UNUSED(result);
@@ -125,7 +114,6 @@
/**
* Retrieve the value of a DOM node
*
- * \param ctx The context in which the node resides
* \param node The node to retrieve the value of
* \param result Pointer to location to receive node value
* \return DOM_NO_ERR.
@@ -137,10 +125,9 @@
* DOM3Core states that this can raise DOMSTRING_SIZE_ERR. It will not in
* this implementation; dom_strings are unbounded.
*/
-dom_exception dom_node_get_value(struct dom_ctx *ctx,
- struct dom_node *node, struct dom_string **result)
-{
- UNUSED(ctx);
+dom_exception dom_node_get_value(struct dom_node *node,
+ struct dom_string **result)
+{
UNUSED(node);
UNUSED(result);
@@ -150,7 +137,6 @@
/**
* Set the value of a DOM node
*
- * \param ctx The context in which the node resides
* \param node Node to set the value of
* \param value New value for node
* \return DOM_NO_ERR on success,
@@ -161,10 +147,9 @@
* should unref it after the call (as the caller should have already claimed
* a reference on the string). The node's existing value will be unrefed.
*/
-dom_exception dom_node_set_value(struct dom_ctx *ctx,
- struct dom_node *node, struct dom_string *value)
-{
- UNUSED(ctx);
+dom_exception dom_node_set_value(struct dom_node *node,
+ struct dom_string *value)
+{
UNUSED(node);
UNUSED(value);
@@ -174,16 +159,12 @@
/**
* Retrieve the type of a DOM node
*
- * \param ctx The context in which the node resides
* \param node The node to retrieve the type of
* \param result Pointer to location to receive node type
* \return DOM_NO_ERR.
*/
-dom_exception dom_node_get_type(struct dom_ctx *ctx,
- struct dom_node *node, dom_node_type *result)
-{
- UNUSED(ctx);
-
+dom_exception dom_node_get_type(struct dom_node *node, dom_node_type *result)
+{
*result = node->type;
return DOM_NO_ERR;
@@ -192,7 +173,6 @@
/**
* Retrieve the parent of a DOM node
*
- * \param ctx The context in which the node resides
* \param node The node to retrieve the parent of
* \param result Pointer to location to receive node parent
* \return DOM_NO_ERR.
@@ -201,12 +181,12 @@
* the responsibility of the caller to unref the node once it has
* finished with it.
*/
-dom_exception dom_node_get_parent(struct dom_ctx *ctx,
- struct dom_node *node, struct dom_node **result)
+dom_exception dom_node_get_parent(struct dom_node *node,
+ struct dom_node **result)
{
/* If there is a parent node, then increase its reference count */
if (node->parent != NULL)
- dom_node_ref(ctx, node->parent);
+ dom_node_ref(node->parent);
*result = node->parent;
@@ -216,17 +196,15 @@
/**
* Retrieve a list of children of a DOM node
*
- * \param ctx The context in which the node resides
* \param node The node to retrieve the children of
* \param result Pointer to location to receive child list
* \return DOM_NO_ERR.
*
* \todo Work out reference counting semantics of dom_node_list
*/
-dom_exception dom_node_get_children(struct dom_ctx *ctx,
- struct dom_node *node, struct dom_node_list **result)
-{
- UNUSED(ctx);
+dom_exception dom_node_get_children(struct dom_node *node,
+ struct dom_node_list **result)
+{
UNUSED(node);
UNUSED(result);
@@ -236,7 +214,6 @@
/**
* Retrieve the first child of a DOM node
*
- * \param ctx The context in which the node resides
* \param node The node to retrieve the first child of
* \param result Pointer to location to receive node's first child
* \return DOM_NO_ERR.
@@ -245,12 +222,12 @@
* the responsibility of the caller to unref the node once it has
* finished with it.
*/
-dom_exception dom_node_get_first_child(struct dom_ctx *ctx,
- struct dom_node *node, struct dom_node **result)
+dom_exception dom_node_get_first_child(struct dom_node *node,
+ struct dom_node **result)
{
/* If there is a first child, increase its reference count */
if (node->first_child != NULL)
- dom_node_ref(ctx, node->first_child);
+ dom_node_ref(node->first_child);
*result = node->first_child;
@@ -260,7 +237,6 @@
/**
* Retrieve the last child of a DOM node
*
- * \param ctx The context in which the node resides
* \param node The node to retrieve the last child of
* \param result Pointer to location to receive node's last child
* \return DOM_NO_ERR.
@@ -269,12 +245,12 @@
* the responsibility of the caller to unref the node once it has
* finished with it.
*/
-dom_exception dom_node_get_last_child(struct dom_ctx *ctx,
- struct dom_node *node, struct dom_node **result)
+dom_exception dom_node_get_last_child(struct dom_node *node,
+ struct dom_node **result)
{
/* If there is a last child, increase its reference count */
if (node->last_child != NULL)
- dom_node_ref(ctx, node->last_child);
+ dom_node_ref(node->last_child);
*result = node->last_child;
@@ -284,7 +260,6 @@
/**
* Retrieve the previous sibling of a DOM node
*
- * \param ctx The context in which the node resides
* \param node The node to retrieve the previous sibling of
* \param result Pointer to location to receive node's previous sibling
* \return DOM_NO_ERR.
@@ -293,12 +268,12 @@
* the responsibility of the caller to unref the node once it has
* finished with it.
*/
-dom_exception dom_node_get_previous(struct dom_ctx *ctx,
- struct dom_node *node, struct dom_node **result)
+dom_exception dom_node_get_previous(struct dom_node *node,
+ struct dom_node **result)
{
/* If there is a previous sibling, increase its reference count */
if (node->previous != NULL)
- dom_node_ref(ctx, node->previous);
+ dom_node_ref(node->previous);
*result = node->previous;
@@ -308,7 +283,6 @@
/**
* Retrieve the subsequent sibling of a DOM node
*
- * \param ctx The context in which the node resides
* \param node The node to retrieve the subsequent sibling of
* \param result Pointer to location to receive node's subsequent sibling
* \return DOM_NO_ERR.
@@ -317,12 +291,12 @@
* the responsibility of the caller to unref the node once it has
* finished with it.
*/
-dom_exception dom_node_get_next(struct dom_ctx *ctx,
- struct dom_node *node, struct dom_node **result)
+dom_exception dom_node_get_next(struct dom_node *node,
+ struct dom_node **result)
{
/* If there is a subsequent sibling, increase its reference count */
if (node->next != NULL)
- dom_node_ref(ctx, node->next);
+ dom_node_ref(node->next);
*result = node->next;
@@ -332,17 +306,15 @@
/**
* Retrieve a map of attributes associated with a DOM node
*
- * \param ctx The context in which the node resides
* \param node The node to retrieve the attributes of
* \param result Pointer to location to receive attribute map
* \return DOM_NO_ERR.
*
* \todo Work out reference counting semantics of dom_named_node_map
*/
-dom_exception dom_node_get_attributes(struct dom_ctx *ctx,
- struct dom_node *node, struct dom_named_node_map **result)
-{
- UNUSED(ctx);
+dom_exception dom_node_get_attributes(struct dom_node *node,
+ struct dom_named_node_map **result)
+{
UNUSED(node);
UNUSED(result);
@@ -352,7 +324,6 @@
/**
* Retrieve the owning document of a DOM node
*
- * \param ctx The context in which the node resides
* \param node The node to retrieve the owner of
* \param result Pointer to location to receive node's owner
* \return DOM_NO_ERR.
@@ -361,12 +332,12 @@
* the responsibility of the caller to unref the node once it has
* finished with it.
*/
-dom_exception dom_node_get_owner(struct dom_ctx *ctx,
- struct dom_node *node, struct dom_document **result)
+dom_exception dom_node_get_owner(struct dom_node *node,
+ struct dom_document **result)
{
/* If there is an owner, increase its reference count */
if (node->owner != NULL)
- dom_node_ref(ctx, (struct dom_node *) node->owner);
+ dom_node_ref((struct dom_node *) node->owner);
*result = node->owner;
@@ -376,7 +347,6 @@
/**
* Insert a child into a node
*
- * \param ctx The context in which the nodes reside
* \param node Node to insert into
* \param new_child Node to insert
* \param ref_child Node to insert before, or NULL to insert as last child
@@ -405,12 +375,10 @@
* ::new_child's reference count will be increased. The caller should unref
* it (as they should already have held a reference on the node)
*/
-dom_exception dom_node_insert_before(struct dom_ctx *ctx,
- struct dom_node *node,
+dom_exception dom_node_insert_before(struct dom_node *node,
struct dom_node *new_child, struct dom_node *ref_child,
struct dom_node **result)
{
- UNUSED(ctx);
UNUSED(node);
UNUSED(new_child);
UNUSED(ref_child);
@@ -422,7 +390,6 @@
/**
* Replace a node's child with a new one
*
- * \param ctx The context in which the nodes reside
* \param node Node whose child to replace
* \param new_child Replacement node
* \param old_child Child to replace
@@ -456,12 +423,10 @@
* transferred to the caller). The caller should unref ::old_child once it
* is finished with it.
*/
-dom_exception dom_node_replace_child(struct dom_ctx *ctx,
- struct dom_node *node,
+dom_exception dom_node_replace_child(struct dom_node *node,
struct dom_node *new_child, struct dom_node *old_child,
struct dom_node **result)
{
- UNUSED(ctx);
UNUSED(node);
UNUSED(new_child);
UNUSED(old_child);
@@ -473,7 +438,6 @@
/**
* Remove a child from a node
*
- * \param ctx The context in which the nodes reside
* \param node Node whose child to replace
* \param old_child Child to remove
* \param result Pointer to location to receive removed node
@@ -489,12 +453,10 @@
* transferred to the caller). The caller should unref ::old_child once it
* is finished with it.
*/
-dom_exception dom_node_remove_child(struct dom_ctx *ctx,
- struct dom_node *node,
+dom_exception dom_node_remove_child(struct dom_node *node,
struct dom_node *old_child,
struct dom_node **result)
{
- UNUSED(ctx);
UNUSED(node);
UNUSED(old_child);
UNUSED(result);
@@ -505,7 +467,6 @@
/**
* Append a child to the end of a node's child list
*
- * \param ctx The context in which the nodes reside
* \param node Node to insert into
* \param new_child Node to append
* \param result Pointer to location to receive node being inserted
@@ -531,28 +492,23 @@
* ::new_child's reference count will be increased. The caller should unref
* it (as they should already have held a reference on the node)
*/
-dom_exception dom_node_append_child(struct dom_ctx *ctx,
- struct dom_node *node,
+dom_exception dom_node_append_child(struct dom_node *node,
struct dom_node *new_child,
struct dom_node **result)
{
/* This is just a veneer over insert_before */
- return dom_node_insert_before(ctx, node, new_child, NULL, result);
+ return dom_node_insert_before(node, new_child, NULL, result);
}
/**
* Determine if a node has any children
*
- * \param ctx The context in which the node resides
* \param node Node to inspect
* \param result Pointer to location to receive result
* \return DOM_NO_ERR.
*/
-dom_exception dom_node_has_children(struct dom_ctx *ctx,
- struct dom_node *node, bool *result)
-{
- UNUSED(ctx);
-
+dom_exception dom_node_has_children(struct dom_node *node, bool *result)
+{
*result = node->first_child != NULL;
return DOM_NO_ERR;
@@ -561,7 +517,6 @@
/**
* Clone a DOM node
*
- * \param ctx The context in which the node resides
* \param node The node to clone
* \param deep True to deep-clone the node's sub-tree
* \param result Pointer to location to receive result
@@ -598,11 +553,9 @@
* \todo work out what happens when cloning Document, DocumentType, Entity
* and Notation nodes.
*/
-dom_exception dom_node_clone(struct dom_ctx *ctx,
- struct dom_node *node, bool deep,
+dom_exception dom_node_clone(struct dom_node *node, bool deep,
struct dom_node **result)
{
- UNUSED(ctx);
UNUSED(node);
UNUSED(deep);
UNUSED(result);
@@ -613,7 +566,6 @@
/**
* Normalize a DOM node
*
- * \param ctx The context in which the node resides
* \param node The node to normalize
* \return DOM_NO_ERR.
*
@@ -621,10 +573,8 @@
* including Attr nodes into "normal" form, where only structure separates
* Text nodes.
*/
-dom_exception dom_node_normalize(struct dom_ctx *ctx,
- struct dom_node *node)
-{
- UNUSED(ctx);
+dom_exception dom_node_normalize(struct dom_node *node)
+{
UNUSED(node);
return DOM_NOT_SUPPORTED_ERR;
@@ -634,18 +584,16 @@
* Test whether the DOM implementation implements a specific feature and
* that feature is supported by the node.
*
- * \param ctx The context in which the node resides
* \param node The node to test
* \param feature The name of the feature to test
* \param version The version number of the feature to test
* \param result Pointer to location to receive result
* \return DOM_NO_ERR.
*/
-dom_exception dom_node_is_supported(struct dom_ctx *ctx,
- struct dom_node *node, struct dom_string *feature,
- struct dom_node *version, bool *result)
-{
- UNUSED(ctx);
+dom_exception dom_node_is_supported(struct dom_node *node,
+ struct dom_string *feature, struct dom_node *version,
+ bool *result)
+{
UNUSED(node);
UNUSED(feature);
UNUSED(version);
@@ -657,7 +605,6 @@
/**
* Retrieve the namespace of a DOM node
*
- * \param ctx The context in which the node resides
* \param node The node to retrieve the namespace of
* \param result Pointer to location to receive node's namespace
* \return DOM_NO_ERR.
@@ -666,12 +613,12 @@
* the responsibility of the caller to unref the string once it has
* finished with it.
*/
-dom_exception dom_node_get_namespace(struct dom_ctx *ctx,
- struct dom_node *node, struct dom_string **result)
+dom_exception dom_node_get_namespace(struct dom_node *node,
+ struct dom_string **result)
{
/* If there is a namespace, increase its reference count */
if (node->namespace != NULL)
- dom_string_ref(ctx, node->namespace);
+ dom_string_ref(node->namespace);
*result = node->namespace;
@@ -681,7 +628,6 @@
/**
* Retrieve the prefix of a DOM node
*
- * \param ctx The context in which the node resides
* \param node The node to retrieve the prefix of
* \param result Pointer to location to receive node's prefix
* \return DOM_NO_ERR.
@@ -690,12 +636,12 @@
* the responsibility of the caller to unref the string once it has
* finished with it.
*/
-dom_exception dom_node_get_prefix(struct dom_ctx *ctx,
- struct dom_node *node, struct dom_string **result)
+dom_exception dom_node_get_prefix(struct dom_node *node,
+ struct dom_string **result)
{
/* If there is a prefix, increase its reference count */
if (node->prefix != NULL)
- dom_string_ref(ctx, node->prefix);
+ dom_string_ref(node->prefix);
*result = node->prefix;
@@ -705,7 +651,6 @@
/**
* Set the prefix of a DOM node
*
- * \param ctx The context in which the node resides
* \param node The node to set the prefix of
* \param prefix Pointer to prefix string
* \return DOM_NO_ERR on success,
@@ -726,10 +671,9 @@
* and the qualifiedName of ::node
* is "xmlns".
*/
-dom_exception dom_node_set_prefix(struct dom_ctx *ctx,
- struct dom_node *node, struct dom_string *prefix)
-{
- UNUSED(ctx);
+dom_exception dom_node_set_prefix(struct dom_node *node,
+ struct dom_string *prefix)
+{
UNUSED(node);
UNUSED(prefix);
@@ -739,7 +683,6 @@
/**
* Retrieve the local part of a node's qualified name
*
- * \param ctx The context in which the node resides
* \param node The node to retrieve the local name of
* \param result Pointer to location to receive local name
* \return DOM_NO_ERR.
@@ -748,12 +691,12 @@
* the responsibility of the caller to unref the string once it has
* finished with it.
*/
-dom_exception dom_node_get_local_name(struct dom_ctx *ctx,
- struct dom_node *node, struct dom_string **result)
+dom_exception dom_node_get_local_name(struct dom_node *node,
+ struct dom_string **result)
{
/* If there is a local name, increase its reference count */
if (node->localname != NULL)
- dom_string_ref(ctx, node->localname);
+ dom_string_ref(node->localname);
*result = node->localname;
@@ -763,16 +706,12 @@
/**
* Determine if a node has any attributes
*
- * \param ctx The context in which the node resides
* \param node Node to inspect
* \param result Pointer to location to receive result
* \return DOM_NO_ERR.
*/
-dom_exception dom_node_has_attributes(struct dom_ctx *ctx,
- struct dom_node *node, bool *result)
-{
- UNUSED(ctx);
-
+dom_exception dom_node_has_attributes(struct dom_node *node, bool *result)
+{
*result = node->attributes != NULL;
return DOM_NO_ERR;
@@ -781,7 +720,6 @@
/**
* Retrieve the base URI of a DOM node
*
- * \param ctx The context in which the node resides
* \param node The node to retrieve the base URI of
* \param result Pointer to location to receive base URI
* \return DOM_NO_ERR.
@@ -790,10 +728,9 @@
* the responsibility of the caller to unref the string once it has
* finished with it.
*/
-dom_exception dom_node_get_base(struct dom_ctx *ctx,
- struct dom_node *node, struct dom_string **result)
-{
- UNUSED(ctx);
+dom_exception dom_node_get_base(struct dom_node *node,
+ struct dom_string **result)
+{
UNUSED(node);
UNUSED(result);
@@ -803,7 +740,6 @@
/**
* Compare the positions of two nodes in a DOM tree
*
- * \param ctx The context in which the nodes reside
* \param node The reference node
* \param other The node to compare
* \param result Pointer to location to receive result
@@ -813,11 +749,9 @@
*
* The result is a bitfield of dom_document_position values.
*/
-dom_exception dom_node_compare_document_position(struct dom_ctx *ctx,
- struct dom_node *node, struct dom_node *other,
- uint16_t *result)
-{
- UNUSED(ctx);
+dom_exception dom_node_compare_document_position(struct dom_node *node,
+ struct dom_node *other, uint16_t *result)
+{
UNUSED(node);
UNUSED(other);
UNUSED(result);
@@ -828,7 +762,6 @@
/**
* Retrieve the text content of a DOM node
*
- * \param ctx The context in which the node resides
* \param node The node to retrieve the text content of
* \param result Pointer to location to receive text content
* \return DOM_NO_ERR.
@@ -840,10 +773,9 @@
* DOM3Core states that this can raise DOMSTRING_SIZE_ERR. It will not in
* this implementation; dom_strings are unbounded.
*/
-dom_exception dom_node_get_text_content(struct dom_ctx *ctx,
- struct dom_node *node, struct dom_string **result)
-{
- UNUSED(ctx);
+dom_exception dom_node_get_text_content(struct dom_node *node,
+ struct dom_string **result)
+{
UNUSED(node);
UNUSED(result);
@@ -853,7 +785,6 @@
/**
* Set the text content of a DOM node
*
- * \param ctx The context in which the node resides
* \param node The node to set the text content of
* \param content New text content for node
* \return DOM_NO_ERR on success,
@@ -862,10 +793,9 @@
* Any child nodes ::node may have are removed and replaced with a single
* Text node containing the new content.
*/
-dom_exception dom_node_set_text_content(struct dom_ctx *ctx,
- struct dom_node *node, struct dom_string *content)
-{
- UNUSED(ctx);
+dom_exception dom_node_set_text_content(struct dom_node *node,
+ struct dom_string *content)
+{
UNUSED(node);
UNUSED(content);
@@ -875,7 +805,6 @@
/**
* Determine if two DOM nodes are the same
*
- * \param ctx The context in which the nodes reside
* \param node The node to compare
* \param other The node to compare against
* \param result Pointer to location to receive result
@@ -883,12 +812,9 @@
*
* This tests if the two nodes reference the same object.
*/
-dom_exception dom_node_is_same(struct dom_ctx *ctx,
- struct dom_node *node, struct dom_node *other,
+dom_exception dom_node_is_same(struct dom_node *node, struct dom_node *other,
bool *result)
{
- UNUSED(ctx);
-
*result = (node == other);
return DOM_NO_ERR;
@@ -897,7 +823,6 @@
/**
* Lookup the prefix associated with the given namespace URI
*
- * \param ctx The context in which the node resides
* \param node The node to start prefix search from
* \param namespace The namespace URI
* \param result Pointer to location to receive result
@@ -907,11 +832,9 @@
* the responsibility of the caller to unref the string once it has
* finished with it.
*/
-dom_exception dom_node_lookup_prefix(struct dom_ctx *ctx,
- struct dom_node *node, struct dom_string *namespace,
- struct dom_string **result)
-{
- UNUSED(ctx);
+dom_exception dom_node_lookup_prefix(struct dom_node *node,
+ struct dom_string *namespace, struct dom_string **result)
+{
UNUSED(node);
UNUSED(namespace);
UNUSED(result);
@@ -922,17 +845,14 @@
/**
* Determine if the specified namespace is the default namespace
*
- * \param ctx The context in which the node resides
* \param node The node to query
* \param namespace The namespace URI to test
* \param result Pointer to location to receive result
* \return DOM_NO_ERR.
*/
-dom_exception dom_node_is_default_namespace(struct dom_ctx *ctx,
- struct dom_node *node, struct dom_string *namespace,
- bool *result)
-{
- UNUSED(ctx);
+dom_exception dom_node_is_default_namespace(struct dom_node *node,
+ struct dom_string *namespace, bool *result)
+{
UNUSED(node);
UNUSED(namespace);
UNUSED(result);
@@ -943,7 +863,6 @@
/**
* Lookup the namespace URI associated with the given prefix
*
- * \param ctx The context in which the node resides
* \param node The node to start namespace search from
* \param prefix The prefix to look for, or NULL to find default.
* \param result Pointer to location to receive result
@@ -953,11 +872,9 @@
* the responsibility of the caller to unref the string once it has
* finished with it.
*/
-dom_exception dom_node_lookup_namespace(struct dom_ctx *ctx,
- struct dom_node *node, struct dom_string *prefix,
- struct dom_string **result)
-{
- UNUSED(ctx);
+dom_exception dom_node_lookup_namespace(struct dom_node *node,
+ struct dom_string *prefix, struct dom_string **result)
+{
UNUSED(node);
UNUSED(prefix);
UNUSED(result);
@@ -968,7 +885,6 @@
/**
* Determine if two DOM nodes are equal
*
- * \param ctx The context in which the nodes reside
* \param node The node to compare
* \param other The node to compare against
* \param result Pointer to location to receive result
@@ -985,11 +901,9 @@
* + The node entities are equal
* + The node notations are equal
*/
-dom_exception dom_node_is_equal(struct dom_ctx *ctx,
- struct dom_node *node, struct dom_node *other,
- bool *result)
-{
- UNUSED(ctx);
+dom_exception dom_node_is_equal(struct dom_node *node,
+ struct dom_node *other, bool *result)
+{
UNUSED(node);
UNUSED(other);
UNUSED(result);
@@ -1001,18 +915,16 @@
* Retrieve an object which implements the specialized APIs of the specified
* feature and version.
*
- * \param ctx The context in which the node resides
* \param node The node to query
* \param feature The requested feature
* \param version The version number of the feature
* \param result Pointer to location to receive result
* \return DOM_NO_ERR.
*/
-dom_exception dom_node_get_feature(struct dom_ctx *ctx,
- struct dom_node *node, struct dom_string *feature,
- struct dom_string *version, void **result)
-{
- UNUSED(ctx);
+dom_exception dom_node_get_feature(struct dom_node *node,
+ struct dom_string *feature, struct dom_string *version,
+ void **result)
+{
UNUSED(node);
UNUSED(feature);
UNUSED(version);
@@ -1024,7 +936,6 @@
/**
* Associate an object to a key on this node
*
- * \param ctx The context in which the node resides
* \param node The node to insert object into
* \param key The key associated with the object
* \param data The object to associate with key, or NULL to remove
@@ -1032,12 +943,10 @@
* \param result Pointer to location to receive previously associated object
* \return DOM_NO_ERR.
*/
-dom_exception dom_node_set_user_data(struct dom_ctx *ctx,
- struct dom_node *node, struct dom_string *key,
- void *data, dom_user_data_handler handler,
- void **result)
-{
- UNUSED(ctx);
+dom_exception dom_node_set_user_data(struct dom_node *node,
+ struct dom_string *key, void *data,
+ dom_user_data_handler handler, void **result)
+{
UNUSED(node);
UNUSED(key);
UNUSED(data);
@@ -1050,17 +959,14 @@
/**
* Retrieves the object associated to a key on this node
*
- * \param ctx The context in which the node resides
* \param node The node to retrieve object from
* \param key The key to search for
* \param result Pointer to location to receive result
* \return DOM_NO_ERR.
*/
-dom_exception dom_node_get_user_data(struct dom_ctx *ctx,
- struct dom_node *node, struct dom_string *key,
- void **result)
-{
- UNUSED(ctx);
+dom_exception dom_node_get_user_data(struct dom_node *node,
+ struct dom_string *key, void **result)
+{
UNUSED(node);
UNUSED(key);
UNUSED(result);
Modified: trunk/dom/src/core/node.h
URL: http://source.netsurf-browser.org/trunk/dom/src/core/node.h?rev=3385&r1=3...
==============================================================================
--- trunk/dom/src/core/node.h (original)
+++ trunk/dom/src/core/node.h Fri Jul 6 22:42:18 2007
@@ -52,8 +52,7 @@
uint32_t refcnt; /**< Reference count */
};
-dom_exception dom_node_create(struct dom_ctx *ctx,
- struct dom_document *doc, dom_node_type type,
+dom_exception dom_node_create(struct dom_document *doc, dom_node_type type,
struct dom_string *name, struct dom_string *value,
struct dom_node **node);
Modified: trunk/dom/src/core/string.c
URL: http://source.netsurf-browser.org/trunk/dom/src/core/string.c?rev=3385&r1...
==============================================================================
--- trunk/dom/src/core/string.c (original)
+++ trunk/dom/src/core/string.c Fri Jul 6 22:42:18 2007
@@ -8,7 +8,6 @@
#include <inttypes.h>
#include <string.h>
-#include <dom/ctx.h>
#include <dom/core/string.h>
#include "core/document.h"
@@ -26,57 +25,51 @@
enum { DOM_STRING_PTR,
DOM_STRING_CONST_PTR,
DOM_STRING_OFFSET
- } type;
+ } type; /**< String type */
union {
uint8_t *ptr;
const uint8_t *cptr;
- struct {
- struct dom_document *doc;
- uint32_t off;
- } offset;
- } data;
-
- size_t len;
-
- uint32_t refcnt;
+ uint32_t offset;
+ } data; /**< Type-specific data */
+
+ size_t len; /**< Byte length of string */
+
+ struct dom_document *doc; /**< Owning document */
+
+ uint32_t refcnt; /**< Reference count */
};
/**
* Claim a reference on a DOM string
*
- * \param ctx The context in which the string resides
* \param str The string to claim a reference on
*/
-void dom_string_ref(struct dom_ctx *ctx, struct dom_string *str)
-{
- UNUSED(ctx);
-
+void dom_string_ref(struct dom_string *str)
+{
str->refcnt++;
}
/**
* Release a reference on a DOM string
*
- * \param ctx The context in which the string resides
* \param str The string to release the reference from
*
* If the reference count reaches zero, any memory claimed by the
* string will be released
*/
-void dom_string_unref(struct dom_ctx *ctx, struct dom_string *str)
+void dom_string_unref(struct dom_string *str)
{
if (--str->refcnt == 0) {
if (str->type == DOM_STRING_PTR)
- ctx->alloc(str->data.ptr, 0, ctx->pw);
-
- ctx->alloc(str, 0, ctx->pw);
+ dom_document_alloc(str->doc, str->data.ptr, 0);
+
+ dom_document_alloc(str->doc, str, 0);
}
}
/**
* Create a DOM string from an offset into the document buffer
*
- * \param ctx The context in which the string resides
* \param doc The document in which the string resides
* \param off Offset from start of document buffer
* \param len Length, in bytes, of string
@@ -86,21 +79,23 @@
* The returned string will already be referenced, so there is no need
* to explicitly reference it.
*/
-dom_exception dom_string_create_from_off(struct dom_ctx *ctx,
- struct dom_document *doc, uint32_t off, size_t len,
- struct dom_string **str)
+dom_exception dom_string_create_from_off(struct dom_document *doc,
+ uint32_t off, size_t len, struct dom_string **str)
{
struct dom_string *ret;
- ret = ctx->alloc(NULL, sizeof(struct dom_string), ctx->pw);
+ ret = dom_document_alloc(doc, NULL, sizeof(struct dom_string));
if (ret == NULL)
return DOM_NO_MEM_ERR;
ret->type = DOM_STRING_OFFSET;
- ret->data.offset.doc = doc;
- ret->data.offset.off = off;
+
+ ret->data.offset = off;
+
ret->len = len;
+ ret->doc = doc;
+
ret->refcnt = 1;
*str = ret;
@@ -111,7 +106,7 @@
/**
* Create a DOM string from a string of characters
*
- * \param ctx The context in which the string resides
+ * \param doc The document in which the string resides
* \param ptr Pointer to string of characters
* \param len Length, in bytes, of string of characters
* \param str Pointer to location to receive pointer to new string
@@ -123,18 +118,18 @@
* The string of characters passed in will be copied for use by the
* returned DOM string.
*/
-dom_exception dom_string_create_from_ptr(struct dom_ctx *ctx,
+dom_exception dom_string_create_from_ptr(struct dom_document *doc,
const uint8_t *ptr, size_t len, struct dom_string **str)
{
struct dom_string *ret;
- ret = ctx->alloc(NULL, sizeof(struct dom_string), ctx->pw);
+ ret = dom_document_alloc(doc, NULL, sizeof(struct dom_string));
if (ret == NULL)
return DOM_NO_MEM_ERR;
- ret->data.ptr = ctx->alloc(NULL, len, ctx->pw);
+ ret->data.ptr = dom_document_alloc(doc, NULL, len);
if (ret->data.ptr == NULL) {
- ctx->alloc(ret, 0, ctx->pw);
+ dom_document_alloc(doc, ret, 0);
return DOM_NO_MEM_ERR;
}
@@ -144,6 +139,8 @@
ret->len = len;
+ ret->doc = doc;
+
ret->refcnt = 1;
*str = ret;
@@ -154,7 +151,7 @@
/**
* Create a DOM string from a constant string of characters
*
- * \param ctx The context in which the string resides
+ * \param doc The document in which the string resides
* \param ptr Pointer to string of characters
* \param len Length, in bytes, of string of characters
* \param str Pointer to location to receive pointer to new string
@@ -166,21 +163,23 @@
* The string of characters passed in will _not_ be copied for use by the
* returned DOM string.
*/
-dom_exception dom_string_create_from_const_ptr(struct dom_ctx *ctx,
+dom_exception dom_string_create_from_const_ptr(struct dom_document *doc,
const uint8_t *ptr, size_t len, struct dom_string **str)
{
struct dom_string *ret;
- ret = ctx->alloc(NULL, sizeof(struct dom_string), ctx->pw);
+ ret = dom_document_alloc(doc, NULL, sizeof(struct dom_string));
if (ret == NULL)
return DOM_NO_MEM_ERR;
+ ret->type = DOM_STRING_CONST_PTR;
+
ret->data.cptr = ptr;
- ret->type = DOM_STRING_CONST_PTR;
-
ret->len = len;
+ ret->doc = doc;
+
ret->refcnt = 1;
*str = ret;
@@ -191,7 +190,6 @@
/**
* Get a pointer to the string of characters within a DOM string
*
- * \param ctx The context in which the string resides
* \param str Pointer to DOM string to retrieve pointer from
* \param data Pointer to location to receive data
* \param len Pointer to location to receive byte length of data
@@ -200,8 +198,8 @@
* The caller must have previously claimed a reference on the DOM string.
* The returned pointer must not be freed.
*/
-dom_exception dom_string_get_data(struct dom_ctx *ctx,
- struct dom_string *str, const uint8_t **data, size_t *len)
+dom_exception dom_string_get_data(struct dom_string *str,
+ const uint8_t **data, size_t *len)
{
switch (str->type) {
case DOM_STRING_PTR:
@@ -211,8 +209,7 @@
*data = str->data.cptr;
break;
case DOM_STRING_OFFSET:
- *data = dom_document_get_base(ctx, str->data.offset.doc) +
- str->data.offset.off;
+ *data = dom_document_get_base(str->doc) + str->data.offset;
break;
}
16 years, 2 months
r3384 jmb - in /trunk/dom: ./ build/ docs/ include/ include/dom/ include/dom/core/ src/ src/core/ src/utils/ test/ test/data/
by netsurf@semichrome.net
Author: jmb
Date: Fri Jul 6 15:32:44 2007
New Revision: 3384
URL: http://source.netsurf-browser.org?rev=3384&view=rev
Log:
Import DOM library.
This is mainly stub functions atm (and is missing a number of key interfaces).
Added:
trunk/dom/
trunk/dom/COPYING
trunk/dom/Makefile
trunk/dom/Makefile-riscos
trunk/dom/README
trunk/dom/build/
trunk/dom/build/Makefile.common
trunk/dom/docs/
trunk/dom/docs/Todo
trunk/dom/include/
trunk/dom/include/dom/
trunk/dom/include/dom/core/
trunk/dom/include/dom/core/attr.h
trunk/dom/include/dom/core/document.h
trunk/dom/include/dom/core/exceptions.h
trunk/dom/include/dom/core/node.h
trunk/dom/include/dom/core/string.h
trunk/dom/include/dom/ctx.h
trunk/dom/src/
trunk/dom/src/Makefile
trunk/dom/src/core/
trunk/dom/src/core/Makefile
trunk/dom/src/core/attr.c
trunk/dom/src/core/document.c
trunk/dom/src/core/document.h
trunk/dom/src/core/node.c
trunk/dom/src/core/node.h
trunk/dom/src/core/string.c
trunk/dom/src/utils/
trunk/dom/src/utils/utils.h
trunk/dom/test/
trunk/dom/test/INDEX
trunk/dom/test/Makefile
trunk/dom/test/data/
trunk/dom/test/testrunner.pl
Added: trunk/dom/COPYING
URL: http://source.netsurf-browser.org/trunk/dom/COPYING?rev=3384&view=auto
==============================================================================
--- trunk/dom/COPYING (added)
+++ trunk/dom/COPYING Fri Jul 6 15:32:44 2007
@@ -1,0 +1,19 @@
+Copyright (C) 2007 J-M Bell
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+ * The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
Added: trunk/dom/Makefile
URL: http://source.netsurf-browser.org/trunk/dom/Makefile?rev=3384&view=auto
==============================================================================
--- trunk/dom/Makefile (added)
+++ trunk/dom/Makefile Fri Jul 6 15:32:44 2007
@@ -1,0 +1,34 @@
+# Toolchain definitions for building on the destination platform
+export CC = gcc
+export AR = ar
+export LD = gcc
+
+export CP = cp
+export RM = rm
+export MKDIR = mkdir
+export MV = mv
+export ECHO = echo
+export MAKE = make
+export PERL = perl
+export PKGCONFIG = pkg-config
+
+# Toolchain flags
+WARNFLAGS = -Wall -Wextra -Wundef -Wpointer-arith -Wcast-align \
+ -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes \
+ -Wmissing-declarations -Wnested-externs -Werror -pedantic
+export CFLAGS = -std=c99 -D_BSD_SOURCE -I$(TOP)/include/ $(WARNFLAGS)
+export ARFLAGS = -cru
+export LDFLAGS = -L$(TOP)/
+
+export CPFLAGS =
+export RMFLAGS =
+export MKDIRFLAGS = -p
+export MVFLAGS =
+export ECHOFLAGS =
+export MAKEFLAGS =
+export PKGCONFIGFLAGS =
+
+export EXEEXT =
+
+
+include build/Makefile.common
Added: trunk/dom/Makefile-riscos
URL: http://source.netsurf-browser.org/trunk/dom/Makefile-riscos?rev=3384&view...
==============================================================================
--- trunk/dom/Makefile-riscos (added)
+++ trunk/dom/Makefile-riscos Fri Jul 6 15:32:44 2007
@@ -1,0 +1,38 @@
+# Toolchain definitions for building for RISC OS using the GCCSDK cross-compiler
+GCCSDK_INSTALL_CROSSBIN ?= /home/riscos/cross/bin
+GCCSDK_INSTALL_ENV ?= /home/riscos/env
+
+export CC = $(GCCSDK_INSTALL_CROSSBIN)/gcc
+export AR = $(GCCSDK_INSTALL_CROSSBIN)/ar
+export LD = $(GCCSDK_INSTALL_CROSSBIN)/gcc
+
+export CP = cp
+export RM = rm
+export MKDIR = mkdir
+export MV = mv
+export ECHO = echo
+export MAKE = make
+export PERL = perl
+export PKGCONFIG = pkg-config
+
+# Toolchain flags
+WARNFLAGS = -Wall -Wextra -Wundef -Wpointer-arith -Wcast-align \
+ -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes \
+ -Wmissing-declarations -Wnested-externs -Werror -pedantic
+export CFLAGS = -std=c99 -D_BSD_SOURCE -I$(TOP)/include/ $(WARNFLAGS) \
+ -mpoke-function-name
+export ARFLAGS = -cru
+export LDFLAGS = -L$(TOP)/
+
+export CPFLAGS =
+export RMFLAGS =
+export MKDIRFLAGS = -p
+export MVFLAGS =
+export ECHOFLAGS =
+export MAKEFLAGS =
+export PKGCONFIGFLAGS =
+
+export EXEEXT = ,ff8
+
+
+include build/Makefile.common
Added: trunk/dom/README
URL: http://source.netsurf-browser.org/trunk/dom/README?rev=3384&view=auto
==============================================================================
--- trunk/dom/README (added)
+++ trunk/dom/README Fri Jul 6 15:32:44 2007
@@ -1,0 +1,39 @@
+libdom -- an implementation of the W3C DOM
+==========================================
+
+Overview
+--------
+
+ libdom is an implementation of the W3C DOM API in C.
+
+Requirements
+------------
+
+ libdom requires the following tools:
+
+ + A C99 capable C compiler
+ + GNU make or compatible
+ + Perl (for the testcases)
+
+Compilation
+-----------
+
+ If necessary, modify the toolchain settings in the Makefile.
+ Invoke make:
+ $ make
+
+Verification
+------------
+
+ To verify that the library is working, it is necessary to specify a
+ different makefile target than that used for normal compilation, thus:
+
+ $ make test
+
+API documentation
+-----------------
+
+ Currently, there is none. However, the code is well commented and the
+ public API may be found in the "include" directory. The testcase sources
+ may also be of use in working out how to use it.
+
Added: trunk/dom/build/Makefile.common
URL: http://source.netsurf-browser.org/trunk/dom/build/Makefile.common?rev=338...
==============================================================================
--- trunk/dom/build/Makefile.common (added)
+++ trunk/dom/build/Makefile.common Fri Jul 6 15:32:44 2007
@@ -1,0 +1,39 @@
+# Top-level Makefile fragment for DOM library
+
+# Name of component
+export COMPONENT = libdom
+
+# Environment
+export EXPORT = $(CURDIR)/dist
+export TOP = $(CURDIR)
+
+.PHONY: release debug test clean setup export distclean
+
+# Rules
+release: setup
+ @$(MAKE) $(MAKEFLAGS) -C src release
+
+debug: setup
+ @$(MAKE) $(MAKEFLAGS) -C src debug
+
+test: debug
+ @$(MAKE) $(MAKEFLAGS) -C test test
+
+clean:
+ @$(MAKE) $(MAKEFLAGS) -C src clean
+ @$(MAKE) $(MAKEFLAGS) -C test clean
+
+setup:
+ @$(MAKE) $(MAKEFLAGS) -C src setup
+ @$(MAKE) $(MAKEFLAGS) -C test setup
+
+export: release
+ @$(MKDIR) $(MKDIRFLAGS) $(TOP)/dist/lib
+ @$(CP) $(CPFLAGS) -r include $(EXPORT)/
+ @$(MAKE) $(MAKEFLAGS) -C src export
+ @$(MAKE) $(MAKEFLAGS) -C test export
+
+distclean: clean
+ -@$(RM) $(RMFLAGS) -r $(TOP)/dist
+ @$(MAKE) $(MAKEFLAGS) -C src distclean
+ @$(MAKE) $(MAKEFLAGS) -C test distclean
Added: trunk/dom/docs/Todo
URL: http://source.netsurf-browser.org/trunk/dom/docs/Todo?rev=3384&view=auto
==============================================================================
--- trunk/dom/docs/Todo (added)
+++ trunk/dom/docs/Todo Fri Jul 6 15:32:44 2007
@@ -1,0 +1,14 @@
+TODO list
+=========
+
+ + Sort out the mess that is dom_ctx - I really don't like it; everything (except dom_strings)
+ should be allocated in the context of a document and, thus, the context is easily found
+ through foo->owner->blah. dom_strings are somewhat awkward here, as they aren't necessarily
+ allocated in the context of a document, but they still need access to an allocator. Perhaps
+ the simplest solution is for the string constructors to take an allocator and private word
+ as parameters, then store them within the string. This does, however, add an overhead of
+ 8 (or 16 on 64bit platforms) bytes per dom_string, which isn't exactly great.
+ + Fill out stub functions for DOM3 core
+ + Rest of DOM level 3
+ + DOM level 2
+ + DOM level 1
Added: trunk/dom/include/dom/core/attr.h
URL: http://source.netsurf-browser.org/trunk/dom/include/dom/core/attr.h?rev=3...
==============================================================================
--- trunk/dom/include/dom/core/attr.h (added)
+++ trunk/dom/include/dom/core/attr.h Fri Jul 6 15:32:44 2007
@@ -1,0 +1,37 @@
+/*
+ * This file is part of libdom.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2007 John-Mark Bell <jmb(a)netsurf-browser.org>
+ */
+
+#ifndef dom_core_attr_h_
+#define dom_core_attr_h_
+
+#include <stdbool.h>
+
+#include <dom/core/exceptions.h>
+
+struct dom_ctx;
+struct dom_element;
+struct dom_typeinfo;
+struct dom_node;
+struct dom_attr;
+struct dom_string;
+
+dom_exception dom_attr_get_name(struct dom_ctx *ctx,
+ struct dom_attr *attr, struct dom_string **result);
+dom_exception dom_attr_get_specified(struct dom_ctx *ctx,
+ struct dom_attr *attr, bool *result);
+dom_exception dom_attr_get_value(struct dom_ctx *ctx,
+ struct dom_attr *attr, struct dom_string **result);
+dom_exception dom_attr_set_value(struct dom_ctx *ctx,
+ struct dom_attr *attr, struct dom_string *value);
+dom_exception dom_attr_get_owner(struct dom_ctx *ctx,
+ struct dom_attr *attr, struct dom_element **result);
+dom_exception dom_attr_get_typeinfo(struct dom_ctx *ctx,
+ struct dom_attr *attr, struct dom_typeinfo **result);
+dom_exception dom_attr_is_id(struct dom_ctx *ctx,
+ struct dom_attr *attr, bool *result);
+
+#endif
Added: trunk/dom/include/dom/core/document.h
URL: http://source.netsurf-browser.org/trunk/dom/include/dom/core/document.h?r...
==============================================================================
--- trunk/dom/include/dom/core/document.h (added)
+++ trunk/dom/include/dom/core/document.h Fri Jul 6 15:32:44 2007
@@ -1,0 +1,105 @@
+/*
+ * This file is part of libdom.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2007 John-Mark Bell <jmb(a)netsurf-browser.org>
+ */
+
+#ifndef dom_core_document_h_
+#define dom_core_document_h_
+
+#include <stdbool.h>
+
+#include <dom/core/exceptions.h>
+
+struct dom_attr;
+struct dom_configuration;
+struct dom_ctx;
+struct dom_document;
+struct dom_document_type;
+struct dom_element;
+struct dom_implementation;
+struct dom_node;
+struct dom_nodelist;
+struct dom_string;
+struct dom_text;
+
+dom_exception dom_document_get_doctype(struct dom_ctx *ctx,
+ struct dom_document *doc, struct dom_document_type **result);
+dom_exception dom_document_get_implementation(struct dom_ctx *ctx,
+ struct dom_document *doc,
+ struct dom_implementation **result);
+dom_exception dom_document_get_element(struct dom_ctx *ctx,
+ struct dom_document *doc, struct dom_element **result);
+dom_exception dom_document_create_element(struct dom_ctx *ctx,
+ struct dom_document *doc, struct dom_string *tag_name,
+ struct dom_element **result);
+dom_exception dom_document_create_document_fragment(struct dom_ctx *ctx,
+ struct dom_document *doc, struct dom_node **result);
+dom_exception dom_document_create_text_node(struct dom_ctx *ctx,
+ struct dom_document *doc, struct dom_string *data,
+ struct dom_text **result);
+dom_exception dom_document_create_cdata_section(struct dom_ctx *ctx,
+ struct dom_document *doc, struct dom_string *data,
+ struct dom_text **result);
+dom_exception dom_document_create_processing_instruction(struct dom_ctx *ctx,
+ struct dom_document *doc, struct dom_string *target,
+ struct dom_string *data,
+ struct dom_node **result);
+dom_exception dom_document_create_attribute(struct dom_ctx *ctx,
+ struct dom_document *doc, struct dom_string *name,
+ struct dom_attr **result);
+dom_exception dom_document_create_entity_reference(struct dom_ctx *ctx,
+ struct dom_document *doc, struct dom_string *name,
+ struct dom_node **result);
+dom_exception dom_document_get_elements_by_tag_name(struct dom_ctx *ctx,
+ struct dom_document *doc, struct dom_string *tagname,
+ struct dom_nodelist **result);
+dom_exception dom_document_import_node(struct dom_ctx *ctx,
+ struct dom_document *doc, struct dom_node *node,
+ bool deep, struct dom_node **result);
+dom_exception dom_document_create_element_ns(struct dom_ctx *ctx,
+ struct dom_document *doc, struct dom_string *namespace,
+ struct dom_string *qname, struct dom_element **result);
+dom_exception dom_document_create_attribute_ns(struct dom_ctx *ctx,
+ struct dom_document *doc, struct dom_string *namespace,
+ struct dom_string *qname, struct dom_attr **result);
+dom_exception dom_document_get_elements_by_tag_name_ns(struct dom_ctx *ctx,
+ struct dom_document *doc, struct dom_string *namespace,
+ struct dom_string *localname, struct dom_nodelist **result);
+dom_exception dom_document_get_element_by_id(struct dom_ctx *ctx,
+ struct dom_document *doc, struct dom_string *id,
+ struct dom_element **result);
+dom_exception dom_document_get_input_encoding(struct dom_ctx *ctx,
+ struct dom_document *doc, struct dom_string **result);
+dom_exception dom_document_get_xml_encoding(struct dom_ctx *ctx,
+ struct dom_document *doc, struct dom_string **result);
+dom_exception dom_document_get_xml_standalone(struct dom_ctx *ctx,
+ struct dom_document *doc, bool *result);
+dom_exception dom_document_set_xml_standalone(struct dom_ctx *ctx,
+ struct dom_document *doc, bool standalone);
+dom_exception dom_document_get_xml_version(struct dom_ctx *ctx,
+ struct dom_document *doc, struct dom_string **result);
+dom_exception dom_document_set_xml_version(struct dom_ctx *ctx,
+ struct dom_document *doc, struct dom_string *version);
+dom_exception dom_document_get_strict_error_checking(struct dom_ctx *ctx,
+ struct dom_document *doc, bool *result);
+dom_exception dom_document_set_strict_error_checking(struct dom_ctx *ctx,
+ struct dom_document *doc, bool strict);
+dom_exception dom_document_get_uri(struct dom_ctx *ctx,
+ struct dom_document *doc, struct dom_string **result);
+dom_exception dom_document_set_uri(struct dom_ctx *ctx,
+ struct dom_document *doc, struct dom_string *uri);
+dom_exception dom_document_adopt_node(struct dom_ctx *ctx,
+ struct dom_document *doc, struct dom_node *node,
+ struct dom_node **result);
+dom_exception dom_document_get_dom_config(struct dom_ctx *ctx,
+ struct dom_document *doc, struct dom_configuration **result);
+dom_exception dom_document_normalize(struct dom_ctx *ctx,
+ struct dom_document *doc);
+dom_exception dom_document_rename_node(struct dom_ctx *ctx,
+ struct dom_document *doc, struct dom_node *node,
+ struct dom_string *namespace, struct dom_string *qname,
+ struct dom_node **result);
+
+#endif
Added: trunk/dom/include/dom/core/exceptions.h
URL: http://source.netsurf-browser.org/trunk/dom/include/dom/core/exceptions.h...
==============================================================================
--- trunk/dom/include/dom/core/exceptions.h (added)
+++ trunk/dom/include/dom/core/exceptions.h Fri Jul 6 15:32:44 2007
@@ -1,0 +1,34 @@
+/*
+ * This file is part of libdom.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2007 John-Mark Bell <jmb(a)netsurf-browser.org>
+ */
+
+#ifndef dom_errors_h_
+#define dom_errors_h_
+
+/* The DOM spec says that this is actually an unsigned short */
+typedef enum {
+ DOM_NO_ERR = 0,
+ DOM_INDEX_SIZE_ERR = 1,
+ DOM_DOMSTRING_SIZE_ERR = 2,
+ DOM_HIERARCHY_REQUEST_ERR = 3,
+ DOM_WRONG_DOCUMENT_ERR = 4,
+ DOM_INVALID_CHARACTER_ERR = 5,
+ DOM_NO_DATA_ALLOWED_ERR = 6,
+ DOM_NO_MODIFICATION_ALLOWED_ERR = 7,
+ DOM_NOT_FOUND_ERR = 8,
+ DOM_NOT_SUPPORTED_ERR = 9,
+ DOM_INUSE_ATTRIBUTE_ERR = 10,
+ DOM_INVALID_STATE_ERR = 11,
+ DOM_SYNTAX_ERR = 12,
+ DOM_INVALID_MODIFICATION_ERR = 13,
+ DOM_NAMESPACE_ERR = 14,
+ DOM_INVALID_ACCESS_ERR = 15,
+ DOM_VALIDATION_ERR = 16,
+ DOM_TYPE_MISMATCH_ERR = 17,
+ DOM_NO_MEM_ERR = (1<<16) /* our own internal error */
+} dom_exception;
+
+#endif
Added: trunk/dom/include/dom/core/node.h
URL: http://source.netsurf-browser.org/trunk/dom/include/dom/core/node.h?rev=3...
==============================================================================
--- trunk/dom/include/dom/core/node.h (added)
+++ trunk/dom/include/dom/core/node.h Fri Jul 6 15:32:44 2007
@@ -1,0 +1,170 @@
+/*
+ * This file is part of libdom.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2007 John-Mark Bell <jmb(a)netsurf-browser.org>
+ */
+
+#ifndef dom_core_node_h_
+#define dom_core_node_h_
+
+#include <inttypes.h>
+#include <stdbool.h>
+
+#include <dom/core/exceptions.h>
+
+struct dom_ctx;
+struct dom_document;
+struct dom_node;
+struct dom_node_list;
+struct dom_named_node_map;
+struct dom_string;
+
+/**
+ * Bits defining position of a node in a document relative to some other node
+ */
+typedef enum {
+ DOM_DOCUMENT_POSITION_DISCONNECTED = 0x01,
+ DOM_DOCUMENT_POSITION_PRECEDING = 0x02,
+ DOM_DOCUMENT_POSITION_FOLLOWING = 0x04,
+ DOM_DOCUMENT_POSITION_CONTAINS = 0x08,
+ DOM_DOCUMENT_POSITION_CONTAINED_BY = 0x10,
+ DOM_DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20
+} dom_document_position;
+
+/**
+ * Type of node operation being notified to user_data_handler
+ */
+typedef enum {
+ DOM_NODE_CLONED = 1,
+ DOM_NODE_IMPORTED = 2,
+ DOM_NODE_DELETED = 3,
+ DOM_NODE_RENAMED = 4,
+ DOM_NODE_ADOPTED = 5
+} dom_node_operation;
+
+/**
+ * Type of handler function for user data registered on a DOM node
+ */
+typedef void (*dom_user_data_handler)(dom_node_operation operation,
+ struct dom_string *key, void *data, struct dom_node *src,
+ struct dom_node *dst);
+
+/**
+ * Type of a DOM node
+ */
+typedef enum {
+ DOM_ELEMENT_NODE = 1,
+ DOM_ATTRIBUTE_NODE = 2,
+ DOM_TEXT_NODE = 3,
+ DOM_CDATA_SECTION_NODE = 4,
+ DOM_ENTITY_REFERENCE_NODE = 5,
+ DOM_ENTITY_NODE = 6,
+ DOM_PROCESSING_INSTRUCTION_NODE = 7,
+ DOM_COMMENT_NODE = 8,
+ DOM_DOCUMENT_NODE = 9,
+ DOM_DOCUMENT_TYPE_NODE = 10,
+ DOM_DOCUMENT_FRAGMENT_NODE = 11,
+ DOM_NOTATION_NODE = 12
+} dom_node_type;
+
+
+void dom_node_ref(struct dom_ctx *ctx, struct dom_node *node);
+void dom_node_unref(struct dom_ctx *ctx, struct dom_node *node);
+
+dom_exception dom_node_get_name(struct dom_ctx *ctx,
+ struct dom_node *node, struct dom_string **result);
+dom_exception dom_node_get_value(struct dom_ctx *ctx,
+ struct dom_node *node, struct dom_string **result);
+dom_exception dom_node_set_value(struct dom_ctx *ctx,
+ struct dom_node *node, struct dom_string *value);
+dom_exception dom_node_get_type(struct dom_ctx *ctx,
+ struct dom_node *node, dom_node_type *result);
+dom_exception dom_node_get_parent(struct dom_ctx *ctx,
+ struct dom_node *node, struct dom_node **result);
+dom_exception dom_node_get_children(struct dom_ctx *ctx,
+ struct dom_node *node, struct dom_node_list **result);
+dom_exception dom_node_get_first_child(struct dom_ctx *ctx,
+ struct dom_node *node, struct dom_node **result);
+dom_exception dom_node_get_last_child(struct dom_ctx *ctx,
+ struct dom_node *node, struct dom_node **result);
+dom_exception dom_node_get_previous(struct dom_ctx *ctx,
+ struct dom_node *node, struct dom_node **result);
+dom_exception dom_node_get_next(struct dom_ctx *ctx,
+ struct dom_node *node, struct dom_node **result);
+dom_exception dom_node_get_attributes(struct dom_ctx *ctx,
+ struct dom_node *node, struct dom_named_node_map **result);
+dom_exception dom_node_get_owner(struct dom_ctx *ctx,
+ struct dom_node *node, struct dom_document **result);
+dom_exception dom_node_insert_before(struct dom_ctx *ctx,
+ struct dom_node *node,
+ struct dom_node *new_child, struct dom_node *ref_child,
+ struct dom_node **result);
+dom_exception dom_node_replace_child(struct dom_ctx *ctx,
+ struct dom_node *node,
+ struct dom_node *new_child, struct dom_node *old_child,
+ struct dom_node **result);
+dom_exception dom_node_remove_child(struct dom_ctx *ctx,
+ struct dom_node *node,
+ struct dom_node *old_child,
+ struct dom_node **result);
+dom_exception dom_node_append_child(struct dom_ctx *ctx,
+ struct dom_node *node,
+ struct dom_node *new_child,
+ struct dom_node **result);
+dom_exception dom_node_has_children(struct dom_ctx *ctx,
+ struct dom_node *node, bool *result);
+dom_exception dom_node_clone(struct dom_ctx *ctx,
+ struct dom_node *node, bool deep,
+ struct dom_node **result);
+dom_exception dom_node_normalize(struct dom_ctx *ctx,
+ struct dom_node *node);
+dom_exception dom_node_is_supported(struct dom_ctx *ctx,
+ struct dom_node *node, struct dom_string *feature,
+ struct dom_node *version, bool *result);
+dom_exception dom_node_get_namespace(struct dom_ctx *ctx,
+ struct dom_node *node, struct dom_string **result);
+dom_exception dom_node_get_prefix(struct dom_ctx *ctx,
+ struct dom_node *node, struct dom_string **result);
+dom_exception dom_node_set_prefix(struct dom_ctx *ctx,
+ struct dom_node *node, struct dom_string *prefix);
+dom_exception dom_node_get_local_name(struct dom_ctx *ctx,
+ struct dom_node *node, struct dom_string **result);
+dom_exception dom_node_has_attributes(struct dom_ctx *ctx,
+ struct dom_node *node, bool *result);
+dom_exception dom_node_get_base(struct dom_ctx *ctx,
+ struct dom_node *node, struct dom_string **result);
+dom_exception dom_node_compare_document_position(struct dom_ctx *ctx,
+ struct dom_node *node, struct dom_node *other,
+ uint16_t *result);
+dom_exception dom_node_get_text_content(struct dom_ctx *ctx,
+ struct dom_node *node, struct dom_string **result);
+dom_exception dom_node_set_text_content(struct dom_ctx *ctx,
+ struct dom_node *node, struct dom_string *content);
+dom_exception dom_node_is_same(struct dom_ctx *ctx,
+ struct dom_node *node, struct dom_node *other,
+ bool *result);
+dom_exception dom_node_lookup_prefix(struct dom_ctx *ctx,
+ struct dom_node *node, struct dom_string *namespace,
+ struct dom_string **result);
+dom_exception dom_node_is_default_namespace(struct dom_ctx *ctx,
+ struct dom_node *node, struct dom_string *namespace,
+ bool *result);
+dom_exception dom_node_lookup_namespace(struct dom_ctx *ctx,
+ struct dom_node *node, struct dom_string *prefix,
+ struct dom_string **result);
+dom_exception dom_node_is_equal(struct dom_ctx *ctx,
+ struct dom_node *node, struct dom_node *other,
+ bool *result);
+dom_exception dom_node_get_feature(struct dom_ctx *ctx,
+ struct dom_node *node, struct dom_string *feature,
+ struct dom_string *version, void **result);
+dom_exception dom_node_set_user_data(struct dom_ctx *ctx,
+ struct dom_node *node, struct dom_string *key,
+ void *data, dom_user_data_handler handler,
+ void **result);
+dom_exception dom_node_get_user_data(struct dom_ctx *ctx,
+ struct dom_node *node, struct dom_string *key,
+ void **result);
+
+#endif
Added: trunk/dom/include/dom/core/string.h
URL: http://source.netsurf-browser.org/trunk/dom/include/dom/core/string.h?rev...
==============================================================================
--- trunk/dom/include/dom/core/string.h (added)
+++ trunk/dom/include/dom/core/string.h Fri Jul 6 15:32:44 2007
@@ -1,0 +1,40 @@
+/*
+ * This file is part of libdom.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2007 John-Mark Bell <jmb(a)netsurf-browser.org>
+ */
+
+#ifndef dom_string_h_
+#define dom_string_h_
+
+#include <inttypes.h>
+#include <stddef.h>
+
+#include <dom/core/exceptions.h>
+
+struct dom_ctx;
+struct dom_document;
+struct dom_string;
+
+/* Claim a reference on a DOM string */
+void dom_string_ref(struct dom_ctx *ctx, struct dom_string *str);
+/* Release a reference on a DOM string */
+void dom_string_unref(struct dom_ctx *ctx, struct dom_string *str);
+
+/* Create a DOM string from an offset into the document buffer */
+dom_exception dom_string_create_from_off(struct dom_ctx *ctx,
+ struct dom_document *doc, uint32_t off, size_t len,
+ struct dom_string **str);
+/* Create a DOM string from a string of characters */
+dom_exception dom_string_create_from_ptr(struct dom_ctx *ctx,
+ const uint8_t *ptr, size_t len, struct dom_string **str);
+/* Create a DOM string from a constant string of characters */
+dom_exception dom_string_create_from_const_ptr(struct dom_ctx *ctx,
+ const uint8_t *ptr, size_t len, struct dom_string **str);
+
+/* Get a pointer to the string of characters within a DOM string */
+dom_exception dom_string_get_data(struct dom_ctx *ctx,
+ struct dom_string *str, const uint8_t **data, size_t *len);
+
+#endif
Added: trunk/dom/include/dom/ctx.h
URL: http://source.netsurf-browser.org/trunk/dom/include/dom/ctx.h?rev=3384&vi...
==============================================================================
--- trunk/dom/include/dom/ctx.h (added)
+++ trunk/dom/include/dom/ctx.h Fri Jul 6 15:32:44 2007
@@ -1,0 +1,26 @@
+/*
+ * This file is part of libdom.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2007 John-Mark Bell <jmb(a)netsurf-browser.org>
+ */
+
+#ifndef dom_ctx_h_
+#define dom_ctx_h_
+
+#include <stddef.h>
+
+/**
+ * Type of allocation function for DOM implementation
+ */
+typedef void *(*dom_alloc)(void *ptr, size_t size, void *pw);
+
+/**
+ * DOM allocation context
+ */
+struct dom_ctx {
+ dom_alloc alloc; /**< Memory (de)allocation function */
+ void *pw; /**< Pointer to client data */
+};
+
+#endif
Added: trunk/dom/src/Makefile
URL: http://source.netsurf-browser.org/trunk/dom/src/Makefile?rev=3384&view=auto
==============================================================================
--- trunk/dom/src/Makefile (added)
+++ trunk/dom/src/Makefile Fri Jul 6 15:32:44 2007
@@ -1,0 +1,72 @@
+# Makefile for libdom
+#
+# Toolchain is exported by top-level makefile
+#
+# Top-level makefile also exports the following variables:
+#
+# COMPONENT Name of component
+# EXPORT Absolute path of export directory
+# TOP Absolute path of source tree root
+#
+# The top-level makefile requires the following targets to exist:
+#
+# clean Clean source tree
+# debug Create a debug binary
+# distclean Fully clean source tree, back to pristine condition
+# export Export distributable components to ${EXPORT}
+# release Create a release binary
+# setup Perform any setup required prior to compilation
+# test Execute any test cases
+
+# Manipulate include paths
+CFLAGS += -I$(CURDIR)
+
+# Release output
+RELEASE = ${TOP}/${COMPONENT}.a
+
+# Debug output
+DEBUG = ${TOP}/${COMPONENT}-debug.a
+
+# Objects
+OBJS =
+
+.PHONY: clean debug distclean export release setup test
+
+# Targets
+release: $(addprefix Release/, $(addsuffix .o, $(OBJS)))
+ @${MAKE} -C core release
+ @${AR} ${ARFLAGS} $(RELEASE) Release/*
+
+debug: $(addprefix Debug/, $(addsuffix .o, $(OBJS)))
+ @${MAKE} -C core debug
+ @${AR} ${ARFLAGS} $(DEBUG) Debug/*
+
+clean:
+ @${MAKE} -C core clean
+ifneq (${OBJS}, )
+ -@${RM} ${RMFLAGS} $(addprefix Release/, $(addsuffix .o, ${OBJS}))
+ -@${RM} ${RMFLAGS} $(addprefix Debug/, $(addsuffix .o, ${OBJS}))
+endif
+ -@${RM} ${RMFLAGS} $(RELEASE) $(DEBUG)
+
+distclean:
+ -@${RM} ${RMFLAGS} -r Release
+ -@${RM} ${RMFLAGS} -r Debug
+
+setup:
+ @${MKDIR} ${MKDIRFLAGS} Release
+ @${MKDIR} ${MKDIRFLAGS} Debug
+
+export:
+ @${CP} ${CPFLAGS} $(RELEASE) ${EXPORT}/lib/
+
+test:
+
+# Pattern rules
+Release/%.o: %.c
+ @${ECHO} ${ECHOFLAGS} "==> $<"
+ @${CC} -c ${CFLAGS} -DNDEBUG -o $@ $<
+
+Debug/%.o: %.c
+ @${ECHO} ${ECHOFLAGS} "==> $<"
+ @${CC} -c -g ${CFLAGS} -o $@ $<
Added: trunk/dom/src/core/Makefile
URL: http://source.netsurf-browser.org/trunk/dom/src/core/Makefile?rev=3384&vi...
==============================================================================
--- trunk/dom/src/core/Makefile (added)
+++ trunk/dom/src/core/Makefile Fri Jul 6 15:32:44 2007
@@ -1,0 +1,53 @@
+# Makefile for libdom
+#
+# Toolchain is exported by top-level makefile
+#
+# Top-level makefile also exports the following variables:
+#
+# COMPONENT Name of component
+# EXPORT Absolute path of export directory
+# TOP Absolute path of source tree root
+#
+# The top-level makefile requires the following targets to exist:
+#
+# clean Clean source tree
+# debug Create a debug binary
+# distclean Fully clean source tree, back to pristine condition
+# export Export distributable components to ${EXPORT}
+# release Create a release binary
+# setup Perform any setup required prior to compilation
+# test Execute any test cases
+
+# Manipulate include paths
+CFLAGS += -I$(CURDIR)
+
+# Objects
+OBJS = attr document node string
+
+.PHONY: clean debug distclean export release setup test
+
+# Targets
+release: $(addprefix ../Release/, $(addsuffix .o, $(OBJS)))
+
+debug: $(addprefix ../Debug/, $(addsuffix .o, $(OBJS)))
+
+clean:
+ -@${RM} ${RMFLAGS} $(addprefix ../Release/, $(addsuffix .o, ${OBJS}))
+ -@${RM} ${RMFLAGS} $(addprefix ../Debug/, $(addsuffix .o, ${OBJS}))
+
+distclean:
+
+setup:
+
+export:
+
+test:
+
+# Pattern rules
+../Release/%.o: %.c
+ @${ECHO} ${ECHOFLAGS} "==> $<"
+ @${CC} -c ${CFLAGS} -DNDEBUG -o $@ $<
+
+../Debug/%.o: %.c
+ @${ECHO} ${ECHOFLAGS} "==> $<"
+ @${CC} -c -g ${CFLAGS} -o $@ $<
Added: trunk/dom/src/core/attr.c
URL: http://source.netsurf-browser.org/trunk/dom/src/core/attr.c?rev=3384&view...
==============================================================================
--- trunk/dom/src/core/attr.c (added)
+++ trunk/dom/src/core/attr.c Fri Jul 6 15:32:44 2007
@@ -1,0 +1,173 @@
+/*
+ * This file is part of libdom.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2007 John-Mark Bell <jmb(a)netsurf-browser.org>
+ */
+
+#include <dom/core/attr.h>
+
+#include "core/node.h"
+#include "utils/utils.h"
+
+struct dom_element;
+struct dom_typeinfo;
+
+/**
+ * DOM node attribute
+ */
+struct dom_attr {
+ struct dom_node base; /**< Base node */
+
+ bool specified; /**< Whether attribute was specified
+ * or defaulted */
+
+ struct dom_element *owner; /**< Owning element */
+
+ struct dom_typeinfo *schema_type_info; /**< Type information */
+
+ bool is_id; /**< Attribute is of type ID */
+};
+
+/**
+ * Retrieve an attribute's name
+ *
+ * \param ctx The context in which the attribute resides
+ * \param attr Attribute to retrieve name from
+ * \param result Pointer to location to receive result
+ * \return DOM_NO_ERR.
+ *
+ * The returned string will have its reference count increased. It is
+ * the responsibility of the caller to unref the string once it has
+ * finished with it.
+ */
+dom_exception dom_attr_get_name(struct dom_ctx *ctx,
+ struct dom_attr *attr, struct dom_string **result)
+{
+ UNUSED(ctx);
+ UNUSED(attr);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Determine if attribute was specified or defaulted
+ *
+ * \param ctx The context in which the attribute resides
+ * \param attr Attribute to inspect
+ * \param result Pointer to location to receive result
+ * \return DOM_NO_ERR.
+ */
+dom_exception dom_attr_get_specified(struct dom_ctx *ctx,
+ struct dom_attr *attr, bool *result)
+{
+ UNUSED(ctx);
+
+ *result = attr->specified;
+
+ return DOM_NO_ERR;
+}
+
+/**
+ * Retrieve an attribute's value
+ *
+ * \param ctx The context in which the attribute resides
+ * \param attr Attribute to retrieve value from
+ * \param result Pointer to location to receive result
+ * \return DOM_NO_ERR.
+ *
+ * The returned string will have its reference count increased. It is
+ * the responsibility of the caller to unref the string once it has
+ * finished with it.
+ */
+dom_exception dom_attr_get_value(struct dom_ctx *ctx,
+ struct dom_attr *attr, struct dom_string **result)
+{
+ UNUSED(ctx);
+ UNUSED(attr);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Set an attribute's value
+ *
+ * \param ctx The context in which the attribute resides
+ * \param attr Attribute to retrieve value from
+ * \param value New value for attribute
+ * \return DOM_NO_ERR on success,
+ * DOM_NO_MODIFICATION_ALLOWED_ERR if attribute is readonly.
+ */
+dom_exception dom_attr_set_value(struct dom_ctx *ctx,
+ struct dom_attr *attr, struct dom_string *value)
+{
+ UNUSED(ctx);
+ UNUSED(attr);
+ UNUSED(value);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Retrieve the owning element of an attribute
+ *
+ * \param ctx The context in which the attribute resides
+ * \param attr The attribute to extract owning element from
+ * \param result Pointer to location to receive result
+ * \return DOM_NO_ERR.
+ *
+ * The returned node will have its reference count increased. The caller
+ * should unref it once it has finished with it.
+ */
+dom_exception dom_attr_get_owner(struct dom_ctx *ctx,
+ struct dom_attr *attr, struct dom_element **result)
+{
+ /* If there is an owning element, increase its reference count */
+ if (attr->owner != NULL)
+ dom_node_ref(ctx, (struct dom_node *) attr->owner);
+
+ *result = attr->owner;
+
+ return DOM_NO_ERR;
+}
+
+/**
+ * Retrieve an attribute's type information
+ *
+ * \param ctx The context in which the attribute resides
+ * \param attr The attribute to extract type information from
+ * \param result Pointer to location to receive result
+ * \return DOM_NO_ERR.
+ *
+ * The returned typeinfo will have its reference count increased. The caller
+ * should unref it once it has finished with it.
+ */
+dom_exception dom_attr_get_typeinfo(struct dom_ctx *ctx,
+ struct dom_attr *attr, struct dom_typeinfo **result)
+{
+ UNUSED(ctx);
+ UNUSED(attr);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Determine if an attribute if of type ID
+ *
+ * \param ctx The context in which the attribute resides
+ * \param attr The attribute to inspect
+ * \param result Pointer to location to receive result
+ * \return DOM_NO_ERR.
+ */
+dom_exception dom_attr_is_id(struct dom_ctx *ctx,
+ struct dom_attr *attr, bool *result)
+{
+ UNUSED(ctx);
+
+ *result = attr->is_id;
+
+ return DOM_NO_ERR;
+}
Added: trunk/dom/src/core/document.c
URL: http://source.netsurf-browser.org/trunk/dom/src/core/document.c?rev=3384&...
==============================================================================
--- trunk/dom/src/core/document.c (added)
+++ trunk/dom/src/core/document.c Fri Jul 6 15:32:44 2007
@@ -1,0 +1,356 @@
+/*
+ * This file is part of libdom.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2007 John-Mark Bell <jmb(a)netsurf-browser.org>
+ */
+
+#include <dom/core/document.h>
+
+#include "core/node.h"
+#include "utils/utils.h"
+
+/**
+ * DOM document
+ */
+struct dom_document {
+ struct dom_node base; /**< Base node */
+};
+
+
+dom_exception dom_document_get_doctype(struct dom_ctx *ctx,
+ struct dom_document *doc, struct dom_document_type **result)
+{
+ UNUSED(ctx);
+ UNUSED(doc);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+dom_exception dom_document_get_implementation(struct dom_ctx *ctx,
+ struct dom_document *doc,
+ struct dom_implementation **result)
+{
+ UNUSED(ctx);
+ UNUSED(doc);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+dom_exception dom_document_get_element(struct dom_ctx *ctx,
+ struct dom_document *doc, struct dom_element **result)
+{
+ UNUSED(ctx);
+ UNUSED(doc);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+dom_exception dom_document_create_element(struct dom_ctx *ctx,
+ struct dom_document *doc, struct dom_string *tag_name,
+ struct dom_element **result)
+{
+ UNUSED(ctx);
+ UNUSED(doc);
+ UNUSED(tag_name);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+dom_exception dom_document_create_document_fragment(struct dom_ctx *ctx,
+ struct dom_document *doc, struct dom_node **result)
+{
+ UNUSED(ctx);
+ UNUSED(doc);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+dom_exception dom_document_create_text_node(struct dom_ctx *ctx,
+ struct dom_document *doc, struct dom_string *data,
+ struct dom_text **result)
+{
+ UNUSED(ctx);
+ UNUSED(doc);
+ UNUSED(data);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+dom_exception dom_document_create_cdata_section(struct dom_ctx *ctx,
+ struct dom_document *doc, struct dom_string *data,
+ struct dom_text **result)
+{
+ UNUSED(ctx);
+ UNUSED(doc);
+ UNUSED(data);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+dom_exception dom_document_create_processing_instruction(struct dom_ctx *ctx,
+ struct dom_document *doc, struct dom_string *target,
+ struct dom_string *data,
+ struct dom_node **result)
+{
+ UNUSED(ctx);
+ UNUSED(doc);
+ UNUSED(target);
+ UNUSED(data);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+dom_exception dom_document_create_attribute(struct dom_ctx *ctx,
+ struct dom_document *doc, struct dom_string *name,
+ struct dom_attr **result)
+{
+ UNUSED(ctx);
+ UNUSED(doc);
+ UNUSED(name);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+dom_exception dom_document_create_entity_reference(struct dom_ctx *ctx,
+ struct dom_document *doc, struct dom_string *name,
+ struct dom_node **result)
+{
+ UNUSED(ctx);
+ UNUSED(doc);
+ UNUSED(name);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+dom_exception dom_document_get_elements_by_tag_name(struct dom_ctx *ctx,
+ struct dom_document *doc, struct dom_string *tagname,
+ struct dom_nodelist **result)
+{
+ UNUSED(ctx);
+ UNUSED(doc);
+ UNUSED(tagname);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+dom_exception dom_document_import_node(struct dom_ctx *ctx,
+ struct dom_document *doc, struct dom_node *node,
+ bool deep, struct dom_node **result)
+{
+ UNUSED(ctx);
+ UNUSED(doc);
+ UNUSED(node);
+ UNUSED(deep);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+dom_exception dom_document_create_element_ns(struct dom_ctx *ctx,
+ struct dom_document *doc, struct dom_string *namespace,
+ struct dom_string *qname, struct dom_element **result)
+{
+ UNUSED(ctx);
+ UNUSED(doc);
+ UNUSED(namespace);
+ UNUSED(qname);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+dom_exception dom_document_create_attribute_ns(struct dom_ctx *ctx,
+ struct dom_document *doc, struct dom_string *namespace,
+ struct dom_string *qname, struct dom_attr **result)
+{
+ UNUSED(ctx);
+ UNUSED(doc);
+ UNUSED(namespace);
+ UNUSED(qname);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+dom_exception dom_document_get_elements_by_tag_name_ns(struct dom_ctx *ctx,
+ struct dom_document *doc, struct dom_string *namespace,
+ struct dom_string *localname, struct dom_nodelist **result)
+{
+ UNUSED(ctx);
+ UNUSED(doc);
+ UNUSED(namespace);
+ UNUSED(localname);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+dom_exception dom_document_get_element_by_id(struct dom_ctx *ctx,
+ struct dom_document *doc, struct dom_string *id,
+ struct dom_element **result)
+{
+ UNUSED(ctx);
+ UNUSED(doc);
+ UNUSED(id);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+dom_exception dom_document_get_input_encoding(struct dom_ctx *ctx,
+ struct dom_document *doc, struct dom_string **result)
+{
+ UNUSED(ctx);
+ UNUSED(doc);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+dom_exception dom_document_get_xml_encoding(struct dom_ctx *ctx,
+ struct dom_document *doc, struct dom_string **result)
+{
+ UNUSED(ctx);
+ UNUSED(doc);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+dom_exception dom_document_get_xml_standalone(struct dom_ctx *ctx,
+ struct dom_document *doc, bool *result)
+{
+ UNUSED(ctx);
+ UNUSED(doc);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+dom_exception dom_document_set_xml_standalone(struct dom_ctx *ctx,
+ struct dom_document *doc, bool standalone)
+{
+ UNUSED(ctx);
+ UNUSED(doc);
+ UNUSED(standalone);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+dom_exception dom_document_get_xml_version(struct dom_ctx *ctx,
+ struct dom_document *doc, struct dom_string **result)
+{
+ UNUSED(ctx);
+ UNUSED(doc);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+dom_exception dom_document_set_xml_version(struct dom_ctx *ctx,
+ struct dom_document *doc, struct dom_string *version)
+{
+ UNUSED(ctx);
+ UNUSED(doc);
+ UNUSED(version);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+dom_exception dom_document_get_strict_error_checking(struct dom_ctx *ctx,
+ struct dom_document *doc, bool *result)
+{
+ UNUSED(ctx);
+ UNUSED(doc);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+dom_exception dom_document_set_strict_error_checking(struct dom_ctx *ctx,
+ struct dom_document *doc, bool strict)
+{
+ UNUSED(ctx);
+ UNUSED(doc);
+ UNUSED(strict);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+dom_exception dom_document_get_uri(struct dom_ctx *ctx,
+ struct dom_document *doc, struct dom_string **result)
+{
+ UNUSED(ctx);
+ UNUSED(doc);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+dom_exception dom_document_set_uri(struct dom_ctx *ctx,
+ struct dom_document *doc, struct dom_string *uri)
+{
+ UNUSED(ctx);
+ UNUSED(doc);
+ UNUSED(uri);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+dom_exception dom_document_adopt_node(struct dom_ctx *ctx,
+ struct dom_document *doc, struct dom_node *node,
+ struct dom_node **result)
+{
+ UNUSED(ctx);
+ UNUSED(doc);
+ UNUSED(node);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+dom_exception dom_document_get_dom_config(struct dom_ctx *ctx,
+ struct dom_document *doc, struct dom_configuration **result)
+{
+ UNUSED(ctx);
+ UNUSED(doc);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+dom_exception dom_document_normalize(struct dom_ctx *ctx,
+ struct dom_document *doc)
+{
+ UNUSED(ctx);
+ UNUSED(doc);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+dom_exception dom_document_rename_node(struct dom_ctx *ctx,
+ struct dom_document *doc, struct dom_node *node,
+ struct dom_string *namespace, struct dom_string *qname,
+ struct dom_node **result)
+{
+ UNUSED(ctx);
+ UNUSED(doc);
+ UNUSED(node);
+ UNUSED(namespace);
+ UNUSED(qname);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
Added: trunk/dom/src/core/document.h
URL: http://source.netsurf-browser.org/trunk/dom/src/core/document.h?rev=3384&...
==============================================================================
--- trunk/dom/src/core/document.h (added)
+++ trunk/dom/src/core/document.h Fri Jul 6 15:32:44 2007
@@ -1,0 +1,19 @@
+/*
+ * This file is part of libdom.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2007 John-Mark Bell <jmb(a)netsurf-browser.org>
+ */
+
+#ifndef dom_internal_document_h_
+#define dom_internal_document_h_
+
+#include <inttypes.h>
+
+struct dom_ctx;
+struct dom_document;
+
+const uint8_t *dom_document_get_base(struct dom_ctx *ctx,
+ struct dom_document *doc);
+
+#endif
Added: trunk/dom/src/core/node.c
URL: http://source.netsurf-browser.org/trunk/dom/src/core/node.c?rev=3384&view...
==============================================================================
--- trunk/dom/src/core/node.c (added)
+++ trunk/dom/src/core/node.c Fri Jul 6 15:32:44 2007
@@ -1,0 +1,1069 @@
+/*
+ * This file is part of libdom.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2007 John-Mark Bell <jmb(a)netsurf-browser.org>
+ */
+
+#include <dom/ctx.h>
+
+#include "core/node.h"
+#include "utils/utils.h"
+
+/**
+ * Create a DOM node
+ *
+ * \param ctx The context in which the node resides
+ * \param doc The document which owns the node
+ * \param type The node type required
+ * \param name The node name, or NULL
+ * \param value The node value, or NULL
+ * \param node Pointer to location to receive created node
+ * \return DOM_NO_ERR on success, DOM_NO_MEM_ERR on memory exhaustion
+ *
+ * The returned node will be referenced, so there is no need for the caller
+ * to explicitly reference it.
+ */
+dom_exception dom_node_create(struct dom_ctx *ctx,
+ struct dom_document *doc, dom_node_type type,
+ struct dom_string *name, struct dom_string *value,
+ struct dom_node **node)
+{
+ struct dom_node *n;
+
+ n = ctx->alloc(NULL, sizeof(struct dom_node), ctx->pw);
+ if (n == NULL)
+ return DOM_NO_MEM_ERR;
+
+ if (name != NULL)
+ dom_string_ref(ctx, name);
+ n->name = name;
+
+ if (value != NULL)
+ dom_string_ref(ctx, value);
+ n->value = value;
+
+ n->type = type;
+
+ n->parent = NULL;
+ n->first_child = NULL;
+ n->last_child = NULL;
+ n->previous = NULL;
+ n->next = NULL;
+ n->attributes = NULL;
+
+ dom_node_ref(ctx, (struct dom_node *) doc);
+ n->owner = doc;
+
+ /** \todo Namespace handling */
+ n->namespace = NULL;
+ n->prefix = NULL;
+ n->localname = NULL;
+
+ n->user_data = NULL;
+
+ n->refcnt = 1;
+
+ *node = n;
+
+ return DOM_NO_ERR;
+}
+
+/**
+ * Claim a reference on a DOM node
+ *
+ * \param ctx The context in which the node resides
+ * \param node The node to claim a reference on
+ */
+void dom_node_ref(struct dom_ctx *ctx, struct dom_node *node)
+{
+ UNUSED(ctx);
+
+ node->refcnt++;
+}
+
+/**
+ * Release a reference on a DOM node
+ *
+ * \param ctx The context in which the node resides
+ * \param node The node to release the reference from
+ *
+ * If the reference count reaches zero, any memory claimed by the
+ * node will be released
+ */
+void dom_node_unref(struct dom_ctx *ctx, struct dom_node *node)
+{
+ UNUSED(ctx);
+
+ if (--node->refcnt == 0) {
+ /** \todo implement */
+ }
+}
+
+/**
+ * Retrieve the name of a DOM node
+ *
+ * \param ctx The context in which the node resides
+ * \param node The node to retrieve the name of
+ * \param result Pointer to location to receive node name
+ * \return DOM_NO_ERR.
+ *
+ * The returned string will have its reference count increased. It is
+ * the responsibility of the caller to unref the string once it has
+ * finished with it.
+ */
+dom_exception dom_node_get_name(struct dom_ctx *ctx,
+ struct dom_node *node, struct dom_string **result)
+{
+ UNUSED(ctx);
+ UNUSED(node);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Retrieve the value of a DOM node
+ *
+ * \param ctx The context in which the node resides
+ * \param node The node to retrieve the value of
+ * \param result Pointer to location to receive node value
+ * \return DOM_NO_ERR.
+ *
+ * The returned string will have its reference count increased. It is
+ * the responsibility of the caller to unref the string once it has
+ * finished with it.
+ *
+ * DOM3Core states that this can raise DOMSTRING_SIZE_ERR. It will not in
+ * this implementation; dom_strings are unbounded.
+ */
+dom_exception dom_node_get_value(struct dom_ctx *ctx,
+ struct dom_node *node, struct dom_string **result)
+{
+ UNUSED(ctx);
+ UNUSED(node);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Set the value of a DOM node
+ *
+ * \param ctx The context in which the node resides
+ * \param node Node to set the value of
+ * \param value New value for node
+ * \return DOM_NO_ERR on success,
+ * DOM_NO_MODIFICATION_ALLOWED_ERR if the node is readonly and the
+ * value is not defined to be null.
+ *
+ * The new value will have its reference count increased, so the caller
+ * should unref it after the call (as the caller should have already claimed
+ * a reference on the string). The node's existing value will be unrefed.
+ */
+dom_exception dom_node_set_value(struct dom_ctx *ctx,
+ struct dom_node *node, struct dom_string *value)
+{
+ UNUSED(ctx);
+ UNUSED(node);
+ UNUSED(value);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Retrieve the type of a DOM node
+ *
+ * \param ctx The context in which the node resides
+ * \param node The node to retrieve the type of
+ * \param result Pointer to location to receive node type
+ * \return DOM_NO_ERR.
+ */
+dom_exception dom_node_get_type(struct dom_ctx *ctx,
+ struct dom_node *node, dom_node_type *result)
+{
+ UNUSED(ctx);
+
+ *result = node->type;
+
+ return DOM_NO_ERR;
+}
+
+/**
+ * Retrieve the parent of a DOM node
+ *
+ * \param ctx The context in which the node resides
+ * \param node The node to retrieve the parent of
+ * \param result Pointer to location to receive node parent
+ * \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_node_get_parent(struct dom_ctx *ctx,
+ struct dom_node *node, struct dom_node **result)
+{
+ /* If there is a parent node, then increase its reference count */
+ if (node->parent != NULL)
+ dom_node_ref(ctx, node->parent);
+
+ *result = node->parent;
+
+ return DOM_NO_ERR;
+}
+
+/**
+ * Retrieve a list of children of a DOM node
+ *
+ * \param ctx The context in which the node resides
+ * \param node The node to retrieve the children of
+ * \param result Pointer to location to receive child list
+ * \return DOM_NO_ERR.
+ *
+ * \todo Work out reference counting semantics of dom_node_list
+ */
+dom_exception dom_node_get_children(struct dom_ctx *ctx,
+ struct dom_node *node, struct dom_node_list **result)
+{
+ UNUSED(ctx);
+ UNUSED(node);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Retrieve the first child of a DOM node
+ *
+ * \param ctx The context in which the node resides
+ * \param node The node to retrieve the first child of
+ * \param result Pointer to location to receive node's first child
+ * \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_node_get_first_child(struct dom_ctx *ctx,
+ struct dom_node *node, struct dom_node **result)
+{
+ /* If there is a first child, increase its reference count */
+ if (node->first_child != NULL)
+ dom_node_ref(ctx, node->first_child);
+
+ *result = node->first_child;
+
+ return DOM_NO_ERR;
+}
+
+/**
+ * Retrieve the last child of a DOM node
+ *
+ * \param ctx The context in which the node resides
+ * \param node The node to retrieve the last child of
+ * \param result Pointer to location to receive node's last child
+ * \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_node_get_last_child(struct dom_ctx *ctx,
+ struct dom_node *node, struct dom_node **result)
+{
+ /* If there is a last child, increase its reference count */
+ if (node->last_child != NULL)
+ dom_node_ref(ctx, node->last_child);
+
+ *result = node->last_child;
+
+ return DOM_NO_ERR;
+}
+
+/**
+ * Retrieve the previous sibling of a DOM node
+ *
+ * \param ctx The context in which the node resides
+ * \param node The node to retrieve the previous sibling of
+ * \param result Pointer to location to receive node's previous sibling
+ * \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_node_get_previous(struct dom_ctx *ctx,
+ struct dom_node *node, struct dom_node **result)
+{
+ /* If there is a previous sibling, increase its reference count */
+ if (node->previous != NULL)
+ dom_node_ref(ctx, node->previous);
+
+ *result = node->previous;
+
+ return DOM_NO_ERR;
+}
+
+/**
+ * Retrieve the subsequent sibling of a DOM node
+ *
+ * \param ctx The context in which the node resides
+ * \param node The node to retrieve the subsequent sibling of
+ * \param result Pointer to location to receive node's subsequent sibling
+ * \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_node_get_next(struct dom_ctx *ctx,
+ struct dom_node *node, struct dom_node **result)
+{
+ /* If there is a subsequent sibling, increase its reference count */
+ if (node->next != NULL)
+ dom_node_ref(ctx, node->next);
+
+ *result = node->next;
+
+ return DOM_NO_ERR;
+}
+
+/**
+ * Retrieve a map of attributes associated with a DOM node
+ *
+ * \param ctx The context in which the node resides
+ * \param node The node to retrieve the attributes of
+ * \param result Pointer to location to receive attribute map
+ * \return DOM_NO_ERR.
+ *
+ * \todo Work out reference counting semantics of dom_named_node_map
+ */
+dom_exception dom_node_get_attributes(struct dom_ctx *ctx,
+ struct dom_node *node, struct dom_named_node_map **result)
+{
+ UNUSED(ctx);
+ UNUSED(node);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Retrieve the owning document of a DOM node
+ *
+ * \param ctx The context in which the node resides
+ * \param node The node to retrieve the owner of
+ * \param result Pointer to location to receive node's owner
+ * \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_node_get_owner(struct dom_ctx *ctx,
+ struct dom_node *node, struct dom_document **result)
+{
+ /* If there is an owner, increase its reference count */
+ if (node->owner != NULL)
+ dom_node_ref(ctx, (struct dom_node *) node->owner);
+
+ *result = node->owner;
+
+ return DOM_NO_ERR;
+}
+
+/**
+ * Insert a child into a node
+ *
+ * \param ctx The context in which the nodes reside
+ * \param node Node to insert into
+ * \param new_child Node to insert
+ * \param ref_child Node to insert before, or NULL to insert as last child
+ * \param result Pointer to location to receive node being inserted
+ * \return DOM_NO_ERR on success,
+ * DOM_HIERARCHY_REQUEST_ERR if ::new_child's type is not
+ * permitted as a child of ::node,
+ * or ::new_child is an ancestor of
+ * ::node (or is ::node itself), or
+ * ::node is of type Document and a
+ * second DocumentType or Element is
+ * being inserted,
+ * DOM_WRONG_DOCUMENT_ERR if ::new_child was created from a
+ * different document than ::node,
+ * DOM_NO_MODIFICATION_ALLOWED_ERR if ::node is readonly, or
+ * ::new_child's parent is readonly,
+ * DOM_NOT_FOUND_ERR if ::ref_child is not a child of
+ * ::node,
+ * DOM_NOT_SUPPORTED_ERR if ::node is of type Document and
+ * ::new_child is of type
+ * DocumentType or Element.
+ *
+ * If ::new_child is a DocumentFragment, all of its children are inserted.
+ * If ::new_child is already in the tree, it is first removed.
+ *
+ * ::new_child's reference count will be increased. The caller should unref
+ * it (as they should already have held a reference on the node)
+ */
+dom_exception dom_node_insert_before(struct dom_ctx *ctx,
+ struct dom_node *node,
+ struct dom_node *new_child, struct dom_node *ref_child,
+ struct dom_node **result)
+{
+ UNUSED(ctx);
+ UNUSED(node);
+ UNUSED(new_child);
+ UNUSED(ref_child);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Replace a node's child with a new one
+ *
+ * \param ctx The context in which the nodes reside
+ * \param node Node whose child to replace
+ * \param new_child Replacement node
+ * \param old_child Child to replace
+ * \param result Pointer to location to receive replaced node
+ * \return DOM_NO_ERR on success,
+ * DOM_HIERARCHY_REQUEST_ERR if ::new_child's type is not
+ * permitted as a child of ::node,
+ * or ::new_child is an ancestor of
+ * ::node (or is ::node itself), or
+ * ::node is of type Document and a
+ * second DocumentType or Element is
+ * being inserted,
+ * DOM_WRONG_DOCUMENT_ERR if ::new_child was created from a
+ * different document than ::node,
+ * DOM_NO_MODIFICATION_ALLOWED_ERR if ::node is readonly, or
+ * ::new_child's parent is readonly,
+ * DOM_NOT_FOUND_ERR if ::old_child is not a child of
+ * ::node,
+ * DOM_NOT_SUPPORTED_ERR if ::node is of type Document and
+ * ::new_child is of type
+ * DocumentType or Element.
+ *
+ * If ::new_child is a DocumentFragment, ::old_child is replaced by all of
+ * ::new_child's children.
+ * If ::new_child is already in the tree, it is first removed.
+ *
+ * ::new_child's reference count will be increased. The caller should unref
+ * it (as they should already have held a reference on the node)
+ *
+ * ::old_child's reference count remains unmodified (::node's reference is
+ * transferred to the caller). The caller should unref ::old_child once it
+ * is finished with it.
+ */
+dom_exception dom_node_replace_child(struct dom_ctx *ctx,
+ struct dom_node *node,
+ struct dom_node *new_child, struct dom_node *old_child,
+ struct dom_node **result)
+{
+ UNUSED(ctx);
+ UNUSED(node);
+ UNUSED(new_child);
+ UNUSED(old_child);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Remove a child from a node
+ *
+ * \param ctx The context in which the nodes reside
+ * \param node Node whose child to replace
+ * \param old_child Child to remove
+ * \param result Pointer to location to receive removed node
+ * \return DOM_NO_ERR on success,
+ * DOM_NO_MODIFICATION_ALLOWED_ERR if ::node is readonly
+ * DOM_NOT_FOUND_ERR if ::old_child is not a child of
+ * ::node,
+ * DOM_NOT_SUPPORTED_ERR if ::node is of type Document and
+ * ::new_child is of type
+ * DocumentType or Element.
+ *
+ * ::old_child's reference count remains unmodified (::node's reference is
+ * transferred to the caller). The caller should unref ::old_child once it
+ * is finished with it.
+ */
+dom_exception dom_node_remove_child(struct dom_ctx *ctx,
+ struct dom_node *node,
+ struct dom_node *old_child,
+ struct dom_node **result)
+{
+ UNUSED(ctx);
+ UNUSED(node);
+ UNUSED(old_child);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Append a child to the end of a node's child list
+ *
+ * \param ctx The context in which the nodes reside
+ * \param node Node to insert into
+ * \param new_child Node to append
+ * \param result Pointer to location to receive node being inserted
+ * \return DOM_NO_ERR on success,
+ * DOM_HIERARCHY_REQUEST_ERR if ::new_child's type is not
+ * permitted as a child of ::node,
+ * or ::new_child is an ancestor of
+ * ::node (or is ::node itself), or
+ * ::node is of type Document and a
+ * second DocumentType or Element is
+ * being inserted,
+ * DOM_WRONG_DOCUMENT_ERR if ::new_child was created from a
+ * different document than ::node,
+ * DOM_NO_MODIFICATION_ALLOWED_ERR if ::node is readonly, or
+ * ::new_child's parent is readonly,
+ * DOM_NOT_SUPPORTED_ERR if ::node is of type Document and
+ * ::new_child is of type
+ * DocumentType or Element.
+ *
+ * If ::new_child is a DocumentFragment, all of its children are inserted.
+ * If ::new_child is already in the tree, it is first removed.
+ *
+ * ::new_child's reference count will be increased. The caller should unref
+ * it (as they should already have held a reference on the node)
+ */
+dom_exception dom_node_append_child(struct dom_ctx *ctx,
+ struct dom_node *node,
+ struct dom_node *new_child,
+ struct dom_node **result)
+{
+ /* This is just a veneer over insert_before */
+ return dom_node_insert_before(ctx, node, new_child, NULL, result);
+}
+
+/**
+ * Determine if a node has any children
+ *
+ * \param ctx The context in which the node resides
+ * \param node Node to inspect
+ * \param result Pointer to location to receive result
+ * \return DOM_NO_ERR.
+ */
+dom_exception dom_node_has_children(struct dom_ctx *ctx,
+ struct dom_node *node, bool *result)
+{
+ UNUSED(ctx);
+
+ *result = node->first_child != NULL;
+
+ return DOM_NO_ERR;
+}
+
+/**
+ * Clone a DOM node
+ *
+ * \param ctx The context in which the node resides
+ * \param node The node to clone
+ * \param deep True to deep-clone the node's sub-tree
+ * \param result Pointer to location to receive result
+ * \return DOM_NO_ERR on success,
+ * DOM_NO_MEMORY_ERR on memory exhaustion.
+ *
+ * The returned node will already be referenced.
+ *
+ * The duplicate node will have no parent and no user data.
+ *
+ * If ::node has registered user_data_handlers, then they will be called.
+ *
+ * Cloning an Element copies all attributes & their values (including those
+ * generated by the XML processor to represent defaulted attributes). It
+ * does not copy any child nodes unless it is a deep copy (this includes
+ * text contained within the Element, as the text is contained in a child
+ * Text node).
+ *
+ * Cloning an Attr directly, as opposed to cloning as part of an Element,
+ * returns a specified attribute. Cloning an Attr always clones its children,
+ * since they represent its value, no matter whether this is a deep clone or
+ * not.
+ *
+ * Cloning an EntityReference automatically constructs its subtree if a
+ * corresponding Entity is available, no matter whether this is a deep clone
+ * or not.
+ *
+ * Cloning any other type of node simply returns a copy.
+ *
+ * Note that cloning an immutable subtree results in a mutable copy, but
+ * the children of an EntityReference clone are readonly. In addition, clones
+ * of unspecified Attr nodes are specified.
+ *
+ * \todo work out what happens when cloning Document, DocumentType, Entity
+ * and Notation nodes.
+ */
+dom_exception dom_node_clone(struct dom_ctx *ctx,
+ struct dom_node *node, bool deep,
+ struct dom_node **result)
+{
+ UNUSED(ctx);
+ UNUSED(node);
+ UNUSED(deep);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Normalize a DOM node
+ *
+ * \param ctx The context in which the node resides
+ * \param node The node to normalize
+ * \return DOM_NO_ERR.
+ *
+ * Puts all Text nodes in the full depth of the sub-tree beneath ::node,
+ * including Attr nodes into "normal" form, where only structure separates
+ * Text nodes.
+ */
+dom_exception dom_node_normalize(struct dom_ctx *ctx,
+ struct dom_node *node)
+{
+ UNUSED(ctx);
+ UNUSED(node);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Test whether the DOM implementation implements a specific feature and
+ * that feature is supported by the node.
+ *
+ * \param ctx The context in which the node resides
+ * \param node The node to test
+ * \param feature The name of the feature to test
+ * \param version The version number of the feature to test
+ * \param result Pointer to location to receive result
+ * \return DOM_NO_ERR.
+ */
+dom_exception dom_node_is_supported(struct dom_ctx *ctx,
+ struct dom_node *node, struct dom_string *feature,
+ struct dom_node *version, bool *result)
+{
+ UNUSED(ctx);
+ UNUSED(node);
+ UNUSED(feature);
+ UNUSED(version);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Retrieve the namespace of a DOM node
+ *
+ * \param ctx The context in which the node resides
+ * \param node The node to retrieve the namespace of
+ * \param result Pointer to location to receive node's namespace
+ * \return DOM_NO_ERR.
+ *
+ * The returned string will have its reference count increased. It is
+ * the responsibility of the caller to unref the string once it has
+ * finished with it.
+ */
+dom_exception dom_node_get_namespace(struct dom_ctx *ctx,
+ struct dom_node *node, struct dom_string **result)
+{
+ /* If there is a namespace, increase its reference count */
+ if (node->namespace != NULL)
+ dom_string_ref(ctx, node->namespace);
+
+ *result = node->namespace;
+
+ return DOM_NO_ERR;
+}
+
+/**
+ * Retrieve the prefix of a DOM node
+ *
+ * \param ctx The context in which the node resides
+ * \param node The node to retrieve the prefix of
+ * \param result Pointer to location to receive node's prefix
+ * \return DOM_NO_ERR.
+ *
+ * The returned string will have its reference count increased. It is
+ * the responsibility of the caller to unref the string once it has
+ * finished with it.
+ */
+dom_exception dom_node_get_prefix(struct dom_ctx *ctx,
+ struct dom_node *node, struct dom_string **result)
+{
+ /* If there is a prefix, increase its reference count */
+ if (node->prefix != NULL)
+ dom_string_ref(ctx, node->prefix);
+
+ *result = node->prefix;
+
+ return DOM_NO_ERR;
+}
+
+/**
+ * Set the prefix of a DOM node
+ *
+ * \param ctx The context in which the node resides
+ * \param node The node to set the prefix of
+ * \param prefix Pointer to prefix string
+ * \return DOM_NO_ERR on success,
+ * DOM_INVALID_CHARACTER_ERR if the specified prefix contains
+ * an illegal character,
+ * DOM_NO_MODIFICATION_ALLOWED_ERR if ::node is readonly,
+ * DOM_NAMESPACE_ERR if the specified prefix is
+ * malformed, if the namespaceURI of
+ * ::node is null, if the specified
+ * prefix is "xml" and the
+ * namespaceURI is different from
+ * "http://www.w3.org/XML/1998/namespace",
+ * if ::node is an attribute and the
+ * specified prefix is "xmlns" and
+ * the namespaceURI is different from
+ * "http://www.w3.org/2000/xmlns",
+ * or if this node is an attribute
+ * and the qualifiedName of ::node
+ * is "xmlns".
+ */
+dom_exception dom_node_set_prefix(struct dom_ctx *ctx,
+ struct dom_node *node, struct dom_string *prefix)
+{
+ UNUSED(ctx);
+ UNUSED(node);
+ UNUSED(prefix);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Retrieve the local part of a node's qualified name
+ *
+ * \param ctx The context in which the node resides
+ * \param node The node to retrieve the local name of
+ * \param result Pointer to location to receive local name
+ * \return DOM_NO_ERR.
+ *
+ * The returned string will have its reference count increased. It is
+ * the responsibility of the caller to unref the string once it has
+ * finished with it.
+ */
+dom_exception dom_node_get_local_name(struct dom_ctx *ctx,
+ struct dom_node *node, struct dom_string **result)
+{
+ /* If there is a local name, increase its reference count */
+ if (node->localname != NULL)
+ dom_string_ref(ctx, node->localname);
+
+ *result = node->localname;
+
+ return DOM_NO_ERR;
+}
+
+/**
+ * Determine if a node has any attributes
+ *
+ * \param ctx The context in which the node resides
+ * \param node Node to inspect
+ * \param result Pointer to location to receive result
+ * \return DOM_NO_ERR.
+ */
+dom_exception dom_node_has_attributes(struct dom_ctx *ctx,
+ struct dom_node *node, bool *result)
+{
+ UNUSED(ctx);
+
+ *result = node->attributes != NULL;
+
+ return DOM_NO_ERR;
+}
+
+/**
+ * Retrieve the base URI of a DOM node
+ *
+ * \param ctx The context in which the node resides
+ * \param node The node to retrieve the base URI of
+ * \param result Pointer to location to receive base URI
+ * \return DOM_NO_ERR.
+ *
+ * The returned string will have its reference count increased. It is
+ * the responsibility of the caller to unref the string once it has
+ * finished with it.
+ */
+dom_exception dom_node_get_base(struct dom_ctx *ctx,
+ struct dom_node *node, struct dom_string **result)
+{
+ UNUSED(ctx);
+ UNUSED(node);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Compare the positions of two nodes in a DOM tree
+ *
+ * \param ctx The context in which the nodes reside
+ * \param node The reference node
+ * \param other The node to compare
+ * \param result Pointer to location to receive result
+ * \return DOM_NO_ERR on success,
+ * DOM_NOT_SUPPORTED_ERR when the nodes are from different DOM
+ * implementations.
+ *
+ * The result is a bitfield of dom_document_position values.
+ */
+dom_exception dom_node_compare_document_position(struct dom_ctx *ctx,
+ struct dom_node *node, struct dom_node *other,
+ uint16_t *result)
+{
+ UNUSED(ctx);
+ UNUSED(node);
+ UNUSED(other);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Retrieve the text content of a DOM node
+ *
+ * \param ctx The context in which the node resides
+ * \param node The node to retrieve the text content of
+ * \param result Pointer to location to receive text content
+ * \return DOM_NO_ERR.
+ *
+ * The returned string will have its reference count increased. It is
+ * the responsibility of the caller to unref the string once it has
+ * finished with it.
+ *
+ * DOM3Core states that this can raise DOMSTRING_SIZE_ERR. It will not in
+ * this implementation; dom_strings are unbounded.
+ */
+dom_exception dom_node_get_text_content(struct dom_ctx *ctx,
+ struct dom_node *node, struct dom_string **result)
+{
+ UNUSED(ctx);
+ UNUSED(node);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Set the text content of a DOM node
+ *
+ * \param ctx The context in which the node resides
+ * \param node The node to set the text content of
+ * \param content New text content for node
+ * \return DOM_NO_ERR on success,
+ * DOM_NO_MODIFICATION_ALLOWED_ERR if ::node is readonly.
+ *
+ * Any child nodes ::node may have are removed and replaced with a single
+ * Text node containing the new content.
+ */
+dom_exception dom_node_set_text_content(struct dom_ctx *ctx,
+ struct dom_node *node, struct dom_string *content)
+{
+ UNUSED(ctx);
+ UNUSED(node);
+ UNUSED(content);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Determine if two DOM nodes are the same
+ *
+ * \param ctx The context in which the nodes reside
+ * \param node The node to compare
+ * \param other The node to compare against
+ * \param result Pointer to location to receive result
+ * \return DOM_NO_ERR.
+ *
+ * This tests if the two nodes reference the same object.
+ */
+dom_exception dom_node_is_same(struct dom_ctx *ctx,
+ struct dom_node *node, struct dom_node *other,
+ bool *result)
+{
+ UNUSED(ctx);
+
+ *result = (node == other);
+
+ return DOM_NO_ERR;
+}
+
+/**
+ * Lookup the prefix associated with the given namespace URI
+ *
+ * \param ctx The context in which the node resides
+ * \param node The node to start prefix search from
+ * \param namespace The namespace URI
+ * \param result Pointer to location to receive result
+ * \return DOM_NO_ERR.
+ *
+ * The returned string will have its reference count increased. It is
+ * the responsibility of the caller to unref the string once it has
+ * finished with it.
+ */
+dom_exception dom_node_lookup_prefix(struct dom_ctx *ctx,
+ struct dom_node *node, struct dom_string *namespace,
+ struct dom_string **result)
+{
+ UNUSED(ctx);
+ UNUSED(node);
+ UNUSED(namespace);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Determine if the specified namespace is the default namespace
+ *
+ * \param ctx The context in which the node resides
+ * \param node The node to query
+ * \param namespace The namespace URI to test
+ * \param result Pointer to location to receive result
+ * \return DOM_NO_ERR.
+ */
+dom_exception dom_node_is_default_namespace(struct dom_ctx *ctx,
+ struct dom_node *node, struct dom_string *namespace,
+ bool *result)
+{
+ UNUSED(ctx);
+ UNUSED(node);
+ UNUSED(namespace);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Lookup the namespace URI associated with the given prefix
+ *
+ * \param ctx The context in which the node resides
+ * \param node The node to start namespace search from
+ * \param prefix The prefix to look for, or NULL to find default.
+ * \param result Pointer to location to receive result
+ * \return DOM_NO_ERR.
+ *
+ * The returned string will have its reference count increased. It is
+ * the responsibility of the caller to unref the string once it has
+ * finished with it.
+ */
+dom_exception dom_node_lookup_namespace(struct dom_ctx *ctx,
+ struct dom_node *node, struct dom_string *prefix,
+ struct dom_string **result)
+{
+ UNUSED(ctx);
+ UNUSED(node);
+ UNUSED(prefix);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Determine if two DOM nodes are equal
+ *
+ * \param ctx The context in which the nodes reside
+ * \param node The node to compare
+ * \param other The node to compare against
+ * \param result Pointer to location to receive result
+ * \return DOM_NO_ERR.
+ *
+ * Two nodes are equal iff:
+ * + They are of the same type
+ * + nodeName, localName, namespaceURI, prefix, nodeValue are equal
+ * + The node attributes are equal
+ * + The child nodes are equal
+ *
+ * Two DocumentType nodes are equal iff:
+ * + publicId, systemId, internalSubset are equal
+ * + The node entities are equal
+ * + The node notations are equal
+ */
+dom_exception dom_node_is_equal(struct dom_ctx *ctx,
+ struct dom_node *node, struct dom_node *other,
+ bool *result)
+{
+ UNUSED(ctx);
+ UNUSED(node);
+ UNUSED(other);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Retrieve an object which implements the specialized APIs of the specified
+ * feature and version.
+ *
+ * \param ctx The context in which the node resides
+ * \param node The node to query
+ * \param feature The requested feature
+ * \param version The version number of the feature
+ * \param result Pointer to location to receive result
+ * \return DOM_NO_ERR.
+ */
+dom_exception dom_node_get_feature(struct dom_ctx *ctx,
+ struct dom_node *node, struct dom_string *feature,
+ struct dom_string *version, void **result)
+{
+ UNUSED(ctx);
+ UNUSED(node);
+ UNUSED(feature);
+ UNUSED(version);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Associate an object to a key on this node
+ *
+ * \param ctx The context in which the node resides
+ * \param node The node to insert object into
+ * \param key The key associated with the object
+ * \param data The object to associate with key, or NULL to remove
+ * \param handler User handler function, or NULL if none
+ * \param result Pointer to location to receive previously associated object
+ * \return DOM_NO_ERR.
+ */
+dom_exception dom_node_set_user_data(struct dom_ctx *ctx,
+ struct dom_node *node, struct dom_string *key,
+ void *data, dom_user_data_handler handler,
+ void **result)
+{
+ UNUSED(ctx);
+ UNUSED(node);
+ UNUSED(key);
+ UNUSED(data);
+ UNUSED(handler);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Retrieves the object associated to a key on this node
+ *
+ * \param ctx The context in which the node resides
+ * \param node The node to retrieve object from
+ * \param key The key to search for
+ * \param result Pointer to location to receive result
+ * \return DOM_NO_ERR.
+ */
+dom_exception dom_node_get_user_data(struct dom_ctx *ctx,
+ struct dom_node *node, struct dom_string *key,
+ void **result)
+{
+ UNUSED(ctx);
+ UNUSED(node);
+ UNUSED(key);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
Added: trunk/dom/src/core/node.h
URL: http://source.netsurf-browser.org/trunk/dom/src/core/node.h?rev=3384&view...
==============================================================================
--- trunk/dom/src/core/node.h (added)
+++ trunk/dom/src/core/node.h Fri Jul 6 15:32:44 2007
@@ -1,0 +1,60 @@
+/*
+ * This file is part of libdom.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2007 John-Mark Bell <jmb(a)netsurf-browser.org>
+ */
+
+#ifndef dom_internal_core_node_h_
+#define dom_internal_core_node_h_
+
+#include <dom/core/node.h>
+#include <dom/core/string.h>
+
+struct dom_attr;
+
+/**
+ * User data context attached to a DOM node
+ */
+struct dom_user_data {
+ struct dom_string *key; /**< Key for data */
+ void *data; /**< Client-specific data */
+ dom_user_data_handler handler; /**< Callback function */
+
+ struct dom_user_data *next; /**< Next in list */
+ struct dom_user_data *prev; /**< Previous in list */
+};
+
+/**
+ * DOM node object
+ *
+ * DOM nodes are reference counted
+ */
+struct dom_node {
+ struct dom_string *name; /**< Node name */
+ struct dom_string *value; /**< Node value */
+ dom_node_type type; /**< Node type */
+ struct dom_node *parent; /**< Parent node */
+ struct dom_node *first_child; /**< First child node */
+ struct dom_node *last_child; /**< Last child node */
+ struct dom_node *previous; /**< Previous sibling */
+ struct dom_node *next; /**< Next sibling */
+ struct dom_attr *attributes; /**< Node attributes */
+
+ struct dom_document *owner; /**< Owning document */
+
+ struct dom_string *namespace; /**< Namespace URI */
+ struct dom_string *prefix; /**< Namespace prefix */
+ struct dom_string *localname; /**< Local part of qualified name */
+
+ struct dom_user_data *user_data; /**< User data list */
+
+ uint32_t refcnt; /**< Reference count */
+};
+
+dom_exception dom_node_create(struct dom_ctx *ctx,
+ struct dom_document *doc, dom_node_type type,
+ struct dom_string *name, struct dom_string *value,
+ struct dom_node **node);
+
+#endif
Added: trunk/dom/src/core/string.c
URL: http://source.netsurf-browser.org/trunk/dom/src/core/string.c?rev=3384&vi...
==============================================================================
--- trunk/dom/src/core/string.c (added)
+++ trunk/dom/src/core/string.c Fri Jul 6 15:32:44 2007
@@ -1,0 +1,222 @@
+/*
+ * This file is part of libdom.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2007 John-Mark Bell <jmb(a)netsurf-browser.org>
+ */
+
+#include <inttypes.h>
+#include <string.h>
+
+#include <dom/ctx.h>
+#include <dom/core/string.h>
+
+#include "core/document.h"
+#include "utils/utils.h"
+
+/**
+ * A DOM string
+ *
+ * DOM strings store either a pointer to allocated data, a pointer
+ * to constant data or an offset into a document buffer.
+ *
+ * They are reference counted so freeing is performed correctly.
+ */
+struct dom_string {
+ enum { DOM_STRING_PTR,
+ DOM_STRING_CONST_PTR,
+ DOM_STRING_OFFSET
+ } type;
+ union {
+ uint8_t *ptr;
+ const uint8_t *cptr;
+ struct {
+ struct dom_document *doc;
+ uint32_t off;
+ } offset;
+ } data;
+
+ size_t len;
+
+ uint32_t refcnt;
+};
+
+/**
+ * Claim a reference on a DOM string
+ *
+ * \param ctx The context in which the string resides
+ * \param str The string to claim a reference on
+ */
+void dom_string_ref(struct dom_ctx *ctx, struct dom_string *str)
+{
+ UNUSED(ctx);
+
+ str->refcnt++;
+}
+
+/**
+ * Release a reference on a DOM string
+ *
+ * \param ctx The context in which the string resides
+ * \param str The string to release the reference from
+ *
+ * If the reference count reaches zero, any memory claimed by the
+ * string will be released
+ */
+void dom_string_unref(struct dom_ctx *ctx, struct dom_string *str)
+{
+ if (--str->refcnt == 0) {
+ if (str->type == DOM_STRING_PTR)
+ ctx->alloc(str->data.ptr, 0, ctx->pw);
+
+ ctx->alloc(str, 0, ctx->pw);
+ }
+}
+
+/**
+ * Create a DOM string from an offset into the document buffer
+ *
+ * \param ctx The context in which the string resides
+ * \param doc The document in which the string resides
+ * \param off Offset from start of document buffer
+ * \param len Length, in bytes, of string
+ * \param str Pointer to location to receive pointer to new string
+ * \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.
+ */
+dom_exception dom_string_create_from_off(struct dom_ctx *ctx,
+ struct dom_document *doc, uint32_t off, size_t len,
+ struct dom_string **str)
+{
+ struct dom_string *ret;
+
+ ret = ctx->alloc(NULL, sizeof(struct dom_string), ctx->pw);
+ if (ret == NULL)
+ return DOM_NO_MEM_ERR;
+
+ ret->type = DOM_STRING_OFFSET;
+ ret->data.offset.doc = doc;
+ ret->data.offset.off = off;
+ ret->len = len;
+
+ ret->refcnt = 1;
+
+ *str = ret;
+
+ return DOM_NO_ERR;
+}
+
+/**
+ * Create a DOM string from a string of characters
+ *
+ * \param ctx The context in which the string resides
+ * \param ptr Pointer to string of characters
+ * \param len Length, in bytes, of string of characters
+ * \param str Pointer to location to receive pointer to new string
+ * \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_string_create_from_ptr(struct dom_ctx *ctx,
+ const uint8_t *ptr, size_t len, struct dom_string **str)
+{
+ struct dom_string *ret;
+
+ ret = ctx->alloc(NULL, sizeof(struct dom_string), ctx->pw);
+ if (ret == NULL)
+ return DOM_NO_MEM_ERR;
+
+ ret->data.ptr = ctx->alloc(NULL, len, ctx->pw);
+ if (ret->data.ptr == NULL) {
+ ctx->alloc(ret, 0, ctx->pw);
+ return DOM_NO_MEM_ERR;
+ }
+
+ ret->type = DOM_STRING_PTR;
+
+ memcpy(ret->data.ptr, ptr, len);
+
+ ret->len = len;
+
+ ret->refcnt = 1;
+
+ *str = ret;
+
+ return DOM_NO_ERR;
+}
+
+/**
+ * Create a DOM string from a constant string of characters
+ *
+ * \param ctx The context in which the string resides
+ * \param ptr Pointer to string of characters
+ * \param len Length, in bytes, of string of characters
+ * \param str Pointer to location to receive pointer to new string
+ * \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 _not_ be copied for use by the
+ * returned DOM string.
+ */
+dom_exception dom_string_create_from_const_ptr(struct dom_ctx *ctx,
+ const uint8_t *ptr, size_t len, struct dom_string **str)
+{
+ struct dom_string *ret;
+
+ ret = ctx->alloc(NULL, sizeof(struct dom_string), ctx->pw);
+ if (ret == NULL)
+ return DOM_NO_MEM_ERR;
+
+ ret->data.cptr = ptr;
+
+ ret->type = DOM_STRING_CONST_PTR;
+
+ ret->len = len;
+
+ ret->refcnt = 1;
+
+ *str = ret;
+
+ return DOM_NO_ERR;
+}
+
+/**
+ * Get a pointer to the string of characters within a DOM string
+ *
+ * \param ctx The context in which the string resides
+ * \param str Pointer to DOM string to retrieve pointer from
+ * \param data Pointer to location to receive data
+ * \param len Pointer to location to receive byte length of data
+ * \return DOM_NO_ERR on success
+ *
+ * The caller must have previously claimed a reference on the DOM string.
+ * The returned pointer must not be freed.
+ */
+dom_exception dom_string_get_data(struct dom_ctx *ctx,
+ struct dom_string *str, const uint8_t **data, size_t *len)
+{
+ switch (str->type) {
+ case DOM_STRING_PTR:
+ *data = str->data.ptr;
+ break;
+ case DOM_STRING_CONST_PTR:
+ *data = str->data.cptr;
+ break;
+ case DOM_STRING_OFFSET:
+ *data = dom_document_get_base(ctx, str->data.offset.doc) +
+ str->data.offset.off;
+ break;
+ }
+
+ *len = str->len;
+
+ return DOM_NO_ERR;
+}
Added: trunk/dom/src/utils/utils.h
URL: http://source.netsurf-browser.org/trunk/dom/src/utils/utils.h?rev=3384&vi...
==============================================================================
--- trunk/dom/src/utils/utils.h (added)
+++ trunk/dom/src/utils/utils.h Fri Jul 6 15:32:44 2007
@@ -1,0 +1,28 @@
+/*
+ * This file is part of libdom.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2007 John-Mark Bell <jmb(a)netsurf-browser.org>
+ */
+
+#ifndef dom_utils_h_
+#define dom_utils_h_
+
+#ifndef max
+#define max(a,b) ((a)>(b)?(a):(b))
+#endif
+
+#ifndef min
+#define min(a,b) ((a)<(b)?(a):(b))
+#endif
+
+#ifndef SLEN
+/* Calculate length of a string constant */
+#define SLEN(s) (sizeof((s)) - 1) /* -1 for '\0' */
+#endif
+
+#ifndef UNUSED
+#define UNUSED(x) ((x)=(x))
+#endif
+
+#endif
Added: trunk/dom/test/INDEX
URL: http://source.netsurf-browser.org/trunk/dom/test/INDEX?rev=3384&view=auto
==============================================================================
--- trunk/dom/test/INDEX (added)
+++ trunk/dom/test/INDEX Fri Jul 6 15:32:44 2007
@@ -1,0 +1,4 @@
+# Index for libdom testcases
+#
+# Test Description DataDir
+
Added: trunk/dom/test/Makefile
URL: http://source.netsurf-browser.org/trunk/dom/test/Makefile?rev=3384&view=auto
==============================================================================
--- trunk/dom/test/Makefile (added)
+++ trunk/dom/test/Makefile Fri Jul 6 15:32:44 2007
@@ -1,0 +1,60 @@
+# Makefile for Hubbub testcases
+#
+# Toolchain is exported by top-level makefile
+#
+# Top-level makefile also exports the following variables:
+#
+# COMPONENT Name of component
+# EXPORT Absolute path of export directory
+# TOP Absolute path of source tree root
+#
+# The top-level makefile requires the following targets to exist:
+#
+# clean Clean source tree
+# debug Create a debug binary
+# distclean Fully clean source tree, back to pristine condition
+# export Export distributable components to ${EXPORT}
+# release Create a release binary
+# setup Perform any setup required prior to compilation
+# test Execute any test cases
+
+# Extend toolchain settings
+CFLAGS += -I${TOP}/src/ -I$(CURDIR)
+
+# Release output
+RELEASE =
+
+# Debug output
+DEBUG =
+
+# Objects
+OBJS =
+
+.PHONY: clean debug export release setup test
+
+# Targets
+release:
+
+debug:
+
+clean:
+ifneq (${OBJS}, )
+ -@${RM} ${RMFLAGS} $(addsuffix ${EXEEXT}, $(OBJS))
+endif
+
+distclean:
+ -@${RM} ${RMFLAGS} log
+
+setup:
+
+export:
+
+test: $(OBJS)
+ @${PERL} testrunner.pl ${EXEEXT}
+
+# Pattern rules
+%: %.c
+ @${ECHO} ${ECHOFLAGS} "==> $<"
+ @${CC} -c -g ${CFLAGS} -o $@.o $<
+ @${LD} -g -o $@ $@.o ${LDFLAGS} -ldom-debug
+ @${RM} ${RMFLAGS} $@.o
Added: trunk/dom/test/testrunner.pl
URL: http://source.netsurf-browser.org/trunk/dom/test/testrunner.pl?rev=3384&v...
==============================================================================
--- trunk/dom/test/testrunner.pl (added)
+++ trunk/dom/test/testrunner.pl Fri Jul 6 15:32:44 2007
@@ -1,0 +1,147 @@
+#!/bin/perl
+#
+# Testcase runner for libhubbub
+#
+# Usage: testrunner <executable extension>
+#
+# Operates upon INDEX files described in the README.
+# Locates and executes testcases, feeding data files to programs
+# as appropriate.
+# Logs testcase output to file.
+# Aborts test sequence on detection of error.
+#
+
+use warnings;
+use strict;
+use File::Spec;
+use IPC::Open3;
+
+# Get EXE extension (if any)
+my $exeext = "";
+$exeext = shift @ARGV if (@ARGV > 0);
+
+# Open log file and /dev/null
+open(LOG, ">log") or die "Failed opening test log";
+open(NULL, "+<", File::Spec->devnull) or die "Failed opening /dev/null";
+
+# Open testcase index
+open(TINDEX, "<INDEX") or die "Failed opening test INDEX";
+
+# Parse testcase index, looking for testcases
+while (my $line = <TINDEX>) {
+ next if ($line =~ /^(#.*)?$/);
+
+ # Found one; decompose
+ (my $test, my $desc, my $data) = split /\t+/, $line;
+
+ # Strip whitespace
+ $test =~ s/^\s+|\s+$//g;
+ $desc =~ s/^\s+|\s+$//g;
+ $data =~ s/^\s+|\s+$//g if ($data);
+
+ # Append EXE extension to binary name
+ $test = $test . $exeext;
+
+ print "Test: $desc\n";
+
+ my $pid;
+
+ if ($data) {
+ # Testcase has external data files
+
+ # Open datafile index
+ open(DINDEX, "<./data/$data/INDEX") or
+ die "Failed opening ./data/$data/INDEX";
+
+ # Parse datafile index, looking for datafiles
+ while (my $dentry = <DINDEX>) {
+ next if ($dentry =~ /^(#.*)?$/);
+
+ # Found one; decompose
+ (my $dtest, my $ddesc) = split /\t+/, $dentry;
+
+ # Strip whitespace
+ $dtest =~ s/^\s+|\s+$//g;
+ $ddesc =~ s/^\s+|\s+$//g;
+
+ print LOG "Running ./$test ./data/Aliases " .
+ "./data/$data/$dtest\n";
+
+ # Make message fit on an 80 column terminal
+ my $msg = " ==> $test [$data/$dtest]";
+ $msg = $msg . "." x (80 - length($msg) - 8);
+
+ print $msg;
+
+ # Run testcase
+ $pid = open3("&<NULL", \*OUT, ">&NULL",
+ "./$test", "./data/Aliases",
+ "./data/$data/$dtest");
+
+ my $last;
+
+ # Marshal testcase output to log file
+ while (my $output = <OUT>) {
+ print LOG " $output";
+ $last = $output;
+ }
+
+ # Wait for child to finish
+ waitpid($pid, 0);
+
+ print substr($last, 0, 4) . "\n";
+
+ # Bail, noisily, on failure
+ if (substr($last, 0, 4) eq "FAIL") {
+ print "\n\nFailure detected: " .
+ "consult log file\n\n\n";
+
+ exit(1);
+ }
+ }
+
+ close(DINDEX);
+ } else {
+ # Testcase has no external data files
+ print LOG "Running ./$test ./data/Aliases\n";
+
+ # Make message fit on an 80 column terminal
+ my $msg = " ==> $test";
+ $msg = $msg . "." x (80 - length($msg) - 8);
+
+ print $msg;
+
+ # Run testcase
+ $pid = open3("&<NULL", \*OUT, "&>NULL",
+ "./$test", "./data/Aliases");
+
+ my $last;
+
+ # Marshal testcase output to log file
+ while (my $output = <OUT>) {
+ print LOG " $output";
+ $last = $output;
+ }
+
+ # Wait for child to finish
+ waitpid($pid, 0);
+
+ print substr($last, 0, 4) . "\n";
+
+ # Bail, noisily, on failure
+ if (substr($last, 0, 4) eq "FAIL") {
+ print "\n\nFailure detected: " .
+ "consult log file\n\n\n";
+
+ exit(1);
+ }
+ }
+
+ print "\n";
+}
+
+# Clean up
+close(TINDEX);
+
+close(NULL);
+close(LOG);
16 years, 2 months
r3383 bursa - in /trunk/netsurf/riscos: save.c save_complete.c
by netsurf@semichrome.net
Author: bursa
Date: Thu Jul 5 05:29:09 2007
New Revision: 3383
URL: http://source.netsurf-browser.org?rev=3383&view=rev
Log:
Add URL file (with the original URL) and Inventory file (listing URLs of objects) to Full Saves.
Modified:
trunk/netsurf/riscos/save.c
trunk/netsurf/riscos/save_complete.c
Modified: trunk/netsurf/riscos/save.c
URL: http://source.netsurf-browser.org/trunk/netsurf/riscos/save.c?rev=3383&r1...
==============================================================================
--- trunk/netsurf/riscos/save.c (original)
+++ trunk/netsurf/riscos/save.c Thu Jul 5 05:29:09 2007
@@ -2,7 +2,7 @@
* This file is part of NetSurf, http://netsurf-browser.org/
* Licensed under the GNU General Public License,
* http://www.opensource.org/licenses/gpl-license
- * Copyright 2004 James Bursa <bursa(a)users.sourceforge.net>
+ * Copyright 2004-2007 James Bursa <bursa(a)users.sourceforge.net>
* Copyright 2005 Adrian Lees <adrianl(a)users.sourceforge.net>
*/
@@ -799,6 +799,11 @@
/* restore sprite name in case the save fails and we need to try again */
memcpy(sprite->name, name, 12);
+ /* save URL file with original URL */
+ snprintf(buf, sizeof buf, "%s.URL", path);
+ if (!ro_gui_save_link(c, LINK_ANT, buf))
+ return false;
+
return save_complete(c, path);
}
Modified: trunk/netsurf/riscos/save_complete.c
URL: http://source.netsurf-browser.org/trunk/netsurf/riscos/save_complete.c?re...
==============================================================================
--- trunk/netsurf/riscos/save_complete.c (original)
+++ trunk/netsurf/riscos/save_complete.c Thu Jul 5 05:29:09 2007
@@ -3,7 +3,7 @@
* Licensed under the GNU General Public License,
* http://www.opensource.org/licenses/gpl-license
* Copyright 2004 John M Bell <jmb202(a)ecs.soton.ac.uk>
- * Copyright 2004 James Bursa <bursa(a)users.sourceforge.net>
+ * Copyright 2004-2007 James Bursa <bursa(a)users.sourceforge.net>
*/
/** \file
@@ -14,6 +14,7 @@
#include <assert.h>
#include <ctype.h>
#include <errno.h>
+#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <regex.h>
@@ -55,6 +56,7 @@
static struct content * save_complete_list_find(const char *url);
static bool save_complete_list_check(struct content *content);
static void save_complete_list_dump(void);
+static bool save_complete_inventory(const char *path);
/**
* Save an HTML page with all dependencies.
@@ -69,6 +71,9 @@
bool result;
result = save_complete_html(c, path, true);
+
+ if (result)
+ result = save_complete_inventory(path);
/* free save_complete_list */
while (save_complete_list) {
@@ -114,9 +119,11 @@
if (save_complete_list_check(css))
continue;
- if (!save_complete_list_add(css)) {
- warn_user("NoMemory", 0);
- return false;
+ if (i != STYLESHEET_STYLE) {
+ if (!save_complete_list_add(css)) {
+ warn_user("NoMemory", 0);
+ return false;
+ }
}
if (!save_imported_sheets(css, path))
@@ -721,4 +728,35 @@
entry->content->url);
}
+
+/**
+ * Create the inventory file listing original URLs.
+ */
+
+bool save_complete_inventory(const char *path)
+{
+ char spath[256];
+ FILE *fp;
+
+ snprintf(spath, sizeof spath, "%s.Inventory", path);
+
+ fp = fopen(spath, "w");
+ if (!fp) {
+ LOG(("fopen(): errno = %i", errno));
+ warn_user("SaveError", strerror(errno));
+ return false;
+ }
+
+ struct save_complete_entry *entry;
+ for (entry = save_complete_list; entry; entry = entry->next)
+ fprintf(fp, "%x %s\n",
+ (unsigned int) entry->content,
+ entry->content->url);
+
+ fclose(fp);
+
+ return true;
+}
+
+
#endif
16 years, 2 months
r3382 bursa - /trunk/netsurf/Docs/00-overview
by netsurf@semichrome.net
Author: bursa
Date: Wed Jul 4 20:09:41 2007
New Revision: 3382
URL: http://source.netsurf-browser.org?rev=3D3382&view=3Drev
Log:
Clarify K&R.
Modified:
trunk/netsurf/Docs/00-overview
Modified: trunk/netsurf/Docs/00-overview
URL: http://source.netsurf-browser.org/trunk/netsurf/Docs/00-overview?rev=
=3D3382&r1=3D3381&r2=3D3382&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/netsurf/Docs/00-overview (original)
+++ trunk/netsurf/Docs/00-overview Wed Jul 4 20:09:41 2007
@@ -75,6 +75,6 @@
functions it calls, then the next externally available function, functions=
it
calls, etc.
=
-We use K&R style, tabs for indent, 80 characters wide,
+We use K&R (2nd edition ANSI C) style, tabs for indent, 80 characters wide,
lower_case_with_underscores.
=
16 years, 2 months
r3381 bursa - /trunk/netsurf/Docs/00-overview
by netsurf@semichrome.net
Author: bursa
Date: Wed Jul 4 20:05:52 2007
New Revision: 3381
URL: http://source.netsurf-browser.org?rev=3D3381&view=3Drev
Log:
Add section on Coding Style.
Modified:
trunk/netsurf/Docs/00-overview
Modified: trunk/netsurf/Docs/00-overview
URL: http://source.netsurf-browser.org/trunk/netsurf/Docs/00-overview?rev=
=3D3381&r1=3D3380&r2=3D3381&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/netsurf/Docs/00-overview (original)
+++ trunk/netsurf/Docs/00-overview Wed Jul 4 20:05:52 2007
@@ -56,3 +56,25 @@
- libjpeg (JPEG support) http://www.ijg.org/[]
- zlib http://www.gzip.org/zlib/[]
- OpenSSL (HTTPS support) http://www.openssl.org/[]
+
+Coding Style
+------------
+NetSurf's source is organised in modules. A module usually consists of a .=
c and
+.h file. For example the html module is in html.c and html.h.
+
+All functions (including static functions) in a module should start <modul=
e>_,
+for example html_create(), html_process_data(), etc. This makes functions =
easy
+to find and names unique through the source, which is=C2=A0helpful for bac=
ktraces,
+documentation, etc.
+
+Global variables in a module (including static) should also start <module>=
_.
+
+Static functions should all be declared at the top.
+
+Put functions in a logical order, for example any init function first, then
+functions it calls, then the next externally available function, functions=
it
+calls, etc.
+
+We use K&R style, tabs for indent, 80 characters wide,
+lower_case_with_underscores.
+
16 years, 2 months