summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2011-05-06 20:40:09 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2011-05-06 20:40:09 +0000
commite71691bae890040b83cfd54a2d9a1097d5026866 (patch)
tree96b2680dc6559ca0ab88fa0b6a533c13b7c9487e /desktop
parente77b1a29550e4753f771848705975295a6ebe99e (diff)
downloadnetsurf-e71691bae890040b83cfd54a2d9a1097d5026866.tar.gz
netsurf-e71691bae890040b83cfd54a2d9a1097d5026866.tar.bz2
Merge branches/jmb/content-factory to trunk
svn path=/trunk/netsurf/; revision=12283
Diffstat (limited to 'desktop')
-rw-r--r--desktop/browser.c2
-rw-r--r--desktop/netsurf.c29
-rw-r--r--desktop/plugin.h59
-rw-r--r--desktop/save_complete.c39
-rw-r--r--desktop/save_complete.h5
-rw-r--r--desktop/searchweb.c13
-rw-r--r--desktop/textinput.c2
-rw-r--r--desktop/tree.c3
-rw-r--r--desktop/tree_url_node.c37
9 files changed, 71 insertions, 118 deletions
diff --git a/desktop/browser.c b/desktop/browser.c
index fafdf7b82..1fb4de5f5 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -454,7 +454,7 @@ void browser_window_go_post(struct browser_window *bw, const char *url,
fetch_is_post ? &post : NULL,
browser_window_callback, bw,
parent != NULL ? &child : NULL,
- NULL, &c);
+ CONTENT_ANY, &c);
if (error == NSERROR_NO_FETCH_HANDLER) {
gui_launch_url(url2);
free(url2);
diff --git a/desktop/netsurf.c b/desktop/netsurf.c
index 3707b1c72..9861e7e4a 100644
--- a/desktop/netsurf.c
+++ b/desktop/netsurf.c
@@ -36,12 +36,15 @@
#include "content/hlcache.h"
#include "content/urldb.h"
#include "css/css.h"
+#include "image/image.h"
#include "desktop/netsurf.h"
#include "desktop/401login.h"
#include "desktop/browser.h"
#include "desktop/gui.h"
#include "desktop/options.h"
#include "desktop/searchweb.h"
+#include "render/html.h"
+#include "render/textplain.h"
#include "utils/log.h"
#include "utils/url.h"
#include "utils/utf8.h"
@@ -94,6 +97,7 @@ nserror netsurf_init(int *pargc,
const char *options,
const char *messages)
{
+ nserror error;
struct utsname utsname;
nserror ret = NSERROR_OK;
@@ -134,6 +138,22 @@ nserror netsurf_init(int *pargc,
messages_load(messages);
+ error = css_init();
+ if (error != NSERROR_OK)
+ return error;
+
+ error = html_init();
+ if (error != NSERROR_OK)
+ return error;
+
+ error = image_init();
+ if (error != NSERROR_OK)
+ return error;
+
+ error = textplain_init();
+ if (error != NSERROR_OK)
+ return error;
+
url_init();
setlocale(LC_ALL, "C");
@@ -176,9 +196,6 @@ void netsurf_exit(void)
LOG(("Closing GUI"));
gui_quit();
- /* Clean up after CSS */
- css_cleanup();
-
LOG(("Closing search and related resources"));
search_web_cleanup();
@@ -191,6 +208,12 @@ void netsurf_exit(void)
LOG(("Closing fetches"));
fetch_quit();
+ /* Clean up after content handlers */
+ textplain_fini();
+ image_fini();
+ html_fini();
+ css_fini();
+
LOG(("Closing utf8"));
utf8_finalise();
diff --git a/desktop/plugin.h b/desktop/plugin.h
deleted file mode 100644
index b615c91af..000000000
--- a/desktop/plugin.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright 2011 Chris Young <chris@unsatisfactorysoftware.co.uk>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/**
- * \file Content handler for plugins (interface)
- */
-
-#ifndef NETSURF_DESKTOP_PLUGIN_H_
-#define NETSURF_DESKTOP_PLUGIN_H_
-
-#ifdef WITH_PLUGIN
-
-#include <stdbool.h>
-
-#if defined(riscos)
-#include "riscos/plugin.h"
-#elif defined(nsamiga)
-#include "amiga/plugin.h"
-#endif
-
-struct box;
-struct browser_window;
-struct content;
-struct object_params;
-struct rect;
-struct http_parameter;
-
-/* function definitions */
-bool plugin_handleable(const char *mime_type);
-bool plugin_create(struct content *c, const struct http_parameter *params);
-bool plugin_convert(struct content *c);
-void plugin_reformat(struct content *c, int width, int height);
-void plugin_destroy(struct content *c);
-bool plugin_redraw(struct content *c, int x, int y,
- int width, int height, const struct rect *clip,
- float scale, colour background_colour);
-void plugin_open(struct content *c, struct browser_window *bw,
- struct content *page, struct box *box,
- struct object_params *params);
-void plugin_close(struct content *c);
-bool plugin_clone(const struct content *old, struct content *new_content);
-
-#endif /* WITH_PLUGIN */
-#endif
diff --git a/desktop/save_complete.c b/desktop/save_complete.c
index 855ed247e..48e38e7f1 100644
--- a/desktop/save_complete.c
+++ b/desktop/save_complete.c
@@ -138,6 +138,7 @@ bool save_complete_html(hlcache_handle *c, const char *path, bool index,
int source_len;
struct nscss_import *imports;
uint32_t import_count;
+ lwc_string *type;
if (sheets[i].type == HTML_STYLESHEET_INTERNAL) {
if (save_imported_sheets(
@@ -176,9 +177,19 @@ bool save_complete_html(hlcache_handle *c, const char *path, bool index,
warn_user("NoMemory", 0);
return false;
}
+
+ type = content_get_mime_type(css);
+ if (type == NULL) {
+ free(source);
+ return false;
+ }
+
res = save_complete_gui_save(path, filename, source_len,
- source, CONTENT_CSS);
+ source, type);
+
+ lwc_string_unref(type);
free(source);
+
if (res == false)
return false;
}
@@ -190,8 +201,9 @@ bool save_complete_html(hlcache_handle *c, const char *path, bool index,
hlcache_handle *obj = object->content;
const char *obj_data;
unsigned long obj_size;
+ lwc_string *type;
- if (obj == NULL || content_get_type(obj) >= CONTENT_OTHER)
+ if (obj == NULL || content_get_type(obj) == CONTENT_NONE)
continue;
obj_data = content_get_source_data(obj, &obj_size);
@@ -214,8 +226,16 @@ bool save_complete_html(hlcache_handle *c, const char *path, bool index,
}
snprintf(filename, sizeof filename, "%p", obj);
+
+ type = content_get_mime_type(obj);
+ if (type == NULL)
+ return false;
+
res = save_complete_gui_save(path, filename,
- obj_size, obj_data, content_get_type(obj));
+ obj_size, obj_data, type);
+
+ lwc_string_unref(type);
+
if(res == false)
return false;
}
@@ -282,6 +302,7 @@ bool save_imported_sheets(struct nscss_import *imports, uint32_t count,
unsigned long css_size;
struct nscss_import *child_imports;
uint32_t child_import_count;
+ lwc_string *type;
if (css == NULL)
continue;
@@ -310,9 +331,19 @@ bool save_imported_sheets(struct nscss_import *imports, uint32_t count,
return false;
}
+ if (lwc_intern_string("text/css", SLEN("text/css"), &type) !=
+ lwc_error_ok) {
+ free(source);
+ warn_user("NoMemory", 0);
+ return false;
+ }
+
res = save_complete_gui_save(path, filename, source_len,
- source, CONTENT_CSS);
+ source, type);
+
+ lwc_string_unref(type);
free(source);
+
if (res == false)
return false;
}
diff --git a/desktop/save_complete.h b/desktop/save_complete.h
index ad31fa486..6970ceaac 100644
--- a/desktop/save_complete.h
+++ b/desktop/save_complete.h
@@ -26,7 +26,8 @@
#include <stdbool.h>
#include <libxml/HTMLtree.h>
-#include "content/content.h"
+
+#include <libwapcaplet/libwapcaplet.h>
struct hlcache_handle;
@@ -34,7 +35,7 @@ void save_complete_init(void);
bool save_complete(struct hlcache_handle *c, const char *path);
bool save_complete_gui_save(const char *path, const char *filename,
- size_t len, const char *sourcedata, content_type type);
+ size_t len, const char *sourcedata, lwc_string *mime_type);
int save_complete_htmlSaveFileFormat(const char *path, const char *filename,
xmlDocPtr cur, const char *encoding, int format);
diff --git a/desktop/searchweb.c b/desktop/searchweb.c
index 23c0d5027..496ec14e1 100644
--- a/desktop/searchweb.c
+++ b/desktop/searchweb.c
@@ -209,10 +209,7 @@ void search_web_retrieve_ico(bool localdefault)
*/
return;
#else
- static const content_type accept[] = {
- CONTENT_ICO,
- CONTENT_UNKNOWN
- };
+ content_type accept = CONTENT_IMAGE;
char *url;
nserror error;
@@ -284,13 +281,7 @@ nserror search_web_ico_callback(hlcache_handle *ico,
case CONTENT_MSG_DONE:
LOG(("got favicon '%s'", content_get_url(ico)));
- if (content_get_type(ico) == CONTENT_ICO) {
- gui_window_set_search_ico(search_ico);
- } else {
- hlcache_handle_release(ico);
- search_ico = NULL;
- search_web_retrieve_ico(true);
- }
+ gui_window_set_search_ico(search_ico);
break;
case CONTENT_MSG_ERROR:
diff --git a/desktop/textinput.c b/desktop/textinput.c
index 920d8fa99..708038d9a 100644
--- a/desktop/textinput.c
+++ b/desktop/textinput.c
@@ -2128,7 +2128,7 @@ void textarea_reflow(struct browser_window *bw, struct box *textarea,
assert(c != NULL);
if (!layout_inline_container(inline_container, width,
- textarea, 0, 0, c))
+ textarea, 0, 0, (struct html_content *) c))
warn_user("NoMemory", 0);
textarea->width = width;
textarea->height = height;
diff --git a/desktop/tree.c b/desktop/tree.c
index 9dc38c247..674bc1612 100644
--- a/desktop/tree.c
+++ b/desktop/tree.c
@@ -2771,7 +2771,8 @@ hlcache_handle *tree_load_icon(const char *name)
/* Fetch the icon */
err = hlcache_handle_retrieve(icon_url, 0, 0, 0,
- tree_icon_callback, 0, 0, 0, &c);
+ tree_icon_callback, 0, 0,
+ CONTENT_IMAGE, &c);
/* If we built the URL here, free it */
diff --git a/desktop/tree_url_node.c b/desktop/tree_url_node.c
index 38fbdf3a6..a8a66dfbe 100644
--- a/desktop/tree_url_node.c
+++ b/desktop/tree_url_node.c
@@ -61,42 +61,7 @@ struct icon_entry icon_table[] = {
{CONTENT_HTML, NULL},
{CONTENT_TEXTPLAIN, NULL},
{CONTENT_CSS, NULL},
-#if defined(WITH_MNG) || defined(WITH_PNG)
- {CONTENT_PNG, NULL},
-#endif
-#ifdef WITH_MNG
- {CONTENT_JNG, NULL},
- {CONTENT_MNG, NULL},
-#endif
-#ifdef WITH_JPEG
- {CONTENT_JPEG, NULL},
-#endif
-#ifdef WITH_GIF
- {CONTENT_GIF, NULL},
-#endif
-#ifdef WITH_BMP
- {CONTENT_BMP, NULL},
- {CONTENT_ICO, NULL},
-#endif
-#ifdef WITH_SPRITE
- {CONTENT_SPRITE, NULL},
-#endif
-#ifdef WITH_DRAW
- {CONTENT_DRAW, NULL},
-#endif
-#ifdef WITH_ARTWORKS
- {CONTENT_ARTWORKS, NULL},
-#endif
-#ifdef WITH_NS_SVG
- {CONTENT_SVG, NULL},
-#endif
-#ifdef WITH_WEBP
- {CONTENT_WEBP, NULL},
-#endif
-#ifdef WITH_AMIGA_ICON
- {CONTENT_AMIGA_ICON, NULL},
-#endif
- {CONTENT_UNKNOWN, NULL},
+ {CONTENT_IMAGE, NULL},
/* this serves as a sentinel */
{CONTENT_HTML, NULL}